当前位置:  开发笔记 > 编程语言 > 正文

MySQL:为函数st_geometryfromtext提供的GIS数据无效

如何解决《MySQL:为函数st_geometryfromtext提供的GIS数据无效》经验,为你挑选了1个好方法。

这是我的代码:

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

有任何想法吗?



1> codejunkie..:

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

试试这个.

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

推荐阅读
mylvfamily
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有