首页 > 解决方案 > MySQL ST_Intersection 不允许地理 SRS 参数

问题描述

我已经安装了 mysql-community-server 8.0.27,希望ST_Intersection允许笛卡尔或地理 SRS 中的参数作为文档https://dev.mysql.com/doc/refman/8.0/en/spatial-operator- functions.html#function_st-intersection说,但有一个错误:

mysql> set @b1 = ST_Buffer(ST_SRID(POINT(0, 0), 4326), 1);
Query OK, 0 rows affected (0.00 sec)

mysql> set @b2 = ST_Buffer(ST_SRID(POINT(0, 0), 4326), 2);
Query OK, 0 rows affected (0.00 sec)

mysql> select ST_Intersection(@b1, @b2);
ERROR 3618 (22S00): st_intersection(POLYGON, POLYGON) has not been implemented for geographic spatial reference systems.

虽然可以通过将 SRID 从 4326 更改为 0 来使用笛卡尔参数。

我错过了什么,还是文档不准确?

标签: mysqlgeospatial

解决方案


有解决该错误的方法吗?,因为ST_DIFFERENCE工作正常。

例如,要计算交叉口的面积,预期呼叫:

select ST_Area(ST_Intersection(@b1, @b2));

可以通过以下方式实现:

select ST_Area(@b1) - ST_Area(ST_Difference(@b1, @b2));

推荐阅读