Point函数
参考地址:http://blog.youkuaiyun.com/ahg1001/article/details/6749506
他写的太多了,我挑了一些有用的出来
Point由X和Y坐标构成,可使用下述函数获得它们:
X(p)
-
以双精度数值返回点p的X坐标值。
mysql> <span class="userinput" style="font-weight: bold;">SELECT X(GeomFromText('Point(56.7 53.34)'));</span> +--------------------------------------+ | X(GeomFromText('Point(56.7 53.34)')) | +--------------------------------------+ | 56.7 | +--------------------------------------+
<span style="font-family: Arial; background-color: rgb(255, 255, 255);">Y(</span><span class="replaceable" style="font-family: Arial; font-style: italic;">p</span><span style="font-family: Arial; background-color: rgb(255, 255, 255);">) </span>
-
以双精度数值返回点p的Y坐标值。
mysql> <span class="userinput" style="font-weight: bold;">SELECT Y(GeomFromText('Point(56.7 53.34)'));</span> +--------------------------------------+ | Y(GeomFromText('Point(56.7 53.34)')) | +--------------------------------------+ | 53.34 | +--------------------------------------+
</pre></li></ul></div></div><div class="section" style="color:rgb(51,51,51); font-family:Arial; font-size:14px"><p></p><pre code_snippet_id="1900577" snippet_file_name="blog_20160926_5_3610925" class="programlisting" name="code" style="color: rgb(51, 51, 51); font-size: 14px; white-space: pre-wrap; word-wrap: break-word;"><span style="font-family: Arial; background-color: rgb(255, 255, 255);"> LineString函数</span>
LineString由Point值组成。你可以提取LineString的特定点,计数它所包含的点数,或获取其长度。EndPoint(ls)
-
返回LineString值1s的最后一个点的Point。
mysql> <span class="userinput" style="font-weight: bold;">SET @ls = 'LineString(1 1,2 2,3 3)';</span> mysql> <span class="userinput" style="font-weight: bold;">SELECT AsText(EndPoint(GeomFromText(@ls)));</span> +-------------------------------------+ | AsText(EndPoint(GeomFromText(@ls))) | +-------------------------------------+ | POINT(3 3) | +-------------------------------------+
<span style="font-family: Arial; background-color: rgb(255, 255, 255);">GLength(</span><span class="replaceable" style="font-family: Arial; font-style: italic;">ls</span><span style="font-family: Arial; background-color: rgb(255, 255, 255);">)</span>
-
以双精度数值返回LineString值1s在相关的空间参考系中的长度。
mysql> <span class="userinput" style="font-weight: bold;">SET @ls = 'LineString(1 1,2 2,3 3)';</span> mysql> <span class="userinput" style="font-weight: bold;">SELECT GLength(GeomFromText(@ls));</span> +----------------------------+ | GLength(GeomFromText(@ls)) | +----------------------------+ | 2.8284271247462 | +----------------------------+
<span style="font-family: Arial; background-color: rgb(255, 255, 255);">NumPoints(</span><span class="replaceable" style="font-family: Arial; font-style: italic;">ls</span><span style="font-family: Arial; background-color: rgb(255, 255, 255);">)</span>
-
返回LineString值1s中的点数。
mysql> <span class="userinput" style="font-weight: bold;">SET @ls = 'LineString(1 1,2 2,3 3)';</span> mysql> <span class="userinput" style="font-weight: bold;">SELECT NumPoints(GeomFromText(@ls));</span> +------------------------------+ | NumPoints(GeomFromText(@ls)) | +------------------------------+ | 3 | +------------------------------+
<span style="font-family: Arial; background-color: rgb(255, 255, 255);">PointN(</span><span class="replaceable" style="font-family: Arial; font-style: italic;">ls</span><span style="font-family: Arial; background-color: rgb(255, 255, 255);">,</span><span class="replaceable" style="font-family: Arial; font-style: italic;">n</span><span style="font-family: Arial; background-color: rgb(255, 255, 255);">)</span>
-
返回LineString值1s中的第n个点。点编号从1开始。
mysql> <span class="userinput" style="font-weight: bold;">SET @ls = 'LineString(1 1,2 2,3 3)';</span> mysql> <span class="userinput" style="font-weight: bold;">SELECT AsText(PointN(GeomFromText(@ls),2));</span> +-------------------------------------+ | AsText(PointN(GeomFromText(@ls),2)) | +-------------------------------------+ | POINT(2 2) | +-------------------------------------+
<span style="font-family: Arial; background-color: rgb(255, 255, 255);">StartPoint(</span><span class="replaceable" style="font-family: Arial; font-style: italic;">ls</span><span style="font-family: Arial; background-color: rgb(255, 255, 255);">)</span>
-
返回LineString值1s的第一个点的Point。
mysql> <span class="userinput" style="font-weight: bold;">SET @ls = 'LineString(1 1,2 2,3 3)';</span> mysql> <span class="userinput" style="font-weight: bold;">SELECT AsText(StartPoint(GeomFromText(@ls)));</span> +---------------------------------------+ | AsText(StartPoint(GeomFromText(@ls))) | +---------------------------------------+ | POINT(1 1) | +---------------------------------------+
-
</pre></li></ul></div></div><div class="section" style="color:rgb(51,51,51); font-family:Arial; font-size:14px"><div class="titlepage"><h4 class="title" style="margin:0px; padding:0px">Polygon函数</h4><h4 class="title" style="margin:0px; padding:0px"><span style="white-space:pre"></span>Area(<span class="replaceable" style="font-style:italic">poly</span>)</h4></div><div class="itemizedlist"><ul type="disc"><li><p>以双精度数值形式返回Polygon值<em>poly</em>的面积,根据在其空间参考系中的测量值。</p><pre code_snippet_id="1900577" snippet_file_name="blog_20160926_16_8617578" class="programlisting" name="code" style="white-space: pre-wrap; word-wrap: break-word;">mysql> <span class="userinput" style="font-weight: bold;">SET @poly = 'Polygon((0 0,0 3,3 0,0 0),(1 1,1 2,2 1,1 1))';</span> mysql> <span class="userinput" style="font-weight: bold;">SELECT Area(GeomFromText(@poly));</span> +---------------------------+ | Area(GeomFromText(@poly)) | +---------------------------+ | 4 | +---------------------------+
<span style="font-family: Arial; background-color: rgb(255, 255, 255);">ExteriorRing(</span><span class="replaceable" style="font-family: Arial; font-style: italic;">poly</span><span style="font-family: Arial; background-color: rgb(255, 255, 255);">)</span>
-
以LineString形式返回Polygon值poly的外环。
mysql> <span class="userinput" style="font-weight: bold;">SET @poly =</span> -> <span class="userinput" style="font-weight: bold;">'Polygon((0 0,0 3,3 3,3 0,0 0),(1 1,1 2,2 2,2 1,1 1))';</span> mysql> <span class="userinput" style="font-weight: bold;">SELECT AsText(ExteriorRing(GeomFromText(@poly)));</span> +-------------------------------------------+ | AsText(ExteriorRing(GeomFromText(@poly))) | +-------------------------------------------+ | LINESTRING(0 0,0 3,3 3,3 0,0 0) | +-------------------------------------------+
<span style="font-family: Arial; background-color: rgb(255, 255, 255);">InteriorRingN(</span><span class="replaceable" style="font-family: Arial; font-style: italic;">poly</span><span style="font-family: Arial; background-color: rgb(255, 255, 255);">,</span><span class="replaceable" style="font-family: Arial; font-style: italic;">n</span><span style="font-family: Arial; background-color: rgb(255, 255, 255);">)</span>
-
以LineString形式返回Polygon值poly的第n个内环。环编号从1开始。
mysql> <span class="userinput" style="font-weight: bold;">SET @poly =</span> -> <span class="userinput" style="font-weight: bold;">'Polygon((0 0,0 3,3 3,3 0,0 0),(1 1,1 2,2 2,2 1,1 1))';</span> mysql> <span class="userinput" style="font-weight: bold;">SELECT AsText(InteriorRingN(GeomFromText(@poly),1));</span> +----------------------------------------------+ | AsText(InteriorRingN(GeomFromText(@poly),1)) | +----------------------------------------------+ | LINESTRING(1 1,1 2,2 2,2 1,1 1) | +----------------------------------------------+
<span style="font-family: Arial; background-color: rgb(255, 255, 255);">NumInteriorRings(</span><span class="replaceable" style="font-family: Arial; font-style: italic;">poly</span><span style="font-family: Arial; background-color: rgb(255, 255, 255);">)</span>
-
返回Polygon值poly的内环的数目。
mysql> <span class="userinput" style="font-weight: bold;">SET @poly =</span> -> <span class="userinput" style="font-weight: bold;">'Polygon((0 0,0 3,3 3,3 0,0 0),(1 1,1 2,2 2,2 1,1 1))';</span> mysql> <span class="userinput" style="font-weight: bold;">SELECT NumInteriorRings(GeomFromText(@poly));</span> +---------------------------------------+ | NumInteriorRings(GeomFromText(@poly)) | +---------------------------------------+ | 1 | +---------------------------------------+
MultiPolygon函数
Area(mpoly)
-
以双精度数值形式返回MultiPolygon值mpoly的面积,根据在其空间参考系中的测量结果。
mysql> <span class="userinput" style="font-weight: bold;">SET @mpoly =</span> -> <span class="userinput" style="font-weight: bold;">'MultiPolygon(((0 0,0 3,3 3,3 0,0 0),(1 1,1 2,2 2,2 1,1 1)))';</span> mysql> <span class="userinput" style="font-weight: bold;">SELECT Area(GeomFromText(@mpoly));</span> +----------------------------+ | Area(GeomFromText(@mpoly)) | +----------------------------+ | 8 | +----------------------------+
<span style="font-family: Arial; background-color: rgb(255, 255, 255);">GeometryCollection函数</span>
<span style="font-family: Arial; background-color: rgb(255, 255, 255);">GeometryN(</span><span class="replaceable" style="font-family: Arial; font-style: italic;">gc</span><span style="font-family: Arial; background-color: rgb(255, 255, 255);">,</span><span class="replaceable" style="font-family: Arial; font-style: italic;">n</span><span style="font-family: Arial; background-color: rgb(255, 255, 255);">)</span>
-
返回GeometryCollection值gc中第n个几何对象。几何对象的编号从1开始。
mysql> <span class="userinput" style="font-weight: bold;">SET @gc = 'GeometryCollection(Point(1 1),LineString(2 2, 3 3))';</span> mysql> <span class="userinput" style="font-weight: bold;">SELECT AsText(GeometryN(GeomFromText(@gc),1));</span> +----------------------------------------+ | AsText(GeometryN(GeomFromText(@gc),1)) | +----------------------------------------+ | POINT(1 1) | +----------------------------------------+
<span style="font-family: Arial; background-color: rgb(255, 255, 255);">NumGeometries(</span><span class="replaceable" style="font-family: Arial; font-style: italic;">gc</span><span style="font-family: Arial; background-color: rgb(255, 255, 255);">)</span>
-
返回GeometryCollection值gc中几何对象的数目。
mysql> <span class="userinput" style="font-weight: bold;">SET @gc = 'GeometryCollection(Point(1 1),LineString(2 2, 3 3))';</span> mysql> <span class="userinput" style="font-weight: bold;">SELECT NumGeometries(GeomFromText(@gc));</span> +----------------------------------+ | NumGeometries(GeomFromText(@gc)) | +----------------------------------+ | 2 | +----------------------------------+