GeometryEngine.intersect of Envelope and Point not working?

894
2
05-03-2018 09:33 PM
by Anonymous User
Not applicable

I'm wondering if someone can confirm whether the GeometryEngine intersect, within and contain actually work or what I'm doing wrong here?

I'm trying to test if a point is within an Extent. You can see from the json representations below that the point definitely sits within the extent, at least as far as I can tell. As further proof, see the screenshot below where the red box is the extent and the yellow dot is the point.

But the intersect, within and contain method of the GeometryEngine all return false.

I tried converting the Envelope to a polygon, and also buffering the point slightly so I'm comparing two of the same geometry types but still couldn't get it to work.

{"spatialReference":{"wkid":2193},"x":1807060.4336000008,"y":5805845.484999999}

extent: {"spatialReference":{"wkid":2193},"xmax":1808145.75126373,"xmin":1804585.54265801,"ymax":5807337.66295673,"ymin":5804529.46796706}

FOOTNOTE: After writing the above I tried one more thing and it seemed to work, so now I'm wondering if it's a bug to do with spatial references?

I tried projecting both the extent and the point to web Mercator and performed the intersect comparison on that and it worked. So possibly the GeometryEngine not fully working yet?

0 Kudos
2 Replies
LukeSmallwood
Esri Contributor

Hi Paul, I'm glad you got the code working in the end. You are correct that GeometryEngine.intersect does expect that the two geometry objects be in a common SpatialReference. You don't necessarily need to project them both - you could do something like:

var geom2Projected = GeometryEngine.project(geom2, geom1.spatialReference());

to put them in the same system. It's also worth connecting to the errorOccurred signal of the GeometryEngine object - that should give you some information where these kinds of operations are not working.

I hope that helps,

Luke

0 Kudos
by Anonymous User
Not applicable

Hi Luke

Thanks for the reply. The only comment I'd make is that the two original geometries that I was comparing were already in the same projection. They were both in NZTM (wkid: 2193) (see the json object text I pasted in the original comment). So the GeometryEngine.intersect() didn't work when they were in NZTM, but worked when they were both converted to web Mercator.

So this suggests to be a bug of some sort still? 

0 Kudos