ST_ASGEOJSON
GEOMETRY または GEOGRAPHY オブジェクトを GeoJSON 表現に変換します。
構文
ST_ASGEOJSON(<geometry_or_geography>)
引数
戻り値の型
Variant。
例
GEOMETRY の例
SELECT
ST_ASGEOJSON(
ST_GEOMETRYFROMWKT(
'SRID=4326;LINESTRING(400000 6000000, 401000 6010000)'
)
) AS pipeline_geojson;
┌─────────────────────────────────────────────────────────────────────────┐
│ pipeline_geojson │
├─────────────────────────────────────────────────────────────────────────┤
│ {"coordinates":[[400000,6000000],[401000,6010000]],"type":"LineString"} │
└─────────────────────────────────────────────────────────────────────────┘
GEOGRAPHY の例
SELECT
ST_ASGEOJSON(
ST_GEOGFROMWKT(
'SRID=4326;POINT(-122.35 37.55)'
)
) AS pipeline_geojson;
╭────────────────────────────────────────────────╮
│ pipeline_geojson │
├────────────────────────────────────────────────┤
│ {"coordinates":[-122.35,37.55],"type":"Point"} │
╰────────────────────────────────────────────────╯