After a huge help from Blah238.
I found exactly what is the problem.
I wasted few days checking our data, and trying many things.
The problem that I cannot do intersection between two polylines to give a result a new polyline.
It was working on 9.3. So I am not sure if it is not supposed to work , or why it is not working on 10.1
So, I modified the code to this. Now this code is generating COM exception on my machine.
Blah can you please help if you can
static void Main(string[] args)
{
//ESRI License Initializer generated code.
m_AOLicenseInitializer.InitializeApplication(new esriLicenseProductCode[] { esriLicenseProductCode.esriLicenseProductCodeStandard, esriLicenseProductCode.esriLicenseProductCodeAdvanced },
new esriLicenseExtensionCode[] { });
var geom1 = "LINESTRING (2 1, 7 1)".ToGeometry();
var geom2 = "LINESTRING (3 1, 6 1)".ToGeometry();
var targetOperator = (ITopologicalOperator)geom1;
targetOperator.Simplify();
IGeometry intersectGeometry = targetOperator.Intersect(geom2, geom2.Dimension);
Console.WriteLine(overlapped1.ToWellKnownText());
m_AOLicenseInitializer.ShutdownApplication();
}
static IGeometry GetOverlappedGeometry(IGeometry sourceGeometry, IGeometry targetGeometry, esriGeometryDimension dimension)
{
IGeometry overlappedGeometry = null;
IGeometry localSourceGeometry;
IGeometry localTargetGeometry;
if (sourceGeometry.GeometryType > targetGeometry.GeometryType)
{
localSourceGeometry = targetGeometry;
localTargetGeometry = sourceGeometry;
}
else
{
localSourceGeometry = sourceGeometry;
localTargetGeometry = targetGeometry;
}
var targetOperator = (ITopologicalOperator)localTargetGeometry;
if (targetOperator != null)
{
targetOperator.Simplify();
IGeometry intersectGeometry = targetOperator.Intersect(localSourceGeometry, dimension);
overlappedGeometry = intersectGeometry;
}
return overlappedGeometry;
}
Please notice that the code is different that Blah code down , that I am using the dimension 1 is the intersection, and not dim0 Because I want a polyline What the problem with 10.1?
Why I was able to do it on 9.3?
IsNullOrEmptyGeometryandIsGeometryIntersect)? Also do you have any test data in WKT form that reproduces the error? – blah238 Feb 28 at 3:50GetOverlappedGeometrydid you meanGetOverlappedGeometry(geom3, overlapped1)instead ofGetOverlappedGeometry(geom3, overlapped2)? – blah238 Feb 28 at 4:42