我有一个包含MariaDB中多个坐标的多边形:
POLYGON((50.4668 -6.90665,51.73607 0.14657,55.3032 -4.52724,50.4668 -6.90665))
我想像这样用MariaDB计算该多边形的面积:
SELECT ST_Area(ST_GeomFromText('POLYGON((50.4668 -6.90665,50.4668 -6.90665))'))
上面的查询结果是15.546039738650009,这是错误的.我使用this工具计算了多边形的面积,得出119116192747.1.
如何使mariaDB理解此多边形包含经度和纬度以正确计算面积?
最佳答案
根据MariaDB文件,它不提供此功能:
In MariaDB,the SRID value is just an integer associated with the geometry value. All calculations are done assuming Euclidean (planar) geometry.
但是,在Mysql 8.0.13中提供了此功能,您可以使用ST_Area()计算多边形面积:
Incompatible Change: Previously,ST_Area() supported only geometry arguments having a Cartesian spatial reference system (SRS) and produced an error when invoked with geometry arguments that specified a geographic SRS. ST_Area() now supports geometry arguments having a geographic SRS and returns the geodetic area in square meters.
因此,如果您将数据库更改为MYSQL> 8.0.13您可以使用以下查询计算多边形面积:
SELECT ST_Area(ST_PolyFromText('POLYGON((50.4668 -6.90665,50.4668 -6.90665))',4326));
(编辑:李大同)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|