How to find the point where two polylines intersect??

3588
5
01-12-2017 12:05 PM
PeterLen
Occasional Contributor

Hello,

In my client, I have two polylines.  I need to find the point where both lines intersect.  I thought that I had found a way to find that out by using the esri.geometry.getLineIntersection(pt, pt, pt, pt), which takes the starting and ending points of each lines.  That does in fact return a single point at the intersection, but the problem is that the function calculates all of the intersections as if both lines would continue forever.  Since one of the polylines will have multiple line segments going in various directions, the getLineIntersection returns multiple points, even though both lines only crossed once.  The function does not take into consideration the length of the line in order to determine if an intersection takes place.

Does anyone know there another way to do this so that I only get the one single intersection point?

My specs: The solution needs to be client-based (JavaScript API) using the Esri JavaScript v3.9 API (I know it is an older API but I cannot upgrade).

If it can't be done with my specs, then that is fine.  At least I would know.

Thanks for any thoughts - Peter

0 Kudos
5 Replies
RobertScheitlin__GISP
MVP Emeritus

Peter,

   Take a look at this thread for some details:

https://community.esri.com/thread/180187 

0 Kudos
PeterLen
Occasional Contributor

Robert - Thanks for the response.  I had previously come across that post.  The problem is that the GeometryEngine was not available until v3.13 of the Esri Javascript API and I am stuck using v3.9.  Thanks for looking - Peter

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Peter,

   What you are looking for exactly is not even available no at 3.19. Notice that Kristen says they will look at the ability to output a point in the future for now the intersect outputs a line from to input lines. Also you can use the GeometryService.intersect you do not need the GeometryEngine for this.

0 Kudos
PeterLen
Occasional Contributor

Robert - I was looking at the GeometryService.intersect.  I must be missing something because in the callback, I do get an object that contains a geometry array.  Inside of that, however, are one or more objects that have a type of polyline but no paths, so I don't see it returning any actual geometries.  I may be missing something on how it is to be used, but it looks like that service will return a polyline(s), which is not what I am looking for. 

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Peter,

   Yep that is what the other thread was mainly about the fact that the GeometryService.intersect using lines as input will return a line instead of a point.

0 Kudos