本文介绍了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数据"错误.

Whenever I run that I get a "MySQL: Invalid GIS data provided to function st_geometryfromtext" error.

这将返回相同的错误:

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

有什么想法吗?

推荐答案

您需要将第一个点和最后一个点指定为相同.

You need to specify the first and last point as same.

尝试一下.

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

AND

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:为函数st_geometryfromtext提供了无效的GIS数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 04:08