Select to view content in your preferred language

Geometry touches method isn't working?

1554
3
Jump to solution
08-26-2016 07:14 AM
by Anonymous User
Not applicable

Hi

A Geometry object has a 'touches' method, but it doesn't appear to work.

I have a given polygon, and have tested with polylines that are a) contained fully within, b) cross over the perimeter of and c) are completely outside, and all scenarios return a false result. I get this result whether I call geometry1.touches(geometry2) or geometry2.touches(geometry1).

To further confirm, if I call geometry1.within(geometry2) then I get the expected results of false if geometry1 is outside geometry2 or partially outside, and true if it is fully inside. I would expect that a geometry "within" therefore definitely "touches".

I also tried geometry.touches(geometry), assuming that this would return true because the two parameters are exactly the same but still got a false result.

As a workaround, I can use the intersect method and test whether it is valid:

if (geometry1.intersect(geometry2).valid){ //do something }

Can anyone else confirm whether the "touches" method is working for them or not?

Cheers,

-Paul

0 Kudos
1 Solution

Accepted Solutions
nakulmanocha
Esri Regular Contributor

Hi Paul,

I tested with polygon geometries and touch operation returns true when the two geometries actually share boundaries.For instance if I click on "Texas state " boundary as first polygon and "New Mexico" as the second polygon. Then I get the result as true.

If the polygons overlaps, crosses or completely within then it won't return true. If the two polygons are same then also touches won't return true. I also tested all these scenarios in Javascript API and I get the same results. 

I hope this helps.

Nakul

View solution in original post

3 Replies
nakulmanocha
Esri Regular Contributor

Hi Paul,

 Can you please log this a Technical Support case along with the sample code to investigate it further? Please let me know.

-Nakul

0 Kudos
nakulmanocha
Esri Regular Contributor

Hi Paul,

I tested with polygon geometries and touch operation returns true when the two geometries actually share boundaries.For instance if I click on "Texas state " boundary as first polygon and "New Mexico" as the second polygon. Then I get the result as true.

If the polygons overlaps, crosses or completely within then it won't return true. If the two polygons are same then also touches won't return true. I also tested all these scenarios in Javascript API and I get the same results. 

I hope this helps.

Nakul

by Anonymous User
Not applicable

Thanks Nakul - sorry, obviously my misunderstanding of the use of this method.

Cheers.

-Paul

0 Kudos