I am migrating .NET code that was running against 9.3, to make it work for 10.1.There is part of the code that is failing when migrate to 10.1 and was working on 9.3The code was doing intersect twice.The code is like thisThe intersection method is wrapped into this methodpublic IGeometry GetOverlappedGeometry(IGeometry sourceGeometry, IGeometry targetGeometry)
{
IGeometry overlappedGeometry = null;
if (!IsNullOrEmptyGeometry(sourceGeometry) && !IsNullOrEmptyGeometry(targetGeometry) && IsGeometryIntersect(sourceGeometry, targetGeometry))
{
IGeometry localSourceGeometry;
IGeometry localTargetGeometry;
if (sourceGeometry.GeometryType > targetGeometry.GeometryType)
{
localSourceGeometry = targetGeometry;
localTargetGeometry = sourceGeometry;
}
else
{
localSourceGeometry = sourceGeometry;
localTargetGeometry = targetGeometry;
}
ITopologicalOperator targetOperator = localTargetGeometry as ITopologicalOperator;
if (targetOperator != null)
{
targetOperator.Simplify();
IGeometry intersectGeometry = targetOperator.Intersect(localSourceGeometry, localSourceGeometry.Dimension);
if (!IsNullOrEmptyGeometry(intersectGeometry))
{
overlappedGeometry = intersectGeometry;
}
}
}
return overlappedGeometry;
}
So the code is calling this method twice
IGeometry overlapped1 = GetOverlappedGeometry(geom1, geom2);
-- where geom1 is PolylineClass, and geom2 is PolygonClass;
IGeometry overlappe2 = GetOverlappedGeometry(geom2, overlapped1);
-- where geom2 is PolylineClass
The code is failing on the second statement,and more specifically when we are calling the intersect methodtargetOperator.Intersect(localSourceGeometry, localSourceGeometry.Dimension); and giving this errorError HRESULT E_FAIL has been returned from a call to a COM component.System.Runtime.InteropServices.ExternalException {System.Runtime.InteropServices.COMException}HResult = -2147467259