MySQL空间几何验证wkt [英] MySQL spatial geometry validate wkt

查看:274
本文介绍了MySQL空间几何验证wkt的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在MySQL中< 5.7当给定无效的WKT时,空间函数返回NULL,例如:

In MySQL < 5.7 the spatial functions returned NULL when given invalid WKT, eg:

mysql> select astext(geomfromtext('polygon()'));

+-----------------------------------+
| astext(geomfromtext('polygon()')) |
+-----------------------------------+
| NULL                              |
+-----------------------------------+
1 row in set (0.00 sec)

但是对于更新的MySQL,相同的输入给出了:

But with newer MySQL the same input gives:

ERROR 3037 (22023): Invalid GIS data provided to function st_geometryfromtext.

在将WKT发送到几何函数之前,是否可以检查WKT是否有效? 另外,是否有一个设置可以强制几何函数产生NULL而不是无效输入的错误?

Is there a way of checking whether the WKT is valid before sending it to the geometry functions? Alternatively is there a setting to force the geometry functions to produce NULL rather than error for invalid input?

推荐答案

MySQL提供了两个功能来测试几何形状的有效性,但是都以已经形成的几何形状作为输入.

there are two functions provided by MySQL to test validity of geometries, but both take an already formed geometry as input.

ST_IsValid(ST_GeomFromText(?));返回一个布尔值

ST_Validate(ST_GeomFromText(?));返回GEOM;如果无效,则返回null.

ST_Validate(ST_GeomFromText(?)); returns the GEOM or null if invalid.

我对MySQL中的WKT解析没有任何了解,也没有设置可以将其切换回< 5.7行为.

there is nothing I know of that parses WKT in MySQL, nor is there a setting that will switch it back to <5.7 behaviour.

这篇关于MySQL空间几何验证wkt的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆