How to get all segments of all polygons in a polygon feature class - how  do it fast

1123
4
05-20-2010 07:14 AM
VladiH_
New Contributor
Hello,

this is my first post - I am pretty new to Esri & gisses.
I am using FileGeoDatabase and C#

What is my problem: The SPEED of getting all segments of all polygons in a feature class. I found out about two ways how to do it:

First way:
   1. enumerate all polygons, get every single one's ExteriorRingBags (inputPoly.ExteriorRingBag),
        2. enumerate all it's exterior rings, get segments from every exterior ring and get interior ringbag of every  exterior ring (inputPoly.get_InteriorRingBag(extRing))
            3. enumerate all interior rings of every interior ringbag and get it's segments
    This way I can collect all segments from all features of a polygon feature class and use them somewhere else (I actually just need the start and end coordinates of each segment)

Second way:
     Usings the function: "FeatureToLine" I can store all features of a polygon feature class, but then I need to get every single segment of the newly created Line class.

The "First" way => to go through all the ArcObjects, through all the enumerations to collect the semgents, is damn slow and therefore not usable - to collect all segments (finally I got them 218 000) of 17000 features lasts over 30 minutes

The "Second" way is a bit faster, because there are not as many enumerations as in the first way, but it is still slow...

Therefore my question: Does anybody know how to query/get all segments of all polygons really fast way? I really need to get through them within seconds or worst - within "very" few minutes, but can't let the algorithm work for 30 min....

Does anybody know how to help me?

Every help is appreciated!!!

Thanx,

   Vladimir
0 Kudos
4 Replies
KirkKuykendall
Occasional Contributor III
Have you tried IGeometryBridge.QuerySegments ?

One of the design goals of IGeometryBridge is to improve performance.
http://resources.esri.com/help/9.3/arcgisengine/dotnet/b0e79fb3-ee12-4cbc-a31f-60f1eb4a4861.htm
0 Kudos
VladiH_
New Contributor
Hi kirkktx!

      Thank you for your answer and new ideas - ok, I tried IGeometryBridge.QuerySegments, but it still does not improve performance signifficantly - with this amount of features it saves some 5 minutes, so the whole iterating lasts 25 minutes instead of 30 minutes. The problem stays that I still need to iterate through: all polygons, their external and internal rings, cast each ring to ISegmentCollection and first this I can use with IGeometryBridge.QuerySegments... :-(.

But the link you provided shows that using Visual C++ on problem parts instead of using C#, can save some signifficant time - they show how using C# 2.0 costs 6 times more time time than using Visual C++!!!. I am using C# 3.5, which has got improvements in speed against C# 2.0. It looks like I have to rewrite the problem parts into C++ & then we will see if the speed improves enough...

But there is one thing bothering me - as we are using C# in our development environment, I will need a C# solution... and... I cannot believe ESRI is letting you rewrite your code into C++ to solve performance problems... Is there not some another "C#" solution?

Thanx for your help, -still, any help is appreciated!!!
0 Kudos
KirkKuykendall
Occasional Contributor III
Have you considered using ArcSDE?

Maybe try SqlServer with  SDEBINARY option.
0 Kudos
VladiH_
New Contributor
Thx, but I need it with File Geodatabase and may be other types of databases too... I probably have the solution... -Now no matter which type of database I choose, it always remains fast. What I did: I at last rewrote it into unmanaged C++ as Esri proposed it in the link you provided. Now the running of the whole  code (the one that lasts for around 25-30 minutes in C#) lasts for no more than 20 SECONDS!!!  ...But the sad problem remains that in C# ( I am using 3.5) there is probably no other solution...?? I will try other SQL solutions including ArcSde once I will have an SQL server, but now I am searching for kind of general solution which will work everywhere.
0 Kudos