如果我运行这个查询
SELECT region_id FROM shape_region WHERE ST_Within(point(-117.10480, 32.72204),shape_region.shape)=1
在MySQL MariaDB version 10.1.13-MariaDB上,没有问题。
但是在 MySQL 版本 5.7.16-0ubuntu0.16.04.1 上我得到这个错误
Binary geometry function st_within given two geometries of different srids: 0 and 1, which should have been identical.
我不明白这个错误,有没有我可以在这个版本的 MySQL 上使用的类似查询?
最佳答案
在此链接找到答案
https://bugs.mysql.com/bug.php?id=79282
适用于 MySQL 和 MariaDB 的兼容查询:
SELECT region_id FROM shape_region WHERE ST_Contains( SHAPE, ST_GeomFromText( 'POINT(-122.392128 37.795653)', 1 ) )
如链接中所述
You can't compare a shape in one spatial reference system (SRID 1) with a point in another spatial reference system (SRID 0). The POINT() function[1] will always return a point in SRID 0, which is the unitless, Cartesian default spatial reference system.
In order to do the intended comparison, the point has to be in the same spatial reference system as the shape. E.g., use the SRID parameter of ST_GeomFromText()[2]:
关于MySQL版本无法执行几何查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42424864/