Marko Apfel - Afghanistan/Belgium/Germany

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

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


Twitter | LinkedIn | Xing

Article Categories


Image Galleries



Enterprise Library


SQL Server


After accessing one feature now i iterate through all features of a feature class:

open System;;

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

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 featureClass = featureWorkspace.OpenFeatureClass("Praxair.SFG.BP_L_ROHR");;

let queryFilter = new QueryFilterClass();;

let featureCursor = featureClass.Search(queryFilter, true);;

let featureCursorSeq (featureCursor : IFeatureCursor) = 
  let actualFeature = ref (featureCursor.NextFeature())
  seq {
    while (!actualFeature) <> null do
actualFeature do actualFeature := featureCursor.NextFeature() };; featureCursorSeq featureCursor |> Seq.iter (fun feature -> Console.WriteLine ((!feature).OID));;


posted on Thursday, March 25, 2010 2:49 PM


# re: F# and ArcObjects, Part 2 3/26/2010 5:21 PM Ralf Schmidt
You use an recycling cursor but store all the features you get. Does your Code really print out different OIDs or only a number of times the OID of the last found feature?

# re: F# and ArcObjects, Part 2 3/26/2010 6:11 PM Marko Apfel
Hi Ralf,
come to Kranzberg and we could have together a look at F# - like in the past .. 15 years ago in Bielefeld with Miranda in the 2nd semester of computer science :-))
Especially for you a screenshoot here
which is the result of an additional filter:
featureCursorSeq featureCursor
|> Seq.filter (fun feature -> (!feature).OID > 320)
|> Seq.iter (fun feature -> Console.WriteLine ((!feature).OID))
I hope you believe that these OIDs does not be faked :-)))
Regards to you and your family ...

# re: F# and ArcObjects, Part 2 3/26/2010 6:18 PM Ralf Schmidt
Argh, yes. Damn functional programming.
The calls to NextFeature() are only then done when the last line is evaluated.
OK, your code is right.

# re: F# and ArcObjects, Part 2 3/26/2010 6:22 PM Marko Apfel
Let us write some F# stuff for the arcAKTUELL
.. maybe in a question answer manner :-)

Post A Comment