Get points from intersecting lines

3790
3
07-21-2016 01:50 AM
ErvyGalvez
New Contributor

Hi All,


I want to get the points from intersecting polylines using the ArcGIS API for JavaScript. While I am exploring the developers site, I came across the geometryserive.intersect(geoms, geom) using this link GeometryService | API Reference | ArcGIS API for JavaScript 3.17 or r  geometryEngine.intersect(geoms, intersector) using this esri/geometry/geometryEngine | API Reference | ArcGIS API for JavaScript 3.17 . also no luck using the mathUtils.getLineIntersectionn(line1s, line1e, line2s, line2e) esri/geometry/mathUtils | API Reference | ArcGIS API for JavaScript 3.17 But then i can't seem to run it the way it was describe.

Aside from geometryEngine.geodesicBuffer(), all other methods do not have a WORKING SAMPLE.

kindly help me with this. thanks.

Reply
0 Kudos
3 Replies
RobertScheitlin__GISP
MVP Esteemed Contributor

Ervy,

If you are trying to evaluate a existing featureclass for intersects, there are many things that are just better done using ArcGIS Desktop. If it is a requirement for this to be done clientside then prepare for a slow process of looping through each line and evaluating if that line intersects with each other line in your loop and then move to the next line in the loop and repeat the process again. Unlike ArcMap where you can say take FC1 and Intersect with FC2, the JS API works with individual geometries.

Are all the line geometries in the same layer?

Are you trying to evaluate if a current layer has any geometries that intersect or are you allowing the user to draw geometry and what to know if that drawn geometry intersects another?

Reply
0 Kudos
ErvyGalvez
New Contributor

Hi Robert,

Thanks for your quick response.

I want it to be done client side using the ArcGIS API for JavaScript.

The geometries came from a 2 query results and both are returning polyline as geometry. I am using GraphicsLayer to store the geometry of two different lines. Then using the geometryEngine.intersects() method to evaluate whether the 2 polylines intersects. When the method return true, I want to get the point (xy or LongLat) from the intersection to do another process.

BlueGreenLines.jpg

In the image above is the result from a query which are stored in a GraphicsLayer. The Green Lines that are intersected by Blue Line visually. In the next image, I put Red Points. Those points are the one that I want to get from the intersection of the 2 lines.

BlueGreenLinesRedPoints.jpg

I already tried the ArcGIS for Desktop Intersect Tool. That tool from the desktop is the one I want in my web base application. As I was exploring the ArcGIS API for JavaScript 3.17 , I came across the esri/geometry/geometryEngine | API Reference | ArcGIS API for JavaScript 3.17 and it has this method geometryEngine.intersect() (which is use to get the points of intersection) and geometryEngine.intersects() (use for determining whether the geometries intersects with each other). I also test the GeometryService | API Reference | ArcGIS API for JavaScript 3.17 but no luck.

I am frustrated because the geometryEngine class do not have a WORKING SAMPLE other than the geometryEngine.geodesicBuffer() method.

I hope you can help with this. Thank you.

Reply
0 Kudos
KristianEkenes
Esri Regular Contributor

Ervy,

The intersect method is designed to return the geometry of the intersection in the lowest dimension of the two input geometries. Since this case uses two lines (which are one dimensional) the output must also be a line. Because this seems counterintuitive, we're looking at the possibility of adding GeometryEngine support for returning a lower dimension than the inputs for this very reason. With two lines you expect to get a point (or several points) back, not necessarily a line.

Just know that this is the current expected behavior, it's on our radar, and we're looking at improving it. Also note that this isn't a simple problem to solve. Because lines can be complex, containing many segments and vertices, processing this on the client can potentially be heavy.