例: GeoJSONFromGeom - Teradata Database - Teradata Vantage NewSQL Engine - GeoJSONFromGeom関数の使用方法を示す例。

Teradata Vantage™ JSONデータ型

Product
Teradata Database
Teradata Vantage NewSQL Engine
Release Number
16.20
Published
2019年3月
Language
日本語
Last Update
2019-10-29
dita:mapPath
ja-JP/bgi1512081870828.ditamap
dita:ditavalPath
ja-JP/bgi1512081870828.ditaval
dita:id
evi1472243742653
Product Category
Software
Teradata Vantage
これらの例は、以下のST_GeometryオブジェクトをGeoJSON標準準拠のJSON文書に変換する処理を示します。
  • Point ST_Geometryオブジェクトから、VARCHAR、CLOB、またはJSONのデータ型を持つJSON文書への変換。
  • 各種のST_Geometryオブジェクトから、VARCHAR(2000) CHARACTER SET LATINのデータ型を持つJSON文書への変換。

例: VARCHAR型を持つJSON文書への変換

SELECT (GeoJSONFromGeom(new ST_Geometry('Point(45.12345 85.67891)'))
RETURNS VARCHAR(2000) CHARACTER SET LATIN);

結果:

GeoJSONFromGeom( NEW ST_GEOMETRY('Point(45.12345 85.67891)'))
-------------------------------------------------------------
{ "type": "Point", "coordinates": [ 45.12345, 85.67891 ] }

例: CLOB型を持つJSON文書への変換

SELECT (GeoJSONFromGeom(new ST_Geometry('Point(45.12345 85.67891)'))
RETURNS CLOB CHARACTER SET UNICODE);

結果:

GeoJSONFromGeom( NEW ST_GEOMETRY('Point(45.12345 85.67891)'))
-------------------------------------------------------------
{ "type": "Point", "coordinates": [ 45.12345, 85.67891 ] }

例: JSON型を持つJSON文書への変換

SELECT (GeoJSONFromGeom(new ST_Geometry('Point(45.12345 85.67891)'))
RETURNS JSON(2000) CHARACTER SET LATIN);

結果:

GeoJSONFromGeom( NEW ST_GEOMETRY('Point(45.12345 85.67891)'))
-------------------------------------------------------------
{ "type": "Point", "coordinates": [ 45.12345, 85.67891 ] }

例: LineString ST_Geometryオブジェクトの変換

SELECT (GeoJSONFromGeom (new ST_Geometry('LineString(10 20, 50 80, 200 50)') )
RETURNS VARCHAR(2000) CHARACTER SET LATIN);

結果:

GeoJSONFromGeom( NEW ST_GEOMETRY('LineString(10 20, 50 80, 200 50)'))
---------------------------------------------------------------------
{ "type": "LineString", "coordinates": [ [ 10.0, 20.0 ], [ 50.0, 80.0 ],
[ 200.0, 50.0 ] ] }

例: Polygon ST_Geometryオブジェクトの変換

SELECT (GeoJSONFromGeom (new ST_Geometry('Polygon((0 0, 0 10, 10 10, 10 0, 0 0))',
4326) )
RETURNS VARCHAR(2000) CHARACTER SET LATIN);

結果:

GeoJSONFromGeom( NEW ST_GEOMETRY('Polygon((0 0, 0 10, 10 10, 10 0, 0 0))', 4326))
---------------------------------------------------------------------------------
{ "type": "Polygon", "coordinates": [ [ [ 0.0, 0.0 ], [ 0.0, 10.0 ], [ 10.0, 10.0 ],
[ 10.0, 0.0 ], [ 0.0, 0.0 ] ] ] }

例: MultiPoint ST_Geometryオブジェクトの変換

SELECT (GeoJSONFromGeom (new ST_Geometry('MultiPoint(10 20, 50 80, 200 50)',
4326) )
RETURNS VARCHAR(2000) CHARACTER SET LATIN);

結果:

GeoJSONFromGeom( NEW ST_GEOMETRY('MultiPoint(10 20, 50 80, 200 50)', 4326))
---------------------------------------------------------------------------
{ "type": "MultiPoint", "coordinates": [ [ 10.0, 20.0 ], [ 50.0, 80.0 ],
[ 200.0, 50.0 ] ] }

例: MultiLineString ST_Geometryオブジェクトの変換

SELECT (GeoJSONFromGeom (new ST_Geometry(
'MultiLineString((10 20, 50 80, 200 50), (0 100, 10 220, 20 240))', 4326) )
RETURNS VARCHAR(2000) CHARACTER SET LATIN);

結果:

GeoJSONFromGeom( NEW ST_GEOMETRY('MultiLineString((10 20, 50 80, 200 50),
(0 100, 10 220, 20 240))', 4326))
-------------------------------------------------------------------------
{ "type": "MultiLineString", "coordinates": [ [ [ 10.0, 20.0 ], [ 50.0, 80.0 ], 
[ 200.0, 50.0 ] ], [ [ 0.0, 100.0 ], [ 10.0, 220.0 ], [ 20.0, 240.0 ] ] ] }

例: MultiPolygon ST_Geometryオブジェクトの変換

SELECT (GeoJSONFromGeom (new ST_Geometry(
'MultiPolygon(((0 0, 0 10, 10 10, 10 0, 0 0)), ((0 50, 0 100, 100 100, 100 50, 0 50)))',
4326) )
RETURNS VARCHAR(2000) CHARACTER SET LATIN);

結果:

GeoJSONFromGeom( NEW ST_GEOMETRY('MultiPolygon(((0 0, 0 10, 10 10, 10 0, 0 0)),
((0 50, 0 100, 100 100, 100 50, 0 50)))', 4326))
-------------------------------------------------------------------------------
{ "type": "MultiPolygon", "coordinates": [ [ [ [ 0.0, 0.0 ], [ 0.0, 10.0 ], 
[ 10.0, 10.0 ], [ 10.0, 0.0 ], [ 0.0, 0.0 ] ] ], [ [ [ 0.0, 50.0 ], [ 0.0, 100.0 ],
[ 100.0, 100.0 ], [ 100.0, 50.0 ], [ 0.0, 50.0 ] ] ] ] }

例: GeometryCollection ST_Geometryオブジェクトの変換

SELECT (GeoJSONFromGeom (new ST_Geometry(
'GeometryCollection(point(10 20), linestring(50 80, 200 50))', 4326) )
RETURNS VARCHAR(2000) CHARACTER SET LATIN);

結果:

GeoJSONFromGeom( NEW ST_GEOMETRY('GeometryCollection(point(10 20),
linestring(50 80, 200 50))', 4326))
------------------------------------------------------------------
{ "type": "GeometryCollection", "geometries": [ { "type": "Point", "coordinates":
[ 10.0, 20.0 ] }, { "type": "LineString", "coordinates": [ [ 50.0, 80.0 ],
[ 200.0, 50.0 ] ] } ] }