mysql> SET @poly ='Polygon((0 0,0 3,3 0,0 0),(1 1,1 2,2 1,1 1))';mysql> SELECT ST_Area(ST_GeomFromText(@poly));+---------------------------------+| ST_Area(ST_GeomFromText(@poly)) |+---------------------------------+| 4 |+---------------------------------+mysql> SET @mpoly ='MultiPolygon(((0 0,0 3,3 3,3 0,0 0),(1 1,1 2,2 2,2 1,1 1)))';mysql> SELECT ST_Area(ST_GeomFromText(@mpoly));+----------------------------------+| ST_Area(ST_GeomFromText(@mpoly)) |+----------------------------------+| 8 |+----------------------------------+
mysql> SET @poly =ST_GeomFromText('POLYGON((0 0,10 0,10 10,0 10,0 0),(5 5,7 5,7 7,5 7,5 5))');mysql> SELECT ST_GeometryType(@poly),ST_AsText(ST_Centroid(@poly));+------------------------+--------------------------------------------+| ST_GeometryType(@poly) | ST_AsText(ST_Centroid(@poly)) |+------------------------+--------------------------------------------+| POLYGON | POINT(4.958333333333333 4.958333333333333) |+------------------------+--------------------------------------------+
mysql> SET @poly ='Polygon((0 0,0 3,3 3,3 0,0 0),(1 1,1 2,2 2,2 1,1 1))';mysql> SELECT ST_AsText(ST_ExteriorRing(ST_GeomFromText(@poly)));+----------------------------------------------------+| ST_AsText(ST_ExteriorRing(ST_GeomFromText(@poly))) |+----------------------------------------------------+| LINESTRING(0 0,0 3,3 3,3 0,0 0) |+----------------------------------------------------+
mysql> SET @poly ='Polygon((0 0,0 3,3 3,3 0,0 0),(1 1,1 2,2 2,2 1,1 1))';mysql> SELECT ST_AsText(ST_InteriorRingN(ST_GeomFromText(@poly),1));+-------------------------------------------------------+| ST_AsText(ST_InteriorRingN(ST_GeomFromText(@poly),1)) |+-------------------------------------------------------+| LINESTRING(1 1,1 2,2 2,2 1,1 1) |+-------------------------------------------------------+
mysql> SET @poly ='Polygon((0 0,0 3,3 3,3 0,0 0),(1 1,1 2,2 2,2 1,1 1))';mysql> SELECT ST_NumInteriorRings(ST_GeomFromText(@poly));+---------------------------------------------+| ST_NumInteriorRings(ST_GeomFromText(@poly)) |+---------------------------------------------+| 1 |+---------------------------------------------+
文章转载自林员外聊编程,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




