メインコンテンツまでスキップ
バージョン: 4.x

ST_GEOMETRYFROMTEXT

説明

WKT(Well Known Text)を対応するメモリジオメトリに変換します

エイリアス

  • ST_GEOMFROMTEXT

構文

ST_GEOMETRYFROMTEXT( <wkt>)

パラメータ

パラメータ説明
<wkt>グラフのメモリ形式

サポートされている WKT フォーマット

  • POINT - 空間内の単一点
  • LINESTRING - 接続された線分のシーケンス
  • POLYGON - 1つ以上のリングで定義される閉じた領域で、最低3つの異なる点と閉じた端点が必要
  • MULTIPOLYGON - ポリゴンのコレクションで、multipolygon内のポリゴンは離散点のみを共有可能
Note

Apache Doris 3.0.6 以降、MULTIPOLYGON フォーマットの解析をサポート

戻り値

WKB の対応する幾何学的ストレージ形式

入力 WKT フォーマットが仕様に準拠していない場合、または入力が NULL の場合は NULL を返します。

-- POINT example
SELECT ST_AsText(ST_GeometryFromText("POINT (1 1)"));
+-----------------------------------------------+
| ST_AsText(ST_GeometryFromText("POINT (1 1)")) |
+-----------------------------------------------+
| POINT (1 1) |
+-----------------------------------------------+
-- POINT illegal example(too many points)
SELECT ST_AsText(ST_GeometryFromText("POINT (1 1, 2 2)"));
+----------------------------------------------------+
| ST_AsText(ST_GeometryFromText("POINT (1 1, 2 2)")) |
+----------------------------------------------------+
| NULL |
+----------------------------------------------------+
-- LINESTRING example
SELECT ST_AsText(ST_GeometryFromText("LINESTRING (1 1, 2 2)"));
+---------------------------------------------------------+
| st_astext(st_geometryfromtext('LINESTRING (1 1, 2 2)')) |
+---------------------------------------------------------+
| LINESTRING (1 1, 2 2) |
+---------------------------------------------------------+
-- LINESTRING illegal example(too few verteices)
SELECT ST_AsText(ST_GeometryFromText("LINESTRING (1 1)"));
+----------------------------------------------------+
| ST_AsText(ST_GeometryFromText("LINESTRING (1 1)")) |
+----------------------------------------------------+
| NULL |
+----------------------------------------------------+
-- POLYGON example
SELECT ST_AsText(ST_GeometryFromText("POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))"));
+-----------------------------------------------------------------------+
| ST_AsText(ST_GeometryFromText("POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))")) |
+-----------------------------------------------------------------------+
| POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0)) |
+-----------------------------------------------------------------------+
-- POLYGON illegal example(not closed end to end)
SELECT ST_AsText(ST_GeometryFromText("POLYGON ((0 0, 1 0, 1 1, 0 1))"));
+------------------------------------------------------------------+
| ST_AsText(ST_GeometryFromText("POLYGON ((0 0, 1 0, 1 1, 0 1))")) |
+------------------------------------------------------------------+
| NULL |
+------------------------------------------------------------------+
-- POLYGON illegal example(too few verteices)
SELECT ST_AsText(ST_GeometryFromText("POLYGON ((0 0, 1 0, 0 0))"));
+-------------------------------------------------------------+
| ST_AsText(ST_GeometryFromText("POLYGON ((0 0, 1 0, 0 0))")) |
+-------------------------------------------------------------+
| NULL |
+-------------------------------------------------------------+
-- MULTIPOLYGON example
SELECT ST_AsText(ST_GeometryFromText("MULTIPOLYGON (((0 0, 1 0, 1 1, 0 1, 0 0)), ((2 2, 3 2, 3 3, 2 3, 2 2)))"));
+-----------------------------------------------------------------------------------------------------------+
| ST_AsText(ST_GeometryFromText("MULTIPOLYGON (((0 0, 1 0, 1 1, 0 1, 0 0)), ((2 2, 3 2, 3 3, 2 3, 2 2)))")) |
+-----------------------------------------------------------------------------------------------------------+
| MULTIPOLYGON (((0 0, 1 0, 1 1, 0 1, 0 0)), ((2 2, 3 2, 3 3, 2 3, 2 2))) |
+-----------------------------------------------------------------------------------------------------------+
-- MULTIPOLYGON example (polygons in multipolygon only share discrete points.)
SELECT ST_AsText(ST_GeometryFromText("MULTIPOLYGON (((0 0, 10 0, 10 10, 0 10, 0 0), (4 4, 6 4, 6 6, 4 6, 4 4)), ((4 5, 5 4, 6 5, 5 6, 4 5)))"));
+------------------------------------------------------------------------------------------------------------------------------------------+
| ST_AsText(ST_GeometryFromText("MULTIPOLYGON (((0 0, 10 0, 10 10, 0 10, 0 0), (4 4, 6 4, 6 6, 4 6, 4 4)), ((4 5, 5 4, 6 5, 5 6, 4 5)))")) |
+------------------------------------------------------------------------------------------------------------------------------------------+
| MULTIPOLYGON (((0 0, 10 0, 10 10, 0 10, 0 0), (4 4, 6 4, 6 6, 4 6, 4 4)), ((4 5, 5 4, 6 5, 5 6, 4 5))) |
+------------------------------------------------------------------------------------------------------------------------------------------+
-- MULTIPOLYGON illegal example(overlap exists)
SELECT ST_AsText(ST_GeometryFromText("MULTIPOLYGON (((0 0, 10 0, 10 10, 0 10, 0 0)), ((10 0, 20 0, 20 10, 10 10, 10 0)))"));
+----------------------------------------------------------------------------------------------------------------------+
| ST_AsText(ST_GeometryFromText("MULTIPOLYGON (((0 0, 10 0, 10 10, 0 10, 0 0)), ((10 0, 20 0, 20 10, 10 10, 10 0)))")) |
+----------------------------------------------------------------------------------------------------------------------+
| NULL |
+----------------------------------------------------------------------------------------------------------------------+
-- input NULL
SELECT ST_AsText(ST_GeometryFromText(NULL));
+--------------------------------------+
| ST_AsText(ST_GeometryFromText(NULL)) |
+--------------------------------------+
| NULL |
+--------------------------------------+