Mysql: ST_Contains with borders to detect if multipolygon contains point

穿精又带淫゛_ 提交于 2019-12-07 10:55:02

问题


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

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?


回答1:


Looks like working solution:

ST_Contains(g1,g2) || ST_Touches(g1, g2)



回答2:


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



来源:https://stackoverflow.com/questions/53456885/mysql-st-contains-with-borders-to-detect-if-multipolygon-contains-point

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!