error 0x80040239 : Using the intersect method of ItopologicalOperator

3124
0
11-04-2014 02:52 AM
Enguerranddes_Vaux
New Contributor III

I would like to intersect a polygon and a polyline to know if the polyline is in the polygon.

The code work but when i do it on more than 100 000 times in a for, there is this error :

System.Runtime.InteropServices.COMException (0x80040239): Exception de HRESULT : 0x80040239

        à ESRI.ArcGIS.Geometry.ITopologicalOperator.Intersect(IGeometry other, esriGeometryDimension resultDimension)

My code :

    ITopologicalOperator4 topoOperateur = secteurPsr.Shape as ITopologicalOperator4;

    topoOperateur.IsKnownSimple_2 = false;

    topoOperateur.Simplify();

    IGeometry geomPsr = currentPsr.Value.Shape;

    IPolyline polylinePsr = geomPsr as IPolyline;

    (geomPsr as ITopologicalOperator2).Simplify();

    IGeometry geomResult = null;

    try

    {

        geomResult = topoOperateur.Intersect(geomPsr,esriGeometryDimension.esriGeometry1Dimension);

     }

THX for any help

UDATE :

I found the solution thaks to : http://gis.stackexchange.com/questions/10974/arcobjects-memory-leak-in-ifeatureclass-search-only-on-...

Code correction :

ITopologicalOperator4 topoOperateur = ((IClone)secteurPsr.Shape).Clone() as ITopologicalOperator4;

                    IGeometry geomPsr = currentPsr.Value.Shape;

                    IPolyline polylinePsr = geomPsr as IPolyline;

                    IGeometry geomResult = null;

                    geomResult = topoOperateur.Intersect(geomPsr, esriGeometryDimension.esriGeometry1Dimension);

     if (topoOperateur != null)

                        Marshal.FinalReleaseComObject(topoOperateur);

0 Kudos
0 Replies