Mysql GIS (a point inside a polygon and a series of points)

I saw this question: See if lat / long gets into the polygon using mysql

Indicates that the mysql GIS extensions are not yet fully implemented. Can someone clarify this for me - does this mean if I have a polygon and you want to determine if a point falls into a certain polygon, it will not be 100% accurate? If so, how accurate is that?

Also, the SQL required for this, from the top of my head, will it be something like strings:

SELECT * WHERE WITHIN(POINT(_LAT_ _LONG_), `polygon`) 

(Where the polygon is the column of the table, and the point is built from the given lat and long values).

If the accuracy is sufficient, how would you find points close to the Lat and Long data? There are different opinions regarding the use of COS / SQRT or the built-in DISTANCE functions, which is best and / or what is the best way to do?

Essentially:

  • Are mySQL GIS extensions expanded to the task of determining whether a point is in the polygon (should be fairly accurate, the polygon is not a specific shape or size).
  • If so, then what is the best method to detect this and, moreover, you need a better method for finding points near a given Lat and Long value
+4
source share
2 answers

According to docs, all functions except Distance () and Related () only check MBR relationships.

MySQL currently does not perform these functions according to the specification. Those that are implemented return the same result as the corresponding functions based on the MBR. This includes functions in the following list, except Distance () and Related ().

It is impossible to say whether the accuracy of the MBR tests is sufficient, as this depends heavily on the shape of your polygons.

"Are mySQL GIS extensions a job to determine if a point is inside a polygon (should be accurate enough, the polygon is not a specific shape or size)?

No.

Use PostGIS if you can.

An alternative would be to implement the Ray Casting algorithm for a Point-in-Polygon problem .

+3
source

It seems to be fully implemented in MySQL5.6.1 and above ( Docs ).

MySQL originally implemented these functions to use object bounding boxes and returns the same result as the corresponding MBR functions. Starting with MySQL 5.6.1, corresponding versions are available that use exact forms of objects. These versions are named with the ST_ prefix. For example, Contains () uses bounding rectangles, while ST_Contains () uses shapes of objects.

0
source

Source: https://habr.com/ru/post/1339370/


All Articles