5

I use mysql spatial functions.

I have to understand if points lies withing multipolygon.
Initially I used MBRContains but it works in a strange way, so I faced the following error: Mysql function MBRContains is not accurate

enter image description here

My next step was switching to the functions ST_Contains. But I found out that if I use polygon(from multipolygon) vertex as argument - function returns false but I want to unclude all multipolygon borders.

P.S.

I found that where are function:

ST_Touches(g1, g2)

Two geometries spatially touch if their interiors do not intersect, but the boundary of one of the geometries intersects either the boundary or the interior of the other

Looks like it works like I want(in OR conditions with ST_contains) but documentation is not clear for me. Can you explain how can 2 conditions be truth together
1. Interiors do not intersects
2. Boundary intersects the interrior.

?

Question:

How can I achieve the behaviour I want?

gstackoverflow
  • 36,709
  • 117
  • 359
  • 710
  • What exactly is your question again. What does the data look like? – Salman A Dec 04 '18 at 12:42
  • @Salman A, I am sorry, I can't add more information. Could you please specify your question? – gstackoverflow Dec 04 '18 at 12:48
  • I mean I cannot feed the picture to MySQL. What exactly does the data look like? – Salman A Dec 04 '18 at 12:49
  • @Salman A, According NDA I can't provide concrete data. But you can create polygon similar to the picture – gstackoverflow Dec 04 '18 at 12:54
  • So you have a polygon and a point and you want to check if point is present/not inside polygon? – Salman A Dec 04 '18 at 12:56
  • @Salmam, yes, I want check if point locates inside polygon. If point locates on a polygon border, then answer must be true – gstackoverflow Dec 05 '18 at 10:08
  • The interiors cannot intersect and interior touches boundary are both true if and only if the polygons are **touching**. That's why the function is called ST_Touches. I don't know why @gstackoverflow's answer is not correct for your case, seems to work no? – Adam Dadvar Dec 06 '18 at 14:54

2 Answers2

1

This looks like a working solution:

ST_Contains(g1,g2) || ST_Touches(g1, g2)
Lee Goddard
  • 10,680
  • 4
  • 46
  • 63
gstackoverflow
  • 36,709
  • 117
  • 359
  • 710
-1

Looks like ST_Distance(AREA, @point)) = 0 includes border

gstackoverflow
  • 36,709
  • 117
  • 359
  • 710