Marko Apfel - Afghanistan/Belgium/Germany

Management, Architecture, Programming, QA, Coach, GIS, EAI

  Home  |   Contact  |   Syndication    |   Login
  187 Posts | 2 Stories | 201 Comments | 4 Trackbacks

News



Twitter | LinkedIn | Xing

Archives

Post Categories

BizTalk

C#

Enterprise Library

SAP

SQL Server

Technologie

Today i played a little bit with IFeature-sequences and piping data.
The result was a calculator of the bounding box around all features in a feature class.

Maybe a little bit dirty, but for learning was it OK. ;-)

open System;;

#I "C:\Program Files\ArcGIS\DotNet";;
#r "ESRI.ArcGIS.System.dll";;
#r "ESRI.ArcGIS.DataSourcesGDB.dll";;
#r "ESRI.ArcGIS.Geodatabase.dll";;
#r "ESRI.ArcGIS.Geometry.dll";;
open ESRI.ArcGIS.esriSystem;;
open ESRI.ArcGIS.DataSourcesGDB;;
open ESRI.ArcGIS.Geodatabase;;
open ESRI.ArcGIS.Geometry;

let aoInitialize = new AoInitializeClass();;

let status = aoInitialize.Initialize(esriLicenseProductCode.esriLicenseProductCodeArcEditor);;

let workspacefactory = new SdeWorkspaceFactoryClass();;

let connection = "SERVER=okul;DATABASE=p*;VERSION=sde.default;INSTANCE=sde:sqlserver:okul;USER=s*;PASSWORD=g*";;

let workspace = workspacefactory.OpenFromString(connection, 0);;

let featureWorkspace = (box workspace) :?> IFeatureWorkspace;;

let featureCursorSeq (featureCursor : IFeatureCursor) = 
  let actualFeature = ref (featureCursor.NextFeature())
  seq {
    while (!actualFeature) <> null do
yield
actualFeature do actualFeature := featureCursor.NextFeature() };; let min x y = if x < y then
x else
y;; let max x y = if x > y then
x else
y;; let info s (x : IEnvelope) = match x with
| null -> printfn "%s is null" s | _ ->
printfn "%s xMin:{%f} xMax: {%f} yMin:{%f} yMax: {%f}" s x.XMin x.XMax x.YMin x.YMax;; let con (env1 : IEnvelope) (env2 : IEnvelope) = match env1 with
| null -> env2 | _ ->
let
env = (new EnvelopeClass()) :> IEnvelope env.XMin <- min env1.XMin env2.XMin env.XMax <- max env1.XMax env2.XMax env.YMin <- min env1.YMin env2.YMin env.YMax <- max env1.YMax env2.YMax info "Intermediate" env env ;; let BoundingBox featureClassName = let featureClass = featureWorkspace.OpenFeatureClass(featureClassName) let queryFilter = new QueryFilterClass() let featureCursor = featureClass.Search(queryFilter, true) let featureCursorSeq (featureCursor : IFeatureCursor) = let actualFeature = ref (featureCursor.NextFeature()) seq { while (!actualFeature) <> null do
yield
actualFeature do actualFeature := featureCursor.NextFeature() } featureCursorSeq featureCursor |> Seq.map (fun feature -> (!feature).Extent) |> Seq.fold (fun (acc : IEnvelope) a ->
info "Intermediate" acc (con acc a)) null
;; let boundingBox = BoundingBox "Praxair.SFG.BP_L_ROHR";; info "Ende-Info:" boundingBox;;

 

posted on Friday, March 26, 2010 1:15 PM