0

I use mysql spatial functions.

I have to understand if points lies withing multipolygon.Birder must be included.

My expriments showed that ST_Contains does not include border of Multipolygon

So for now I have 2 solutions which looks like working:
1. ST_Contains(g1,g2) || ST_Touches(g1, g2)
2. ST_distance(g1,g2)=0

Are that solutions equivalent ?

gstackoverflow
  • 36,709
  • 117
  • 359
  • 710
  • Do you want to test for "single point inside a geometry or on its border" (otherwise your two conditions are clearly not equivalent)? You can use `st_intersects` for that. – Solarflare Nov 30 '18 at 11:24
  • @Solarflare could you please elaborate? – gstackoverflow Nov 30 '18 at 11:35
  • I just meant that it looks as if you are trying to test if a point lies on the polygon or on its border, and since the border is excluded in `st_contains`, you seem to add an additional `st_touches`. And it looks as if you are trying to now simplify your expression (by `st_distance`). So *if* that is what you are after, I'd try `st_intersects` (="is there any point where they overlap", which, for a point, checks if the point is inside *or on the border* of the other shape). Not entirely sure though if that is your actual question/problem. – Solarflare Nov 30 '18 at 12:34
  • @Solarflare, You understood my question properly. According the docs st_intersect is inversion of st_contains – gstackoverflow Nov 30 '18 at 17:33
  • No, it's not the inversion (you can just verify that if contains is true, intersects is also true). But you should just test it, it should (for a point and a polygon) do what (I think) you expect. – Solarflare Nov 30 '18 at 18:44

0 Answers0