Select to view content in your preferred language

Some errors on Intersection by ITopologicalOperator

3391
4
06-24-2010 03:32 PM
MerhutOqaz
Deactivated User
I'm trying to intersect some polygons (shapes from graphic objects, not features) using the  Intersect method of the ITopologicalOperator class. On the same geometries sometime it works and sometime not.
The code I use is

        Dim pPoly1, pPoly2, pIntersection As IPolygon
        ..
        ..  'give a square shape to the polygons
        ..
        Dim opTop As ITopologicalOperator3 = pPoly1
        pIntersection = opTop.Intersect(pPoly2, esriGeometryDimension.esriGeometry2Dimension)


I've tried also with ITopologicalOperator and ITopologicalOperator2 with the same results.
I can not find a pattern for the uncorrect behaviour except that it seems to get worst the more I move one polygon far right to the other (I know it's strange). In the attached picture the green area is pIntersection .
Any idea?
Thank you in advance
Valentino
0 Kudos
4 Replies
GeorgeSilva
Emerging Contributor
Hello valentino,

ITopologicalOperator needs to have accurate ISpatialReference values, otherwise it may give bizzare results.

Are you declaring the ISpatialReference for your graphics? You features might have Spatial Refrences, but what about the graphics?
0 Kudos
by Anonymous User
Not applicable
Original User: kirkktx

Also, don't assume the geometry of an IElement is Simple - try simplifying be setting IsKnownSimple to false and call Simplify.  In addition to George's spatialref advice, consider calling IGeometry.SnapToSpatialReference.
0 Kudos
MerhutOqaz
Deactivated User
Thank you, George and Kirk.
Following your advices I've added the lines of code below for all the polygons involved but it still doesn't work!

pPoly1.SpatialReference = m_spatialReference      'spatial reference of the map
pPoly1.SnapToSpatialReference()
Dim opTop As ITopologicalOperator4 = pPoly1
If (Not opTop.IsknowSimple) Then                       'isKnowSimple is readonly, I can not set to False
       opTop.Simplify()
End If
'**** make intersect or any other opTop method



I really don't know what to do. That operator is involved in almost any geometrical operation I need to do on map objects.
0 Kudos
by Anonymous User
Not applicable
Original User: kirkktx

try opTop.IsKnownSimple_2 = false
0 Kudos