MySQL Spatial 中是否实现了质心法?

发布于 2024-08-22 09:09:11 字数 57 浏览 2 评论 0原文

简单的问题,我想知道质心方法是否在 MySQL 空间扩展中实现。我查看了文档,但无法找到明确的答案。

Simple question, I'm wondering if the centroid method is implemented in the MySQL spatial extensions. I've looked at the documentation but wasn't able to find a definitive answer.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

装纯掩盖桑 2024-08-29 09:09:11

一般:是

多多边形:否

OpenGIS 规范还定义了
MySQL 中的以下函数
未实现:

质心(mpoly)

返回数学质心
MultiPolygon 值 mpoly 作为
观点。不保证结果
在多多边形上。

http://dev.mysql .com/doc/refman/5.1/en/geometry-property-functions.html#function_centroid

您可以使用 获取多重多边形内每个多边形的质心,尽管 MySQL 手册中没有记录这几何函数。例如,

select astext(centroid(geometryn(geomfromtext('MultiPolygon(((0 0,0 3,3 3,3 0,0 0)),((10 10,10 20,20 20,20 10,10 10)))'),2)));

返回

POINT(15 15)

MultiPolygon 内第二个多边形的质心。无论如何,对于 MultiPolygon 来说,拥有质心可能没有多大意义。

In general: Yes

MultiPolygon: No

The OpenGIS specification also defines
the following functions, which MySQL
does not implement:

Centroid(mpoly)

Returns the mathematical centroid for
the MultiPolygon value mpoly as a
Point. The result is not guaranteed to
be on the MultiPolygon.

http://dev.mysql.com/doc/refman/5.1/en/geometry-property-functions.html#function_centroid

You can get the centroid of each polygon, within a multipolygon, though this is not documented in the MySQL manual, by using the geometryn function. For exmaple,

select astext(centroid(geometryn(geomfromtext('MultiPolygon(((0 0,0 3,3 3,3 0,0 0)),((10 10,10 20,20 20,20 10,10 10)))'),2)));

returns

POINT(15 15)

which is the centroid of the 2nd polygon within the MultiPolygon. It probably doesn't make much sense for a MultiPolygon to have a centroid, anyway.

山田美奈子 2024-08-29 09:09:11

是的,您可以从MySQL - 多边形属性函数。查看页面下方的第一条用户评论。那里说:

不仅仅是这些可用的功能。我认为这不是
文档中足够清楚。例如,多多边形“质心”
函数也适用于多边形。

例子:

mysql> SET @poly = 'Polygon((0 0,0 3,3 3,3 0,0 0))';
mysql> select astext( Centroid(PolygonFromText(@poly)));

Yes, you can read it from the MySQL - Polygon Property Functions. Look below the page for the first user comment. It says there:

there are more than just these functions available. I think this not
clear enough in the docs. for example, the MultiPolygon 'Centroid'
function works for Polygons as well.

Example:

mysql> SET @poly = 'Polygon((0 0,0 3,3 3,3 0,0 0))';
mysql> select astext( Centroid(PolygonFromText(@poly)));
决绝 2024-08-29 09:09:11

从 Mysql 8 开始,质心已经不存在了。

获取多边形|m多边形中心的正确解决方案是st_centroid()方法。

这是一个示例:

select st_astext(ST_Centroid(st_geomfromtext('MultiPolygon(((0 0,0 3,3 3,3 0,0 0)),((10 10,10 20,20 20,20 10,10 10)))'))) as center_point;

参考Mysql st_centroid()方法

As of Mysql 8 centroid is not there anymore.

The proper solution to get the center of the polygon|m-polygon is st_centroid() method.

Here is an example:

select st_astext(ST_Centroid(st_geomfromtext('MultiPolygon(((0 0,0 3,3 3,3 0,0 0)),((10 10,10 20,20 20,20 10,10 10)))'))) as center_point;

The reference Mysql st_centroid() method

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文