这是我的代码:
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);