AnsweredAssumed Answered

Question about geometryEngine intersect

Question asked by ibroad on Apr 4, 2018
Latest reply on Apr 4, 2018 by ibroad

I'm doing some testing, and the intersect tool isn't working like I thought it would.

 

I have simple code using the SketchViewModel to create a polyline.

 

I check the graphicLayer, and when 2 lines are created I want to get a point geometry where the lines intersect.

 

sketchViewModel.on('draw-complete', function(evt) {
     graphicsLayer.add(evt.graphic);

     if (graphicsLayer.graphics.items.length == 2) {
          console.log(graphicsLayer);

          var line1 = graphicsLayer.graphics.items[0].geometry;
          var line2 = graphicsLayer.graphics.items[1].geometry;

          console.log(line1);
          console.log(line2);

          var intersection = geometryEngine.intersect(line1, line2);

          console.log(intersection);
     }
});

 

`line1` and `line2` log fine with correct geometry, but `intersection` just logs `null`.

 

Any idea why?

 

If I change `intersect` to `intersects` it logs `true`.

Outcomes