1--
2-- GML
3--
4
5-- Empty Geometry
6SELECT 'gml_empty_geom', ST_AsGML(ST_GeomFromEWKT(NULL));
7
8-- Precision
9SELECT 'gml_precision_01', ST_AsGML(ST_GeomFromEWKT('SRID=4326;POINT(1.1111111 1.1111111)'), -2);
10SELECT 'gml_precision_02', ST_AsGML(ST_GeomFromEWKT('SRID=4326;POINT(1.1111111 1.1111111)'), 19);
11
12-- Version
13SELECT 'gml_version_01', ST_AsGML(2, ST_GeomFromEWKT('SRID=4326;POINT(1 1)'));
14SELECT 'gml_version_02', ST_AsGML(3, ST_GeomFromEWKT('SRID=4326;POINT(1 1)'));
15SELECT 'gml_version_03', ST_AsGML(21, ST_GeomFromEWKT('SRID=4326;POINT(1 1)'));
16SELECT 'gml_version_04', ST_AsGML(-4, ST_GeomFromEWKT('SRID=4326;POINT(1 1)'));
17
18-- Option
19SELECT 'gml_option_01', ST_AsGML(2, ST_GeomFromEWKT('SRID=4326;POINT(1 2)'), 0, 0);
20SELECT 'gml_option_02', ST_AsGML(3, ST_GeomFromEWKT('SRID=4326;POINT(1 2)'), 0, 1);
21SELECT 'gml_option_03', ST_AsGML(3, ST_GeomFromEWKT('SRID=4326;POINT(1 2)'), 0, 2);
22SELECT 'gml_option_04', ST_AsGML(3, ST_GeomFromEWKT('SRID=4326;POINT(1 2)'), 0, 4);
23SELECT 'gml_option_05', ST_AsGML(3, ST_GeomFromEWKT('SRID=4326;POINT(1 2)'), 0, 16);
24SELECT 'gml_option_06', ST_AsGML(2, ST_GeomFromEWKT('SRID=4326;LINESTRING(1 2, 3 4)'), 0, 32);
25SELECT 'gml_option_07', ST_AsGML(3, ST_GeomFromEWKT('SRID=4326;LINESTRING(1 2, 3 4)'), 0, 32);
26
27-- Deegree data
28SELECT 'gml_deegree_01', ST_AsGML(3, ST_GeomFromEWKT('SRID=4326;POINT(1 2)'), 0, 0);
29SELECT 'gml_deegree_02', ST_AsGML(2, ST_GeomFromEWKT('SRID=4326;POINT(1 2)'), 0, 16);
30SELECT 'gml_deegree_03', ST_AsGML(3, ST_GeomFromEWKT('SRID=4326;POINT(1 2)'), 0, 16);
31SELECT 'gml_deegree_04', ST_AsGML(3, ST_GeomFromEWKT('SRID=4326;POINT(1 2 3)'), 0, 0);
32SELECT 'gml_deegree_05', ST_AsGML(2, ST_GeomFromEWKT('SRID=4326;POINT(1 2 3)'), 0, 16);
33SELECT 'gml_deegree_06', ST_AsGML(3, ST_GeomFromEWKT('SRID=4326;POINT(1 2 3)'), 0, 16);
34
35-- Prefix
36SELECT 'gml_prefix_01', ST_AsGML(2, ST_GeomFromEWKT('SRID=4326;POINT(1 2)'), 0, 16, '');
37SELECT 'gml_prefix_02', ST_AsGML(3, ST_GeomFromEWKT('SRID=4326;POINT(1 2)'), 0, 16, '');
38SELECT 'gml_prefix_03', ST_AsGML(2, ST_GeomFromEWKT('SRID=4326;POINT(1 2)'), 0, 16, 'foo');
39SELECT 'gml_prefix_04', ST_AsGML(3, ST_GeomFromEWKT('SRID=4326;POINT(1 2)'), 0, 16, 'foo');
40
41-- LineString
42SELECT 'gml_shortline_01', ST_AsGML(3, ST_GeomFromEWKT('LINESTRING(1 2, 3 4)'), 0, 6, '');
43SELECT 'gml_shortline_02', ST_AsGML(3, ST_GeomFromEWKT('LINESTRING(1 2, 3 4)'), 0, 2, '');
44SELECT 'gml_shortline_03', ST_AsGML(3, ST_GeomFromEWKT('MULTILINESTRING((1 2, 3 4), (5 6, 7 8))'), 0, 6, '');
45SELECT 'gml_shortline_04', ST_AsGML(3, ST_GeomFromEWKT('MULTILINESTRING((1 2, 3 4), (5 6, 7 8))'), 0, 2, '');
46
47-- CIRCULARSTRING / COMPOUNDCURVE / CURVEPOLYGON / MULTISURFACE / MULTICURVE
48SELECT 'gml_out_curve_01', ST_AsGML(3, ST_GeomFromEWKT('CIRCULARSTRING(-2 0,0 2,2 0,0 2,2 4)'));
49SELECT 'gml_out_curve_02', ST_ASGML(3, ST_GeomFromEWKT('COMPOUNDCURVE(CIRCULARSTRING(0 0,1 1,1 0),(1 0,0 1))'));
50SELECT 'gml_out_curve_03', ST_AsGML(3, ST_GeomFromEWKT('CURVEPOLYGON(CIRCULARSTRING(-2 0,-1 -1,0 0,1 -1,2 0,0 2,-2 0),(-1 0,0 0.5,1 0,0 1,-1 0))'));
51SELECT 'gml_out_curve_04', ST_AsGML(3, ST_GeomFromEWKT('MULTICURVE((5 5,3 5,3 3,0 3),CIRCULARSTRING(0 0,2 1,2 2))'));
52SELECT 'gml_out_curve_05', ST_AsGML(3, ST_GeomFromEWKT('MULTISURFACE(CURVEPOLYGON(CIRCULARSTRING(-2 0,-1 -1,0 0,1 -1,2 0,0 2,-2 0),(-1 0,0 0.5,1 0,0 1,-1 0)),((7 8,10 10,6 14,4 11,7 8)))'));
53
54--
55-- KML
56--
57
58-- SRID
59SELECT 'kml_srid_01', ST_AsKML(ST_GeomFromEWKT('SRID=10;POINT(0 1)'));
60SELECT 'kml_srid_02', ST_AsKML(ST_GeomFromEWKT('POINT(0 1)'));
61
62-- Empty Geometry
63SELECT 'kml_empty_geom', ST_AsKML(ST_GeomFromEWKT(NULL));
64
65-- Precision
66SELECT 'kml_precision_01', ST_AsKML(ST_GeomFromEWKT('SRID=4326;POINT(1.1111111 1.1111111)'), -2);
67SELECT 'kml_precision_02', ST_AsKML(ST_GeomFromEWKT('SRID=4326;POINT(1.1111111 1.1111111)'), 19);
68
69-- Prefix
70SELECT 'kml_prefix_01', ST_AsKML(ST_GeomFromEWKT('SRID=4326;POINT(1 2)'), 0, '');
71SELECT 'kml_prefix_02', ST_AsKML(ST_GeomFromEWKT('SRID=4326;POINT(1 2)'), 0, 'kml');
72
73-- Projected
74-- National Astronomical Observatory of Colombia - Bogota, Colombia (Placemark)
75SELECT 'kml_projection_01', ST_AsKML(ST_GeomFromEWKT('SRID=3116;POINT(1000000 1000000)'), 3);
76
77--
78-- Encoded Polyline
79--
80SELECT 'encoded_polyline_01', ST_AsEncodedPolyline(ST_GeomFromEWKT('SRID=4326;LINESTRING(-120.2 38.5,-120.95 40.7,-126.453 43.252)'));
81SELECT 'encoded_polyline_02', ST_AsEncodedPolyline(ST_GeomFromEWKT('SRID=4326;MULTIPOINT(-120.2 38.5,-120.95 40.7,-126.453 43.252)'));
82SELECT 'encoded_polyline_03', ST_AsEncodedPolyline(ST_GeomFromEWKT('LINESTRING(-120.2 38.5,-120.95 40.7,-126.453 43.252)'));
83SELECT 'encoded_polyline_04', ST_AsEncodedPolyline(ST_GeomFromEWKT('SRID=4326;LINESTRING(-120.234467 38.5,-120.95 40.7343495,-126.453 43.252)'), 6);
84
85--
86-- SVG
87--
88
89-- Empty Geometry
90SELECT 'svg_empty_geom', ST_AsSVG(ST_GeomFromEWKT(NULL));
91
92-- Option
93SELECT 'svg_option_01', ST_AsSVG(ST_GeomFromEWKT('LINESTRING(1 1, 4 4, 5 7)'), 0);
94SELECT 'svg_option_02', ST_AsSVG(ST_GeomFromEWKT('LINESTRING(1 1, 4 4, 5 7)'), 1);
95SELECT 'svg_option_03', ST_AsSVG(ST_GeomFromEWKT('LINESTRING(1 1, 4 4, 5 7)'), 0, 0);
96SELECT 'svg_option_04', ST_AsSVG(ST_GeomFromEWKT('LINESTRING(1 1, 4 4, 5 7)'), 1, 0);
97
98-- Precision
99SELECT 'svg_precision_01', ST_AsSVG(ST_GeomFromEWKT('POINT(1.1111111 1.1111111)'), 1, -2);
100SELECT 'svg_precision_02', ST_AsSVG(ST_GeomFromEWKT('POINT(1.1111111 1.1111111)'), 1, 19);
101
102--
103-- GeoJSON
104--
105
106-- Empty Geometry
107SELECT 'geojson_empty_geom', ST_AsGeoJSON(ST_GeomFromEWKT(NULL));
108
109-- Precision
110SELECT 'geojson_precision_01', ST_AsGeoJSON(ST_GeomFromEWKT('SRID=4326;POINT(1.1111111 1.1111111)'), -2);
111SELECT 'geojson_precision_02', ST_AsGeoJSON(ST_GeomFromEWKT('SRID=4326;POINT(1.1111111 1.1111111)'), 19);
112
113-- Version
114SELECT 'geojson_version_01', ST_AsGeoJSON(ST_GeomFromEWKT('SRID=4326;POINT(1 1)'));
115
116-- CRS
117SELECT 'geojson_crs_01', ST_AsGeoJSON(ST_GeomFromEWKT('SRID=4326;POINT(1 1)'), 0, 2);
118SELECT 'geojson_crs_02', ST_AsGeoJSON(ST_GeomFromEWKT('SRID=0;POINT(1 1)'), 0, 2);
119SELECT 'geojson_crs_03', ST_AsGeoJSON(ST_GeomFromEWKT('SRID=4326;POINT(1 1)'), 0, 4);
120SELECT 'geojson_crs_04', ST_AsGeoJSON(ST_GeomFromEWKT('SRID=0;POINT(1 1)'), 0, 4);
121SELECT 'geojson_crs_05', ST_AsGeoJSON(ST_GeomFromEWKT('SRID=1;POINT(1 1)'), 0, 2);
122SELECT 'geojson_crs_06', ST_AsGeoJSON(ST_GeomFromEWKT('SRID=1;POINT(1 1)'), 0, 4);
123SELECT 'geojson_crs_07', ST_AsGeoJSON(ST_GeomFromEWKT('SRID=3005;POINT(1 1)'));
124
125-- Bbox
126SELECT 'geojson_bbox_01', ST_AsGeoJSON(ST_GeomFromEWKT('LINESTRING(1 1, 2 2, 3 3, 4 4)'), 0);
127SELECT 'geojson_bbox_02', ST_AsGeoJSON(ST_GeomFromEWKT('LINESTRING(1 1, 2 2, 3 3, 4 4)'), 0, 1);
128SELECT 'geojson_bbox_03', ST_AsGeoJSON(ST_GeomFromEWKT('LINESTRING(1 1, 2 2, 3 3, 4 4)'), 0, 3);
129SELECT 'geojson_bbox_04', ST_AsGeoJSON(ST_GeomFromEWKT('LINESTRING(1 1, 2 2, 3 3, 4 4)'), 0, 5);
130
131-- CRS and Bbox
132SELECT 'geojson_options_01', ST_AsGeoJSON(ST_GeomFromEWKT('SRID=0;LINESTRING(1 1, 2 2, 3 3, 4 4)'), 0, 0);
133SELECT 'geojson_options_02', ST_AsGeoJSON(ST_GeomFromEWKT('SRID=4326;LINESTRING(1 1, 2 2, 3 3, 4 4)'), 0);
134SELECT 'geojson_options_03', ST_AsGeoJSON(ST_GeomFromEWKT('SRID=0;LINESTRING(1 1, 2 2, 3 3, 4 4)'), 0, 1);
135SELECT 'geojson_options_04', ST_AsGeoJSON(ST_GeomFromEWKT('SRID=4326;LINESTRING(1 1, 2 2, 3 3, 4 4)'), 0, 1);
136SELECT 'geojson_options_05', ST_AsGeoJSON(ST_GeomFromEWKT('SRID=0;LINESTRING(1 1, 2 2, 3 3, 4 4)'), 0, 2);
137SELECT 'geojson_options_06', ST_AsGeoJSON(ST_GeomFromEWKT('SRID=4326;LINESTRING(1 1, 2 2, 3 3, 4 4)'), 0, 2);
138SELECT 'geojson_options_07', ST_AsGeoJSON(ST_GeomFromEWKT('SRID=0;LINESTRING(1 1, 2 2, 3 3, 4 4)'), 0, 3);
139SELECT 'geojson_options_08', ST_AsGeoJSON(ST_GeomFromEWKT('SRID=4326;LINESTRING(1 1, 2 2, 3 3, 4 4)'), 0, 3);
140SELECT 'geojson_options_09', ST_AsGeoJSON(ST_GeomFromEWKT('SRID=0;LINESTRING(1 1, 2 2, 3 3, 4 4)'), 0, 4);
141SELECT 'geojson_options_10', ST_AsGeoJSON(ST_GeomFromEWKT('SRID=4326;LINESTRING(1 1, 2 2, 3 3, 4 4)'), 0, 4);
142SELECT 'geojson_options_11', ST_AsGeoJSON(ST_GeomFromEWKT('SRID=0;LINESTRING(1 1, 2 2, 3 3, 4 4)'), 0, 5);
143SELECT 'geojson_options_12', ST_AsGeoJSON(ST_GeomFromEWKT('SRID=4326;LINESTRING(1 1, 2 2, 3 3, 4 4)'), 0, 5);
144SELECT 'geojson_options_13', ST_AsGeoJSON(ST_GeomFromEWKT('SRID=0;LINESTRING(1 1, 2 2, 3 3, 4 4)'), 0, 6);
145SELECT 'geojson_options_14', ST_AsGeoJSON(ST_GeomFromEWKT('SRID=4326;LINESTRING(1 1, 2 2, 3 3, 4 4)'), 0, 6);
146SELECT 'geojson_options_15', ST_AsGeoJSON(ST_GeomFromEWKT('SRID=0;LINESTRING(1 1, 2 2, 3 3, 4 4)'), 0, 7);
147SELECT 'geojson_options_16', ST_AsGeoJSON(ST_GeomFromEWKT('SRID=4326;LINESTRING(1 1, 2 2, 3 3, 4 4)'), 0, 7);
148
149-- Out and in to PostgreSQL native geometric types
150WITH p AS ( SELECT '((0,0),(0,1),(1,1),(1,0),(0,0))'::text AS p )
151  SELECT 'pgcast_01', p = p::polygon::geometry::polygon::text FROM p;
152WITH p AS ( SELECT '[(0,0),(1,1)]'::text AS p )
153  SELECT 'pgcast_02', p = p::path::geometry::path::text FROM p;
154WITH p AS ( SELECT '(1,1)'::text AS p )
155  SELECT 'pgcast_03', p = p::point::geometry::point::text FROM p;
156SELECT 'pgcast_03','POLYGON EMPTY'::geometry::polygon IS NULL;
157SELECT 'pgcast_04','LINESTRING EMPTY'::geometry::path IS NULL;
158SELECT 'pgcast_05','POINT EMPTY'::geometry::point IS NULL;
159SELECT 'pgcast_06',ST_AsText('((0,0),(0,1),(1,1),(1,0))'::polygon::geometry);
160
161
162--
163-- Text
164--
165
166-- Precision
167SELECT 'text_precision_01', ST_AsText(GeomFromEWKT('SRID=4326;POINT(111.1111111 1.1111111)'));
168SELECT 'text_precision_02', ST_AsText(GeomFromEWKT('SRID=4326;POINT(111.1111111 1.1111111)'),2);
169