Apply buffer around polyline

588
3
Jump to solution
07-24-2013 06:52 AM
CarstenSchumann
Occasional Contributor
Hey folks,

I am trying retrieve a polyline from within a polygon. I use IRing#GetSubCurveEx for this. Afterwards I am trying to build a buffer around the curve, so I build up a polyline from the segments of the curve, as follows:
// try counter-clockwise ICurve c1 = ring.GetSubcurveEx(fromDistance, toDistance, false, true, false); IPolyline p1 = new PolylineClass(); ISegmentCollection segments = (ISegmentCollection) p1; segments.AddSegmentCollection((ISegmentCollection) c1); // build a buffer around the curve ITopologicalOperator topo = (ITopologicalOperator) p1; IPolygon buffer = (IPolygon) topo.Buffer(bufferSize);


This code works so far, but on one single polygon it crashes with the following error: 0x8004023E which is the EsriNetworkError NETWORK_E_INVALID_ELEMENT_TYPE. But as I do not use any ERSI-Network-functionality I am somehow confused on this error. Moreover this code works one time on a given polygon, but if I pass this polygon a second time to this part of code the mentioned error occurs. I wonder under which circumstances this error is created if the polygon is known to be simple.

Any help appreciated

EDIT: Maybe I should also mention that the first time I use another from- and toPoint for retrieving the subcurve of the ring, but as I also check the distances of the from/to-Points to the ring to be null I can ensure these points are on the boundary of my ring.
0 Kudos
1 Solution

Accepted Solutions
CarstenSchumann
Occasional Contributor
I finally managed the issue by setting the spatial reference of the geometry. But I wonder why this worked all the time before without setting the reference...

View solution in original post

0 Kudos
3 Replies
CarstenSchumann
Occasional Contributor
I finally managed the issue by setting the spatial reference of the geometry. But I wonder why this worked all the time before without setting the reference...

View solution in original post

0 Kudos
VinceAngelo
Esri Esteemed Contributor
That's probably a question in the ArcObjects forum, but generally, if you need
to set the spatial reference, it's because you're using a mix of them and/or
some of the feature classes don't have one assigned, neither of which is
really recommended.

- V
0 Kudos
CarstenSchumann
Occasional Contributor
Thanks for the hint, actually the spatial references of the concerned featureClasses is set correctly, it seems its getting lost while doing some geometric operations on the features. This is why I have to reset it to the reference set in the featureClass.
0 Kudos