GeometryEngine.Intersection of Polyline and Polyline

1522
1
06-23-2016 08:57 AM
charlesroberts3
New Contributor

ArcGIS Runtime for .NET 10.2.7

I am using GeometryEngine.Intersect to find the intersection of two Polylines. The GeometryEngine.Intersects function returns the correct value, however, GeometryEngine.Intersection  returns only an empty geometry, not very useful. I expect a MapPoint.
How can I retrieve the intersection point?

Polyline p1 = new Polyline(new List<MapPoint>()

{

     new MapPoint(55.0, 25.0, SpatialReferences.Wgs84),

     new MapPoint(57.0, 25.0, SpatialReferences.Wgs84)

});

Polyline p2 = new Polyline(new List<MapPoint>()

{

     new MapPoint(56.0, 24.0, SpatialReferences.Wgs84),

     new MapPoint(56.0, 26.0, SpatialReferences.Wgs84)

});

if( GeometryEngine.Intersects(p1, p2))

{

    var intersection = GeometryEngine.Intersection(p1, p2);

     System.Diagnostics.Trace.WriteLine(intersection.IsEmpty);

}

0 Kudos
1 Reply
JoshuaBixby
MVP Esteemed Contributor

My guess is that you are getting a MULTILINESTRING EMPTY returned to you, which is a valid geometry, just an empty one.  Back when I did ArcObjects programming, the Intersection method had a third parameter that specified the dimension of the product you wanted returned.  With your example, asking for a point would return the point you seek while asking for a line would return an empty multilinestring.

Looking at the geometry engine documentation, that doesn't appear to exist anymore.  I will have to think about how to work around this.

0 Kudos