MySQL 版本无法执行几何查询

MySQL version fails to execute geometry query

如果我运行这个查询

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 上使用的比较查询?

答案在此 link

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 ) )

如 link

中所述

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]: