Intersect two polylines to produce third polyline on 10.1 is broken

559
6
03-01-2013 07:33 AM
GhassanKarwchan
New Contributor III
So, I am migrating code from 9.3 to 10.1 SP1.
The code is working on 9.3, but not on 10.1 SP1

After long fight I narrow the problem to this.

In 10.1 I cannot do intersection between two polylines to produce third polyline.
Is that correct?

I wrote below very simple Visual Studio console application that is doing intersection between two polylines.

I created very two simple polylines, using WKT library , which you can get it from here.
Anyway you can replace it with any code that generate simple polylines.

        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, esriGeometryDimension.esriGeometryNoDimension );
            Console.WriteLine(intersectGeometry.ToWellKnownText());


            m_AOLicenseInitializer.ShutdownApplication();

        }


The above code generate this COM Exception
Error HRESULT E_FAIL has been returned from a call to a COM component.
With error code
-2147467259
0 Kudos
6 Replies
LeoDonahue
Occasional Contributor III
In Java, I would have to put some of that in a try-catch block.  Does .NET not have AutomationExceptions?
0 Kudos
GhassanKarwchan
New Contributor III
In Java, I would have to put some of that in a try-catch block.  Does .NET not have AutomationExceptions?


My concern is not about handling the exception.
My question is why I cannot do intersection of two polylines to produce a polyline in 10.1

And thanks for your help, but I know how to do exception handling, and I am not that stupid to ask how to do exception handling in .net on ESRI forum
0 Kudos
LeoDonahue
Occasional Contributor III
My question is why I cannot do intersection of two polylines to produce a polyline in 10.1

I don't know.  Probably something you are missing.  Based on the code you posted, I can't tell.

I'm sure ESRI would not leave the ability to use the intersect method broken through a major upgrade to 10.1 and SP1.
0 Kudos
WeifengHe
Esri Contributor
I believe this is a special case.  Both input lines are horizontal and overlapping with each other.  This can causes the crash as you mentioned.  The problem has already been addressed in 10.2.
0 Kudos
GhassanKarwchan
New Contributor III
I believe this is a special case.  Both input lines are horizontal and overlapping with each other.  This can causes the crash as you mentioned.  The problem has already been addressed in 10.2.


I am wondering if there is a work around
In my case, I am having input from the users.
It is happening on horizontal or vertical lines.
They are few but the exists, and I need to process them.

Thanks
0 Kudos
WeifengHe
Esri Contributor
The easiest way right now to deal with these situations is to work on a pre 10.1 set up, say 10.0 or 9.3, until 10.2 comes out.

The work around probably won't be pretty.  To make it work in 10.1, you might want to avoid the cases such as the bounding box or the envelope which holds the 2 input polylines has an area equal to 0.  For example, in your case, you can add an extra non-horizontal segment to one of the input lines.  Or rotate-intersect-rotate back?  Maybe you have better idea.
0 Kudos