MySQL:为函数st_geometryfromtext提供的GIS数据无效
作者:互联网
这是我的代码:
SET @poly =
'Polygon((-98.07697478272888 30.123832577126326,
-98.07697478272888 30.535734310413392,
-97.48302581787107 30.535734310413392,
-97.48302581787107 30.123832577126326))';
SELECT name
FROM county_shapes
WHERE MBRContains(ST_GeomFromText(@poly), SHAPE);
每当我运行时,我得到一个“MySQL:提供给函数st_geometryfromtext的无效GIS数据”错误.
这会返回相同的错误:
SELECT name
FROM county_shapes
WHERE MBRContains(ST_GeomFromText('Polygon((-98.07697478272888 30.123832577126326,
-98.07697478272888 30.535734310413392,
-97.48302581787107 30.535734310413392,
-97.48302581787107 30.123832577126326))'), SHAPE);
有任何想法吗?
解决方法:
您需要将第一个和最后一个点指定为相同.
尝试这个.
SET @poly =
'Polygon((-98.07697478272888 30.123832577126326,
-98.07697478272888 30.535734310413392,
-97.48302581787107 30.535734310413392,
-97.48302581787107 30.123832577126326,
-98.07697478272888 30.123832577126326,))';
SELECT name
FROM county_shapes
WHERE MBRContains(ST_GeomFromText(@poly), SHAPE);
和
SELECT name
FROM county_shapes
WHERE MBRContains(ST_GeomFromText('Polygon((
-98.07697478272888 30.123832577126326,
-98.07697478272888 30.535734310413392,
-97.48302581787107 30.535734310413392,
-97.48302581787107 30.123832577126326,
-98.07697478272888 30.123832577126326))'), SHAPE);
标签:mysql-5-7,mysql,gis,spatial-index 来源: https://codeday.me/bug/20191008/1871836.html