int SRID = SRID_DEFAULT;
int precision = OUT_MAX_DOUBLE_PRECISION;
int option=0;
+ int is_deegree=0;
/* Get the version */
version = PG_GETARG_INT32(0);
elog(ERROR, "SRID %d unknown in spatial_ref_sys table", SRID_DEFAULT);
PG_RETURN_NULL();
}
+
+ /* Revert lat/lon only with long SRS */
+ if (option & 1) is_deegree = 1;
if (version == 2)
gml = lwgeom_to_gml2(lwgeom_serialize(lwgeom), srs, precision);
else
- gml = lwgeom_to_gml3(lwgeom_serialize(lwgeom), srs, precision, 1);
+ gml = lwgeom_to_gml3(lwgeom_serialize(lwgeom), srs, precision, is_deegree);
PG_FREE_IF_COPY(lwgeom, 1);
/* check for relative path notation */
if ( PG_NARGS() > 1 && ! PG_ARGISNULL(1) )
- relative = PG_GETARG_INT32(1) ? 0:1;
+ relative = PG_GETARG_INT32(1) ? 1:0;
if ( PG_NARGS() > 2 && ! PG_ARGISNULL(2) )
{
sql-mm-general \
sql-mm-multicurve \
sql-mm-multisurface \
- geojson \
- gml \
- svg \
- kml \
+ out_geometry \
+ out_geography \
in_gml \
in_kml \
regress_ogc \
+++ /dev/null
---
--- spatial_ref_sys data
---
-INSERT INTO "spatial_ref_sys" ("srid","auth_name","auth_srid","proj4text") VALUES (4326,'EPSG',4326,'+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs ');
-
-
--- Empty Geometry
-SELECT 'empty_geom', ST_AsGeoJson(GeomFromEWKT(NULL));
-
--- Precision
-SELECT 'precision_01', ST_AsGeoJson(GeomFromEWKT('SRID=4326;POINT(1.1111111 1.1111111)'), -2);
-SELECT 'precision_02', ST_AsGeoJson(GeomFromEWKT('SRID=4326;POINT(1.1111111 1.1111111)'), 19);
-
-
--- Version
-SELECT 'version_01', ST_AsGeoJson(1, GeomFromEWKT('SRID=4326;POINT(1 1)'));
-SELECT 'version_02', ST_AsGeoJson(21, GeomFromEWKT('SRID=4326;POINT(1 1)'));
-SELECT 'version_03', ST_AsGeoJson(-4, GeomFromEWKT('SRID=4326;POINT(1 1)'));
-
-
--- CRS
-SELECT 'crs_01', ST_AsGeoJson(GeomFromEWKT('SRID=4326;POINT(1 1)'), 0, 2);
-SELECT 'crs_02', ST_AsGeoJson(GeomFromEWKT('SRID=-1;POINT(1 1)'), 0, 2);
-SELECT 'crs_03', ST_AsGeoJson(GeomFromEWKT('SRID=4326;POINT(1 1)'), 0, 4);
-SELECT 'crs_04', ST_AsGeoJson(GeomFromEWKT('SRID=-1;POINT(1 1)'), 0, 4);
-SELECT 'crs_05', ST_AsGeoJson(GeomFromEWKT('SRID=1;POINT(1 1)'), 0, 2);
-SELECT 'crs_06', ST_AsGeoJson(GeomFromEWKT('SRID=1;POINT(1 1)'), 0, 4);
-
--- Bbox
-SELECT 'bbox_01', ST_AsGeoJson(GeomFromEWKT('LINESTRING(1 1, 2 2, 3 3, 4 4)'), 0);
-SELECT 'bbox_02', ST_AsGeoJson(GeomFromEWKT('LINESTRING(1 1, 2 2, 3 3, 4 4)'), 0, 1);
-SELECT 'bbox_03', ST_AsGeoJson(GeomFromEWKT('LINESTRING(1 1, 2 2, 3 3, 4 4)'), 0, 3);
-SELECT 'bbox_04', ST_AsGeoJson(GeomFromEWKT('LINESTRING(1 1, 2 2, 3 3, 4 4)'), 0, 5);
-
--- CRS and Bbox
-SELECT 'options_01', ST_AsGeoJson(GeomFromEWKT('SRID=-1;LINESTRING(1 1, 2 2, 3 3, 4 4)'), 0, 0);
-SELECT 'options_02', ST_AsGeoJson(GeomFromEWKT('SRID=4326;LINESTRING(1 1, 2 2, 3 3, 4 4)'), 0);
-SELECT 'options_03', ST_AsGeoJson(GeomFromEWKT('SRID=-1;LINESTRING(1 1, 2 2, 3 3, 4 4)'), 0, 1);
-SELECT 'options_04', ST_AsGeoJson(GeomFromEWKT('SRID=4326;LINESTRING(1 1, 2 2, 3 3, 4 4)'), 0, 1);
-SELECT 'options_05', ST_AsGeoJson(GeomFromEWKT('SRID=-1;LINESTRING(1 1, 2 2, 3 3, 4 4)'), 0, 2);
-SELECT 'options_06', ST_AsGeoJson(GeomFromEWKT('SRID=4326;LINESTRING(1 1, 2 2, 3 3, 4 4)'), 0, 2);
-SELECT 'options_07', ST_AsGeoJson(GeomFromEWKT('SRID=-1;LINESTRING(1 1, 2 2, 3 3, 4 4)'), 0, 3);
-SELECT 'options_08', ST_AsGeoJson(GeomFromEWKT('SRID=4326;LINESTRING(1 1, 2 2, 3 3, 4 4)'), 0, 3);
-SELECT 'options_09', ST_AsGeoJson(GeomFromEWKT('SRID=-1;LINESTRING(1 1, 2 2, 3 3, 4 4)'), 0, 4);
-SELECT 'options_10', ST_AsGeoJson(GeomFromEWKT('SRID=4326;LINESTRING(1 1, 2 2, 3 3, 4 4)'), 0, 4);
-SELECT 'options_10', ST_AsGeoJson(GeomFromEWKT('SRID=-1;LINESTRING(1 1, 2 2, 3 3, 4 4)'), 0, 5);
-SELECT 'options_11', ST_AsGeoJson(GeomFromEWKT('SRID=4326;LINESTRING(1 1, 2 2, 3 3, 4 4)'), 0, 5);
-SELECT 'options_12', ST_AsGeoJson(GeomFromEWKT('SRID=-1;LINESTRING(1 1, 2 2, 3 3, 4 4)'), 0, 6);
-SELECT 'options_13', ST_AsGeoJson(GeomFromEWKT('SRID=4326;LINESTRING(1 1, 2 2, 3 3, 4 4)'), 0, 6);
-SELECT 'options_14', ST_AsGeoJson(GeomFromEWKT('SRID=-1;LINESTRING(1 1, 2 2, 3 3, 4 4)'), 0, 7);
-SELECT 'options_15', ST_AsGeoJson(GeomFromEWKT('SRID=4326;LINESTRING(1 1, 2 2, 3 3, 4 4)'), 0, 7);
-
-
-
---
--- Delete inserted spatial data
---
-DELETE FROM spatial_ref_sys;
+++ /dev/null
-empty_geom|
-precision_01|{"type":"Point","coordinates":[1,1]}
-precision_02|{"type":"Point","coordinates":[1.1111111,1.1111111]}
-version_01|{"type":"Point","coordinates":[1,1]}
-ERROR: Only GeoJSON 1 is supported
-ERROR: Only GeoJSON 1 is supported
-crs_01|{"type":"Point","crs":{"type":"name","properties":{"name":"EPSG:4326"}},"coordinates":[1,1]}
-crs_02|{"type":"Point","coordinates":[1,1]}
-crs_03|{"type":"Point","crs":{"type":"name","properties":{"name":"urn:ogc:def:crs:EPSG:4326"}},"coordinates":[1,1]}
-crs_04|{"type":"Point","coordinates":[1,1]}
-ERROR: SRID 1 unknown in spatial_ref_sys table
-ERROR: SRID 1 unknown in spatial_ref_sys table
-bbox_01|{"type":"LineString","coordinates":[[1,1],[2,2],[3,3],[4,4]]}
-bbox_02|{"type":"LineString","bbox":[1,1,4,4],"coordinates":[[1,1],[2,2],[3,3],[4,4]]}
-bbox_03|{"type":"LineString","bbox":[1,1,4,4],"coordinates":[[1,1],[2,2],[3,3],[4,4]]}
-bbox_04|{"type":"LineString","bbox":[1,1,4,4],"coordinates":[[1,1],[2,2],[3,3],[4,4]]}
-options_01|{"type":"LineString","coordinates":[[1,1],[2,2],[3,3],[4,4]]}
-options_02|{"type":"LineString","coordinates":[[1,1],[2,2],[3,3],[4,4]]}
-options_03|{"type":"LineString","bbox":[1,1,4,4],"coordinates":[[1,1],[2,2],[3,3],[4,4]]}
-options_04|{"type":"LineString","bbox":[1,1,4,4],"coordinates":[[1,1],[2,2],[3,3],[4,4]]}
-options_05|{"type":"LineString","coordinates":[[1,1],[2,2],[3,3],[4,4]]}
-options_06|{"type":"LineString","crs":{"type":"name","properties":{"name":"EPSG:4326"}},"coordinates":[[1,1],[2,2],[3,3],[4,4]]}
-options_07|{"type":"LineString","bbox":[1,1,4,4],"coordinates":[[1,1],[2,2],[3,3],[4,4]]}
-options_08|{"type":"LineString","crs":{"type":"name","properties":{"name":"EPSG:4326"}},"bbox":[1,1,4,4],"coordinates":[[1,1],[2,2],[3,3],[4,4]]}
-options_09|{"type":"LineString","coordinates":[[1,1],[2,2],[3,3],[4,4]]}
-options_10|{"type":"LineString","crs":{"type":"name","properties":{"name":"urn:ogc:def:crs:EPSG:4326"}},"coordinates":[[1,1],[2,2],[3,3],[4,4]]}
-options_10|{"type":"LineString","bbox":[1,1,4,4],"coordinates":[[1,1],[2,2],[3,3],[4,4]]}
-options_11|{"type":"LineString","crs":{"type":"name","properties":{"name":"urn:ogc:def:crs:EPSG:4326"}},"bbox":[1,1,4,4],"coordinates":[[1,1],[2,2],[3,3],[4,4]]}
-options_12|{"type":"LineString","coordinates":[[1,1],[2,2],[3,3],[4,4]]}
-options_13|{"type":"LineString","crs":{"type":"name","properties":{"name":"urn:ogc:def:crs:EPSG:4326"}},"coordinates":[[1,1],[2,2],[3,3],[4,4]]}
-options_14|{"type":"LineString","bbox":[1,1,4,4],"coordinates":[[1,1],[2,2],[3,3],[4,4]]}
-options_15|{"type":"LineString","crs":{"type":"name","properties":{"name":"urn:ogc:def:crs:EPSG:4326"}},"bbox":[1,1,4,4],"coordinates":[[1,1],[2,2],[3,3],[4,4]]}
+++ /dev/null
---
--- spatial_ref_sys data
---
-INSERT INTO "spatial_ref_sys" ("srid","auth_name","auth_srid","srtext","proj4text") VALUES (4326,'EPSG',4326,'GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]]','+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs ');
-
--- Empty Geometry
-SELECT 'empty_geom', ST_AsGML(GeomFromEWKT(NULL));
-
--- Precision
-SELECT 'precision_01', ST_AsGML(GeomFromEWKT('SRID=4326;POINT(1.1111111 1.1111111)'), -2);
-SELECT 'precision_02', ST_AsGML(GeomFromEWKT('SRID=4326;POINT(1.1111111 1.1111111)'), 19);
-
--- Version
-SELECT 'version_01', ST_AsGML(2, GeomFromEWKT('SRID=4326;POINT(1 1)'));
-SELECT 'version_02', ST_AsGML(3, GeomFromEWKT('SRID=4326;POINT(1 1)'));
-SELECT 'version_03', ST_AsGML(21, GeomFromEWKT('SRID=4326;POINT(1 1)'));
-SELECT 'version_04', ST_AsGML(-4, GeomFromEWKT('SRID=4326;POINT(1 1)'));
-
--- Option
-SELECT 'option_01', ST_AsGML(2, GeomFromEWKT('SRID=4326;POINT(1 1)'), 0, 0);
-SELECT 'option_02', ST_AsGML(3, GeomFromEWKT('SRID=4326;POINT(1 1)'), 0, 1);
-
--- Deegree data
-SELECT 'deegree_01', ST_AsGML(3, GeomFromEWKT('SRID=4326;POINT(1 2)'), 0, 0);
-SELECT 'deegree_02', ST_AsGML(2, GeomFromEWKT('SRID=4326;POINT(1 2)'), 0, 16);
-SELECT 'deegree_03', ST_AsGML(3, GeomFromEWKT('SRID=4326;POINT(1 2)'), 0, 16);
-SELECT 'deegree_04', ST_AsGML(3, GeomFromEWKT('SRID=4326;POINT(1 2 3)'), 0, 0);
-SELECT 'deegree_05', ST_AsGML(2, GeomFromEWKT('SRID=4326;POINT(1 2 3)'), 0, 16);
-SELECT 'deegree_06', ST_AsGML(3, GeomFromEWKT('SRID=4326;POINT(1 2 3)'), 0, 16);
-SELECT 'deegree_07', ST_AsGML(3, GeomFromEWKT('SRID=4326;LINESTRING(1 2, 2 3, 4 5)'), 0, 0);
-SELECT 'deegree_08', ST_AsGML(2, GeomFromEWKT('SRID=4326;LINESTRING(1 2, 2 3, 4 5)'), 0, 16);
-SELECT 'deegree_09', ST_AsGML(3, GeomFromEWKT('SRID=4326;LINESTRING(1 2, 2 3, 4 5)'), 0, 16);
-SELECT 'deegree_10', ST_AsGML(3, GeomFromEWKT('SRID=4326;POLYGON((1 2, 2 3, 4 5, 3 2, 1 2))'), 0, 0);
-SELECT 'deegree_11', ST_AsGML(2, GeomFromEWKT('SRID=4326;POLYGON((1 2, 2 3, 4 5, 3 2, 1 2))'), 0, 16);
-SELECT 'deegree_12', ST_AsGML(3, GeomFromEWKT('SRID=4326;POLYGON((1 2, 2 3, 4 5, 3 2, 1 2))'), 0, 16);
-SELECT 'deegree_13', ST_AsGML(3, GeomFromEWKT('SRID=4326;MULTIPOINT(1 2, 2 3, 4 5)'), 0, 0);
-SELECT 'deegree_14', ST_AsGML(2, GeomFromEWKT('SRID=4326;MULTIPOINT(1 2, 2 3, 4 5)'), 0, 16);
-SELECT 'deegree_15', ST_AsGML(3, GeomFromEWKT('SRID=4326;MULTIPOINT(1 2, 2 3, 4 5)'), 0, 16);
-SELECT 'deegree_16', ST_AsGML(3, GeomFromEWKT('SRID=4326;MULTILINESTRING((1 2, 2 3, 4 5))'), 0, 0);
-SELECT 'deegree_17', ST_AsGML(2, GeomFromEWKT('SRID=4326;MULTILINESTRING((1 2, 2 3, 4 5))'), 0, 16);
-SELECT 'deegree_18', ST_AsGML(3, GeomFromEWKT('SRID=4326;MULTILINESTRING((1 2, 2 3, 4 5))'), 0, 16);
-SELECT 'deegree_19', ST_AsGML(3, GeomFromEWKT('SRID=4326;MULTIPOLYGON(((1 2, 2 3, 4 5, 3 2, 1 2)))'), 0, 0);
-SELECT 'deegree_20', ST_AsGML(2, GeomFromEWKT('SRID=4326;MULTIPOLYGON(((1 2, 2 3, 4 5, 3 2, 1 2)))'), 0, 16);
-SELECT 'deegree_21', ST_AsGML(3, GeomFromEWKT('SRID=4326;MULTIPOLYGON(((1 2, 2 3, 4 5, 3 2, 1 2)))'), 0, 16);
-SELECT 'deegree_22', ST_AsGML(3, GeomFromEWKT('SRID=4326;GEOMETRYCOLLECTION(MULTIPOLYGON(((1 2, 2 3, 4 5, 3 2, 1 2))), MULTILINESTRING((1 2, 2 3, 4 5)), MULTIPOINT(1 2, 3 4))'), 0, 0);
-SELECT 'deegree_23', ST_AsGML(2, GeomFromEWKT('SRID=4326;GEOMETRYCOLLECTION(MULTIPOLYGON(((1 2, 2 3, 4 5, 3 2, 1 2))), MULTILINESTRING((1 2, 2 3, 4 5)), MULTIPOINT(1 2, 3 4))'), 0, 16);
-SELECT 'deegree_24', ST_AsGML(3, GeomFromEWKT('SRID=4326;GEOMETRYCOLLECTION(MULTIPOLYGON(((1 2, 2 3, 4 5, 3 2, 1 2))), MULTILINESTRING((1 2, 2 3, 4 5)), MULTIPOINT(1 2, 3 4))'), 0, 16);
-
-
---
--- Delete inserted spatial data
---
-DELETE FROM spatial_ref_sys WHERE srid = 4326;
+++ /dev/null
-empty_geom|
-precision_01|<gml:Point srsName="EPSG:4326"><gml:coordinates>1,1</gml:coordinates></gml:Point>
-precision_02|<gml:Point srsName="EPSG:4326"><gml:coordinates>1.1111111,1.1111111</gml:coordinates></gml:Point>
-version_01|<gml:Point srsName="EPSG:4326"><gml:coordinates>1,1</gml:coordinates></gml:Point>
-version_02|<gml:Point srsName="EPSG:4326"><gml:pos srsDimension="2">1 1</gml:pos></gml:Point>
-ERROR: Only GML 2 and GML 3 are supported
-ERROR: Only GML 2 and GML 3 are supported
-option_01|<gml:Point srsName="EPSG:4326"><gml:coordinates>1,1</gml:coordinates></gml:Point>
-option_02|<gml:Point srsName="urn:ogc:def:crs:EPSG:4326"><gml:pos srsDimension="2">1 1</gml:pos></gml:Point>
-deegree_01|<gml:Point srsName="EPSG:4326"><gml:pos srsDimension="2">1 2</gml:pos></gml:Point>
-deegree_02|<gml:Point srsName="EPSG:4326"><gml:coordinates>1,2</gml:coordinates></gml:Point>
-deegree_03|<gml:Point srsName="EPSG:4326"><gml:pos srsDimension="2">2 1</gml:pos></gml:Point>
-deegree_04|<gml:Point srsName="EPSG:4326"><gml:pos srsDimension="3">1 2 3</gml:pos></gml:Point>
-deegree_05|<gml:Point srsName="EPSG:4326"><gml:coordinates>1,2,3</gml:coordinates></gml:Point>
-deegree_06|<gml:Point srsName="EPSG:4326"><gml:pos srsDimension="3">2 1 3</gml:pos></gml:Point>
-deegree_07|<gml:Curve srsName="EPSG:4326"><gml:segments><gml:LineStringSegment><gml:posList srsDimension="2">1 2 2 3 4 5</gml:posList></gml:LineStringSegment></gml:segments></gml:Curve>
-deegree_08|<gml:LineString srsName="EPSG:4326"><gml:coordinates>1,2 2,3 4,5</gml:coordinates></gml:LineString>
-deegree_09|<gml:Curve srsName="EPSG:4326"><gml:segments><gml:LineStringSegment><gml:posList srsDimension="2">2 1 3 2 5 4</gml:posList></gml:LineStringSegment></gml:segments></gml:Curve>
-deegree_10|<gml:Polygon srsName="EPSG:4326"><gml:exterior><gml:LinearRing><gml:posList srsDimension="2">1 2 2 3 4 5 3 2 1 2</gml:posList></gml:LinearRing></gml:exterior></gml:Polygon>
-deegree_11|<gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>1,2 2,3 4,5 3,2 1,2</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon>
-deegree_12|<gml:Polygon srsName="EPSG:4326"><gml:exterior><gml:LinearRing><gml:posList srsDimension="2">2 1 3 2 5 4 2 3 2 1</gml:posList></gml:LinearRing></gml:exterior></gml:Polygon>
-deegree_13|<gml:MultiPoint srsName="EPSG:4326"><gml:pointMember><gml:Point><gml:pos srsDimension="2">1 2</gml:pos></gml:Point></gml:pointMember><gml:pointMember><gml:Point><gml:pos srsDimension="2">2 3</gml:pos></gml:Point></gml:pointMember><gml:pointMember><gml:Point><gml:pos srsDimension="2">4 5</gml:pos></gml:Point></gml:pointMember></gml:MultiPoint>
-deegree_14|<gml:MultiPoint srsName="EPSG:4326"><gml:pointMember><gml:Point><gml:coordinates>1,2</gml:coordinates></gml:Point></gml:pointMember><gml:pointMember><gml:Point><gml:coordinates>2,3</gml:coordinates></gml:Point></gml:pointMember><gml:pointMember><gml:Point><gml:coordinates>4,5</gml:coordinates></gml:Point></gml:pointMember></gml:MultiPoint>
-deegree_15|<gml:MultiPoint srsName="EPSG:4326"><gml:pointMember><gml:Point><gml:pos srsDimension="2">2 1</gml:pos></gml:Point></gml:pointMember><gml:pointMember><gml:Point><gml:pos srsDimension="2">3 2</gml:pos></gml:Point></gml:pointMember><gml:pointMember><gml:Point><gml:pos srsDimension="2">5 4</gml:pos></gml:Point></gml:pointMember></gml:MultiPoint>
-deegree_16|<gml:MultiCurve srsName="EPSG:4326"><gml:curveMember><gml:Curve><gml:segments><gml:LineStringSegment><gml:posList srsDimension="2">1 2 2 3 4 5</gml:posList></gml:LineStringSegment></gml:segments></gml:Curve></gml:curveMember></gml:MultiCurve>
-deegree_17|<gml:MultiLineString srsName="EPSG:4326"><gml:lineStringMember><gml:LineString><gml:coordinates>1,2 2,3 4,5</gml:coordinates></gml:LineString></gml:lineStringMember></gml:MultiLineString>
-deegree_18|<gml:MultiCurve srsName="EPSG:4326"><gml:curveMember><gml:Curve><gml:segments><gml:LineStringSegment><gml:posList srsDimension="2">2 1 3 2 5 4</gml:posList></gml:LineStringSegment></gml:segments></gml:Curve></gml:curveMember></gml:MultiCurve>
-deegree_19|<gml:MultiSurface srsName="EPSG:4326"><gml:surfaceMember><gml:Polygon><gml:exterior><gml:LinearRing><gml:posList srsDimension="2">1 2 2 3 4 5 3 2 1 2</gml:posList></gml:LinearRing></gml:exterior></gml:Polygon></gml:surfaceMember></gml:MultiSurface>
-deegree_20|<gml:MultiPolygon srsName="EPSG:4326"><gml:polygonMember><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>1,2 2,3 4,5 3,2 1,2</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></gml:polygonMember></gml:MultiPolygon>
-deegree_21|<gml:MultiSurface srsName="EPSG:4326"><gml:surfaceMember><gml:Polygon><gml:exterior><gml:LinearRing><gml:posList srsDimension="2">2 1 3 2 5 4 2 3 2 1</gml:posList></gml:LinearRing></gml:exterior></gml:Polygon></gml:surfaceMember></gml:MultiSurface>
-deegree_22|<gml:MultiGeometry srsName="EPSG:4326"><gml:geometryMember><gml:MultiSurface><gml:surfaceMember><gml:Polygon><gml:exterior><gml:LinearRing><gml:posList srsDimension="2">1 2 2 3 4 5 3 2 1 2</gml:posList></gml:LinearRing></gml:exterior></gml:Polygon></gml:surfaceMember></gml:MultiSurface></gml:geometryMember><gml:geometryMember><gml:MultiCurve><gml:curveMember><gml:Curve><gml:segments><gml:LineStringSegment><gml:posList srsDimension="2">1 2 2 3 4 5</gml:posList></gml:LineStringSegment></gml:segments></gml:Curve></gml:curveMember></gml:MultiCurve></gml:geometryMember><gml:geometryMember><gml:MultiPoint><gml:pointMember><gml:Point><gml:pos srsDimension="2">1 2</gml:pos></gml:Point></gml:pointMember><gml:pointMember><gml:Point><gml:pos srsDimension="2">3 4</gml:pos></gml:Point></gml:pointMember></gml:MultiPoint></gml:geometryMember></gml:MultiGeometry>
-deegree_23|<gml:MultiGeometry srsName="EPSG:4326"><gml:geometryMember><gml:MultiPolygon><gml:polygonMember><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>1,2 2,3 4,5 3,2 1,2</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></gml:polygonMember></gml:MultiPolygon></gml:geometryMember><gml:geometryMember><gml:MultiLineString><gml:lineStringMember><gml:LineString><gml:coordinates>1,2 2,3 4,5</gml:coordinates></gml:LineString></gml:lineStringMember></gml:MultiLineString></gml:geometryMember><gml:geometryMember><gml:MultiPoint><gml:pointMember><gml:Point><gml:coordinates>1,2</gml:coordinates></gml:Point></gml:pointMember><gml:pointMember><gml:Point><gml:coordinates>3,4</gml:coordinates></gml:Point></gml:pointMember></gml:MultiPoint></gml:geometryMember></gml:MultiGeometry>
-deegree_24|<gml:MultiGeometry srsName="EPSG:4326"><gml:geometryMember><gml:MultiSurface><gml:surfaceMember><gml:Polygon><gml:exterior><gml:LinearRing><gml:posList srsDimension="2">2 1 3 2 5 4 2 3 2 1</gml:posList></gml:LinearRing></gml:exterior></gml:Polygon></gml:surfaceMember></gml:MultiSurface></gml:geometryMember><gml:geometryMember><gml:MultiCurve><gml:curveMember><gml:Curve><gml:segments><gml:LineStringSegment><gml:posList srsDimension="2">2 1 3 2 5 4</gml:posList></gml:LineStringSegment></gml:segments></gml:Curve></gml:curveMember></gml:MultiCurve></gml:geometryMember><gml:geometryMember><gml:MultiPoint><gml:pointMember><gml:Point><gml:pos srsDimension="2">2 1</gml:pos></gml:Point></gml:pointMember><gml:pointMember><gml:Point><gml:pos srsDimension="2">4 3</gml:pos></gml:Point></gml:pointMember></gml:MultiPoint></gml:geometryMember></gml:MultiGeometry>
+++ /dev/null
--- Regress test for ST_AsKML
-
---- EPSG 4326 : WGS 84
-INSERT INTO "spatial_ref_sys" ("srid", "proj4text") VALUES (4326, '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs ');
-
---- EPSG 1021892 : Bogota 1975 / Colombia Bogota zone (deprecated)
-INSERT INTO "spatial_ref_sys" ("srid", "proj4text") VALUES (1021892, '+proj=tmerc +lat_0=4.599047222222222 +lon_0=-74.08091666666667 +k=1.000000 +x_0=1000000 +y_0=1000000 +ellps=intl +towgs84=307,304,-318,0,0,0,0 +units=m +no_defs ');
-
-
--- SRID
-SELECT 'srid_01', ST_AsKML(GeomFromEWKT('SRID=10;POINT(0 1)'));
-SELECT 'srid_02', ST_AsKML(GeomFromEWKT('POINT(0 1)'));
-
--- Empty Geometry
-SELECT 'empty_geom', ST_AsKML(GeomFromEWKT(NULL));
-
--- Precision
-SELECT 'precision_01', ST_AsKML(ST_GeomFromEWKT('SRID=4326;POINT(1.1111111 1.1111111)'), -2);
-SELECT 'precision_02', ST_AsKML(ST_GeomFromEWKT('SRID=4326;POINT(1.1111111 1.1111111)'), 19);
-
--- Version
-SELECT 'version_01', ST_AsKML(2, GeomFromEWKT('SRID=4326;POINT(1 1)'));
-SELECT 'version_02', ST_AsKML(3, GeomFromEWKT('SRID=4326;POINT(1 1)'));
-SELECT 'version_03', ST_AsKML(-4, GeomFromEWKT('SRID=4326;POINT(1 1)'));
-
--- Projected
--- National Astronomical Observatory of Colombia - Bogota, Colombia (Placemark)
-SELECT 'projection_01', ST_AsKML(ST_GeomFromEWKT('SRID=1021892;POINT(1000000 1000000)'), 3);
-
-
-DELETE FROM spatial_ref_sys;
+++ /dev/null
-ERROR: GetProj4StringSPI: Cannot find SRID (10) in spatial_ref_sys
-ERROR: Input geometry has unknown (-1) SRID
-empty_geom|
-precision_01|<Point><coordinates>1,1</coordinates></Point>
-precision_02|<Point><coordinates>1.1111111,1.1111111</coordinates></Point>
-version_01|<Point><coordinates>1,1</coordinates></Point>
-ERROR: Only KML 2 is supported
-ERROR: Only KML 2 is supported
-projection_01|<Point><coordinates>-74.078,4.596</coordinates></Point>
--- /dev/null
+--
+-- spatial_ref_sys data
+--
+INSERT INTO "spatial_ref_sys" ("srid","auth_name","auth_srid","proj4text") VALUES (4326,'EPSG',4326,'+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs ');
+
+--- EPSG 1021892 : Bogota 1975 / Colombia Bogota zone (deprecated)
+INSERT INTO "spatial_ref_sys" ("srid", "proj4text") VALUES (1021892, '+proj=tmerc +lat_0=4.599047222222222 +lon_0=-74.08091666666667 +k=1.000000 +x_0=1000000 +y_0=1000000 +ellps=intl +towgs84=307,304,-318,0,0,0,0 +units=m +no_defs ');
+
+
+--
+-- GML
+--
+
+-- Empty Geometry
+SELECT 'gml_empty_geom', ST_AsGML(geography(GeomFromEWKT(NULL)));
+
+-- Precision
+SELECT 'gml_precision_01', ST_AsGML(geography(GeomFromEWKT('SRID=4326;POINT(1.1111111 1.1111111)')), -2);
+SELECT 'gml_precision_02', ST_AsGML(geography(GeomFromEWKT('SRID=4326;POINT(1.1111111 1.1111111)')), 19);
+
+-- Version
+SELECT 'gml_version_01', ST_AsGML(2, geography(GeomFromEWKT('SRID=4326;POINT(1 1)')));
+SELECT 'gml_version_02', ST_AsGML(3, geography(GeomFromEWKT('SRID=4326;POINT(1 1)')));
+SELECT 'gml_version_03', ST_AsGML(21, geography(GeomFromEWKT('SRID=4326;POINT(1 1)')));
+SELECT 'gml_version_04', ST_AsGML(-4, geography(GeomFromEWKT('SRID=4326;POINT(1 1)')));
+
+-- Option
+SELECT 'gml_option_01', ST_AsGML(2, geography(GeomFromEWKT('SRID=4326;POINT(1 1)')), 0, 0);
+SELECT 'gml_option_02', ST_AsGML(3, geography(GeomFromEWKT('SRID=4326;POINT(1 1)')), 0, 1);
+
+-- Deegree data
+SELECT 'gml_deegree_01', ST_AsGML(2, geography(GeomFromEWKT('SRID=4326;POINT(1 2)')), 0, 0);
+SELECT 'gml_deegree_02', ST_AsGML(2, geography(GeomFromEWKT('SRID=4326;POINT(1 2)')), 0, 1);
+SELECT 'gml_deegree_03', ST_AsGML(3, geography(GeomFromEWKT('SRID=4326;POINT(1 2)')), 0, 0);
+SELECT 'gml_deegree_04', ST_AsGML(3, geography(GeomFromEWKT('SRID=4326;POINT(1 2)')), 0, 1);
+
+
+--
+-- KML
+--
+
+-- SRID
+SELECT 'kml_srid_01', ST_AsKML(geography(GeomFromEWKT('SRID=10;POINT(0 1)')));
+SELECT 'kml_srid_02', ST_AsKML(geography(GeomFromEWKT('POINT(0 1)')));
+
+-- Empty Geometry
+SELECT 'kml_empty_geom', ST_AsKML(geography(GeomFromEWKT(NULL)));
+
+-- Precision
+SELECT 'kml_precision_01', ST_AsKML(geography(GeomFromEWKT('SRID=4326;POINT(1.1111111 1.1111111)')), -2);
+SELECT 'kml_precision_02', ST_AsKML(geography(GeomFromEWKT('SRID=4326;POINT(1.1111111 1.1111111)')), 19);
+
+-- Version
+SELECT 'kml_version_01', ST_AsKML(2, geography(GeomFromEWKT('SRID=4326;POINT(1 1)')));
+SELECT 'kml_version_02', ST_AsKML(3, geography(GeomFromEWKT('SRID=4326;POINT(1 1)')));
+SELECT 'kml_version_03', ST_AsKML(-4, geography(GeomFromEWKT('SRID=4326;POINT(1 1)')));
+
+-- Projected
+-- National Astronomical Observatory of Colombia - Bogota, Colombia (Placemark)
+SELECT 'kml_projection_01', ST_AsKML(geography(GeomFromEWKT('SRID=1021892;POINT(1000000 1000000)')), 3);
+
+
+--
+-- SVG
+--
+
+-- Empty Geometry
+SELECT 'svg_empty_geom', ST_AsSVG(geography(GeomFromEWKT(NULL)));
+
+-- Option
+SELECT 'svg_option_01', ST_AsSVG(geography(GeomFromEWKT('LINESTRING(1 1, 4 4, 5 7)')), 0);
+SELECT 'svg_option_02', ST_AsSVG(geography(GeomFromEWKT('LINESTRING(1 1, 4 4, 5 7)')), 1);
+SELECT 'svg_option_03', ST_AsSVG(geography(GeomFromEWKT('LINESTRING(1 1, 4 4, 5 7)')), 0, 0);
+SELECT 'svg_option_04', ST_AsSVG(geography(GeomFromEWKT('LINESTRING(1 1, 4 4, 5 7)')), 1, 0);
+
+-- Precision
+SELECT 'svg_precision_01', ST_AsSVG(geography(GeomFromEWKT('POINT(1.1111111 1.1111111)')), 1, -2);
+SELECT 'svg_precision_02', ST_AsSVG(geography(GeomFromEWKT('POINT(1.1111111 1.1111111)')), 1, 19);
+
+
+--
+-- GeoJson
+--
+
+-- Empty Geometry
+SELECT 'geojson_empty_geom', ST_AsGeoJson(geography(GeomFromEWKT(NULL)));
+
+-- Precision
+SELECT 'geojson_precision_01', ST_AsGeoJson(geography(GeomFromEWKT('SRID=4326;POINT(1.1111111 1.1111111)')), -2);
+SELECT 'geojson_precision_02', ST_AsGeoJson(geography(GeomFromEWKT('SRID=4326;POINT(1.1111111 1.1111111)')), 19);
+
+-- Version
+SELECT 'geojson_version_01', ST_AsGeoJson(1, geography(GeomFromEWKT('SRID=4326;POINT(1 1)')));
+SELECT 'geojson_version_02', ST_AsGeoJson(21, geography(GeomFromEWKT('SRID=4326;POINT(1 1)')));
+SELECT 'geojson_version_03', ST_AsGeoJson(-4, geography(GeomFromEWKT('SRID=4326;POINT(1 1)')));
+
+-- CRS
+SELECT 'geojson_crs_01', ST_AsGeoJson(geography(GeomFromEWKT('SRID=4326;POINT(1 1)')), 0, 2);
+SELECT 'geojson_crs_02', ST_AsGeoJson(geography(GeomFromEWKT('SRID=-1;POINT(1 1)')), 0, 2);
+SELECT 'geojson_crs_03', ST_AsGeoJson(geography(GeomFromEWKT('SRID=4326;POINT(1 1)')), 0, 4);
+SELECT 'geojson_crs_04', ST_AsGeoJson(geography(GeomFromEWKT('SRID=-1;POINT(1 1)')), 0, 4);
+SELECT 'geojson_crs_05', ST_AsGeoJson(geography(GeomFromEWKT('SRID=1;POINT(1 1)')), 0, 2);
+SELECT 'geojson_crs_06', ST_AsGeoJson(geography(GeomFromEWKT('SRID=1;POINT(1 1)')), 0, 4);
+
+-- Bbox
+SELECT 'geojson_bbox_01', ST_AsGeoJson(geography(GeomFromEWKT('LINESTRING(1 1, 2 2, 3 3, 4 4)')), 0);
+SELECT 'geojson_bbox_02', ST_AsGeoJson(geography(GeomFromEWKT('LINESTRING(1 1, 2 2, 3 3, 4 4)')), 0, 1);
+SELECT 'geojson_bbox_03', ST_AsGeoJson(geography(GeomFromEWKT('LINESTRING(1 1, 2 2, 3 3, 4 4)')), 0, 3);
+SELECT 'geojson_bbox_04', ST_AsGeoJson(geography(GeomFromEWKT('LINESTRING(1 1, 2 2, 3 3, 4 4)')), 0, 5);
+
+-- CRS and Bbox
+SELECT 'geojson_options_01', ST_AsGeoJson(geography(GeomFromEWKT('SRID=-1;LINESTRING(1 1, 2 2, 3 3, 4 4)')), 0, 0);
+SELECT 'geojson_options_02', ST_AsGeoJson(geography(GeomFromEWKT('SRID=4326;LINESTRING(1 1, 2 2, 3 3, 4 4)')), 0);
+SELECT 'geojson_options_03', ST_AsGeoJson(geography(GeomFromEWKT('SRID=-1;LINESTRING(1 1, 2 2, 3 3, 4 4)')), 0, 1);
+SELECT 'geojson_options_04', ST_AsGeoJson(geography(GeomFromEWKT('SRID=4326;LINESTRING(1 1, 2 2, 3 3, 4 4)')), 0, 1);
+SELECT 'geojson_options_05', ST_AsGeoJson(geography(GeomFromEWKT('SRID=-1;LINESTRING(1 1, 2 2, 3 3, 4 4)')), 0, 2);
+SELECT 'geojson_options_06', ST_AsGeoJson(geography(GeomFromEWKT('SRID=4326;LINESTRING(1 1, 2 2, 3 3, 4 4)')), 0, 2);
+SELECT 'geojson_options_07', ST_AsGeoJson(geography(GeomFromEWKT('SRID=-1;LINESTRING(1 1, 2 2, 3 3, 4 4)')), 0, 3);
+SELECT 'geojson_options_08', ST_AsGeoJson(geography(GeomFromEWKT('SRID=4326;LINESTRING(1 1, 2 2, 3 3, 4 4)')), 0, 3);
+SELECT 'geojson_options_09', ST_AsGeoJson(geography(GeomFromEWKT('SRID=-1;LINESTRING(1 1, 2 2, 3 3, 4 4)')), 0, 4);
+SELECT 'geojson_options_10', ST_AsGeoJson(geography(GeomFromEWKT('SRID=4326;LINESTRING(1 1, 2 2, 3 3, 4 4)')), 0, 4);
+SELECT 'geojson_options_11', ST_AsGeoJson(geography(GeomFromEWKT('SRID=-1;LINESTRING(1 1, 2 2, 3 3, 4 4)')), 0, 5);
+SELECT 'geojson_options_12', ST_AsGeoJson(geography(GeomFromEWKT('SRID=4326;LINESTRING(1 1, 2 2, 3 3, 4 4)')), 0, 5);
+SELECT 'geojson_options_13', ST_AsGeoJson(geography(GeomFromEWKT('SRID=-1;LINESTRING(1 1, 2 2, 3 3, 4 4)')), 0, 6);
+SELECT 'geojson_options_14', ST_AsGeoJson(geography(GeomFromEWKT('SRID=4326;LINESTRING(1 1, 2 2, 3 3, 4 4)')), 0, 6);
+SELECT 'geojson_options_15', ST_AsGeoJson(geography(GeomFromEWKT('SRID=-1;LINESTRING(1 1, 2 2, 3 3, 4 4)')), 0, 7);
+SELECT 'geojson_options_16', ST_AsGeoJson(geography(GeomFromEWKT('SRID=4326;LINESTRING(1 1, 2 2, 3 3, 4 4)')), 0, 7);
+
+
+--
+-- Delete inserted spatial data
+--
+DELETE FROM spatial_ref_sys;
--- /dev/null
+gml_empty_geom|
+gml_precision_01|<gml:Point srsName="EPSG:4326"><gml:coordinates>1,1</gml:coordinates></gml:Point>
+gml_precision_02|<gml:Point srsName="EPSG:4326"><gml:coordinates>1.1111111,1.1111111</gml:coordinates></gml:Point>
+gml_version_01|<gml:Point srsName="EPSG:4326"><gml:coordinates>1,1</gml:coordinates></gml:Point>
+gml_version_02|<gml:Point srsName="EPSG:4326"><gml:pos srsDimension="2">1 1</gml:pos></gml:Point>
+ERROR: Only GML 2 and GML 3 are supported
+ERROR: Only GML 2 and GML 3 are supported
+gml_option_01|<gml:Point srsName="EPSG:4326"><gml:coordinates>1,1</gml:coordinates></gml:Point>
+gml_option_02|<gml:Point srsName="urn:ogc:def:crs:EPSG:4326"><gml:pos srsDimension="2">1 1</gml:pos></gml:Point>
+gml_deegree_01|<gml:Point srsName="EPSG:4326"><gml:coordinates>1,2</gml:coordinates></gml:Point>
+gml_deegree_02|<gml:Point srsName="urn:ogc:def:crs:EPSG:4326"><gml:coordinates>1,2</gml:coordinates></gml:Point>
+gml_deegree_03|<gml:Point srsName="EPSG:4326"><gml:pos srsDimension="2">1 2</gml:pos></gml:Point>
+gml_deegree_04|<gml:Point srsName="urn:ogc:def:crs:EPSG:4326"><gml:pos srsDimension="2">2 1</gml:pos></gml:Point>
+ERROR: Only SRID SRID_DEFAULT is currently supported in geography.
+kml_srid_02|<Point><coordinates>0,1</coordinates></Point>
+kml_empty_geom|
+kml_precision_01|<Point><coordinates>1,1</coordinates></Point>
+kml_precision_02|<Point><coordinates>1.1111111,1.1111111</coordinates></Point>
+kml_version_01|<Point><coordinates>1,1</coordinates></Point>
+ERROR: Only KML 2 is supported
+ERROR: Only KML 2 is supported
+ERROR: Only SRID SRID_DEFAULT is currently supported in geography.
+svg_empty_geom|
+svg_option_01|M 1 -1 L 4 -4 5 -7
+svg_option_02|M 1 -1 l 3 -3 1 -3
+svg_option_03|M 1 -1 L 4 -4 5 -7
+svg_option_04|M 1 -1 l 3 -3 1 -3
+svg_precision_01|x="1" y="-1"
+svg_precision_02|x="1.1111111" y="-1.1111111"
+geojson_empty_geom|
+geojson_precision_01|{"type":"Point","coordinates":[1,1]}
+geojson_precision_02|{"type":"Point","coordinates":[1.1111111,1.1111111]}
+geojson_version_01|{"type":"Point","coordinates":[1,1]}
+ERROR: Only GeoJSON 1 is supported
+ERROR: Only GeoJSON 1 is supported
+geojson_crs_01|{"type":"Point","crs":{"type":"name","properties":{"name":"EPSG:4326"}},"coordinates":[1,1]}
+geojson_crs_02|{"type":"Point","crs":{"type":"name","properties":{"name":"EPSG:4326"}},"coordinates":[1,1]}
+geojson_crs_03|{"type":"Point","crs":{"type":"name","properties":{"name":"urn:ogc:def:crs:EPSG:4326"}},"coordinates":[1,1]}
+geojson_crs_04|{"type":"Point","crs":{"type":"name","properties":{"name":"urn:ogc:def:crs:EPSG:4326"}},"coordinates":[1,1]}
+ERROR: Only SRID SRID_DEFAULT is currently supported in geography.
+ERROR: Only SRID SRID_DEFAULT is currently supported in geography.
+geojson_bbox_01|{"type":"LineString","coordinates":[[1,1],[2,2],[3,3],[4,4]]}
+geojson_bbox_02|{"type":"LineString","bbox":[1,1,4,4],"coordinates":[[1,1],[2,2],[3,3],[4,4]]}
+geojson_bbox_03|{"type":"LineString","crs":{"type":"name","properties":{"name":"EPSG:4326"}},"bbox":[1,1,4,4],"coordinates":[[1,1],[2,2],[3,3],[4,4]]}
+geojson_bbox_04|{"type":"LineString","crs":{"type":"name","properties":{"name":"urn:ogc:def:crs:EPSG:4326"}},"bbox":[1,1,4,4],"coordinates":[[1,1],[2,2],[3,3],[4,4]]}
+geojson_options_01|{"type":"LineString","coordinates":[[1,1],[2,2],[3,3],[4,4]]}
+geojson_options_02|{"type":"LineString","coordinates":[[1,1],[2,2],[3,3],[4,4]]}
+geojson_options_03|{"type":"LineString","bbox":[1,1,4,4],"coordinates":[[1,1],[2,2],[3,3],[4,4]]}
+geojson_options_04|{"type":"LineString","bbox":[1,1,4,4],"coordinates":[[1,1],[2,2],[3,3],[4,4]]}
+geojson_options_05|{"type":"LineString","crs":{"type":"name","properties":{"name":"EPSG:4326"}},"coordinates":[[1,1],[2,2],[3,3],[4,4]]}
+geojson_options_06|{"type":"LineString","crs":{"type":"name","properties":{"name":"EPSG:4326"}},"coordinates":[[1,1],[2,2],[3,3],[4,4]]}
+geojson_options_07|{"type":"LineString","crs":{"type":"name","properties":{"name":"EPSG:4326"}},"bbox":[1,1,4,4],"coordinates":[[1,1],[2,2],[3,3],[4,4]]}
+geojson_options_08|{"type":"LineString","crs":{"type":"name","properties":{"name":"EPSG:4326"}},"bbox":[1,1,4,4],"coordinates":[[1,1],[2,2],[3,3],[4,4]]}
+geojson_options_09|{"type":"LineString","crs":{"type":"name","properties":{"name":"urn:ogc:def:crs:EPSG:4326"}},"coordinates":[[1,1],[2,2],[3,3],[4,4]]}
+geojson_options_10|{"type":"LineString","crs":{"type":"name","properties":{"name":"urn:ogc:def:crs:EPSG:4326"}},"coordinates":[[1,1],[2,2],[3,3],[4,4]]}
+geojson_options_11|{"type":"LineString","crs":{"type":"name","properties":{"name":"urn:ogc:def:crs:EPSG:4326"}},"bbox":[1,1,4,4],"coordinates":[[1,1],[2,2],[3,3],[4,4]]}
+geojson_options_12|{"type":"LineString","crs":{"type":"name","properties":{"name":"urn:ogc:def:crs:EPSG:4326"}},"bbox":[1,1,4,4],"coordinates":[[1,1],[2,2],[3,3],[4,4]]}
+geojson_options_13|{"type":"LineString","crs":{"type":"name","properties":{"name":"urn:ogc:def:crs:EPSG:4326"}},"coordinates":[[1,1],[2,2],[3,3],[4,4]]}
+geojson_options_14|{"type":"LineString","crs":{"type":"name","properties":{"name":"urn:ogc:def:crs:EPSG:4326"}},"coordinates":[[1,1],[2,2],[3,3],[4,4]]}
+geojson_options_15|{"type":"LineString","crs":{"type":"name","properties":{"name":"urn:ogc:def:crs:EPSG:4326"}},"bbox":[1,1,4,4],"coordinates":[[1,1],[2,2],[3,3],[4,4]]}
+geojson_options_16|{"type":"LineString","crs":{"type":"name","properties":{"name":"urn:ogc:def:crs:EPSG:4326"}},"bbox":[1,1,4,4],"coordinates":[[1,1],[2,2],[3,3],[4,4]]}
--- /dev/null
+--
+-- spatial_ref_sys data
+--
+INSERT INTO "spatial_ref_sys" ("srid","auth_name","auth_srid","proj4text") VALUES (4326,'EPSG',4326,'+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs ');
+
+--- EPSG 1021892 : Bogota 1975 / Colombia Bogota zone (deprecated)
+INSERT INTO "spatial_ref_sys" ("srid", "proj4text") VALUES (1021892, '+proj=tmerc +lat_0=4.599047222222222 +lon_0=-74.08091666666667 +k=1.000000 +x_0=1000000 +y_0=1000000 +ellps=intl +towgs84=307,304,-318,0,0,0,0 +units=m +no_defs ');
+
+
+--
+-- GML
+--
+
+-- Empty Geometry
+SELECT 'gml_empty_geom', ST_AsGML(GeomFromEWKT(NULL));
+
+-- Precision
+SELECT 'gml_precision_01', ST_AsGML(GeomFromEWKT('SRID=4326;POINT(1.1111111 1.1111111)'), -2);
+SELECT 'gml_precision_02', ST_AsGML(GeomFromEWKT('SRID=4326;POINT(1.1111111 1.1111111)'), 19);
+
+-- Version
+SELECT 'gml_version_01', ST_AsGML(2, GeomFromEWKT('SRID=4326;POINT(1 1)'));
+SELECT 'gml_version_02', ST_AsGML(3, GeomFromEWKT('SRID=4326;POINT(1 1)'));
+SELECT 'gml_version_03', ST_AsGML(21, GeomFromEWKT('SRID=4326;POINT(1 1)'));
+SELECT 'gml_version_04', ST_AsGML(-4, GeomFromEWKT('SRID=4326;POINT(1 1)'));
+
+-- Option
+SELECT 'gml_option_01', ST_AsGML(2, GeomFromEWKT('SRID=4326;POINT(1 1)'), 0, 0);
+SELECT 'gml_option_02', ST_AsGML(3, GeomFromEWKT('SRID=4326;POINT(1 1)'), 0, 1);
+
+-- Deegree data
+SELECT 'gml_deegree_01', ST_AsGML(3, GeomFromEWKT('SRID=4326;POINT(1 2)'), 0, 0);
+SELECT 'gml_deegree_02', ST_AsGML(2, GeomFromEWKT('SRID=4326;POINT(1 2)'), 0, 16);
+SELECT 'gml_deegree_03', ST_AsGML(3, GeomFromEWKT('SRID=4326;POINT(1 2)'), 0, 16);
+SELECT 'gml_deegree_04', ST_AsGML(3, GeomFromEWKT('SRID=4326;POINT(1 2 3)'), 0, 0);
+SELECT 'gml_deegree_05', ST_AsGML(2, GeomFromEWKT('SRID=4326;POINT(1 2 3)'), 0, 16);
+SELECT 'gml_deegree_06', ST_AsGML(3, GeomFromEWKT('SRID=4326;POINT(1 2 3)'), 0, 16);
+
+
+--
+-- KML
+--
+
+-- SRID
+SELECT 'kml_srid_01', ST_AsKML(GeomFromEWKT('SRID=10;POINT(0 1)'));
+SELECT 'kml_srid_02', ST_AsKML(GeomFromEWKT('POINT(0 1)'));
+
+-- Empty Geometry
+SELECT 'kml_empty_geom', ST_AsKML(GeomFromEWKT(NULL));
+
+-- Precision
+SELECT 'kml_precision_01', ST_AsKML(ST_GeomFromEWKT('SRID=4326;POINT(1.1111111 1.1111111)'), -2);
+SELECT 'kml_precision_02', ST_AsKML(ST_GeomFromEWKT('SRID=4326;POINT(1.1111111 1.1111111)'), 19);
+
+-- Version
+SELECT 'kml_version_01', ST_AsKML(2, GeomFromEWKT('SRID=4326;POINT(1 1)'));
+SELECT 'kml_version_02', ST_AsKML(3, GeomFromEWKT('SRID=4326;POINT(1 1)'));
+SELECT 'kml_version_03', ST_AsKML(-4, GeomFromEWKT('SRID=4326;POINT(1 1)'));
+
+-- Projected
+-- National Astronomical Observatory of Colombia - Bogota, Colombia (Placemark)
+SELECT 'kml_projection_01', ST_AsKML(ST_GeomFromEWKT('SRID=1021892;POINT(1000000 1000000)'), 3);
+
+
+--
+-- SVG
+--
+
+-- Empty Geometry
+SELECT 'svg_empty_geom', ST_AsSVG(GeomFromEWKT(NULL));
+
+-- Option
+SELECT 'svg_option_01', ST_AsSVG(GeomFromEWKT('LINESTRING(1 1, 4 4, 5 7)'), 0);
+SELECT 'svg_option_02', ST_AsSVG(GeomFromEWKT('LINESTRING(1 1, 4 4, 5 7)'), 1);
+SELECT 'svg_option_03', ST_AsSVG(GeomFromEWKT('LINESTRING(1 1, 4 4, 5 7)'), 0, 0);
+SELECT 'svg_option_04', ST_AsSVG(GeomFromEWKT('LINESTRING(1 1, 4 4, 5 7)'), 1, 0);
+
+-- Precision
+SELECT 'svg_precision_01', ST_AsSVG(GeomFromEWKT('POINT(1.1111111 1.1111111)'), 1, -2);
+SELECT 'svg_precision_02', ST_AsSVG(GeomFromEWKT('POINT(1.1111111 1.1111111)'), 1, 19);
+
+
+--
+-- GeoJson
+--
+
+-- Empty Geometry
+SELECT 'geojson_empty_geom', ST_AsGeoJson(GeomFromEWKT(NULL));
+
+-- Precision
+SELECT 'geojson_precision_01', ST_AsGeoJson(GeomFromEWKT('SRID=4326;POINT(1.1111111 1.1111111)'), -2);
+SELECT 'geojson_precision_02', ST_AsGeoJson(GeomFromEWKT('SRID=4326;POINT(1.1111111 1.1111111)'), 19);
+
+-- Version
+SELECT 'geojson_version_01', ST_AsGeoJson(1, GeomFromEWKT('SRID=4326;POINT(1 1)'));
+SELECT 'geojson_version_02', ST_AsGeoJson(21, GeomFromEWKT('SRID=4326;POINT(1 1)'));
+SELECT 'geojson_version_03', ST_AsGeoJson(-4, GeomFromEWKT('SRID=4326;POINT(1 1)'));
+
+-- CRS
+SELECT 'geojson_crs_01', ST_AsGeoJson(GeomFromEWKT('SRID=4326;POINT(1 1)'), 0, 2);
+SELECT 'geojson_crs_02', ST_AsGeoJson(GeomFromEWKT('SRID=-1;POINT(1 1)'), 0, 2);
+SELECT 'geojson_crs_03', ST_AsGeoJson(GeomFromEWKT('SRID=4326;POINT(1 1)'), 0, 4);
+SELECT 'geojson_crs_04', ST_AsGeoJson(GeomFromEWKT('SRID=-1;POINT(1 1)'), 0, 4);
+SELECT 'geojson_crs_05', ST_AsGeoJson(GeomFromEWKT('SRID=1;POINT(1 1)'), 0, 2);
+SELECT 'geojson_crs_06', ST_AsGeoJson(GeomFromEWKT('SRID=1;POINT(1 1)'), 0, 4);
+
+-- Bbox
+SELECT 'geojson_bbox_01', ST_AsGeoJson(GeomFromEWKT('LINESTRING(1 1, 2 2, 3 3, 4 4)'), 0);
+SELECT 'geojson_bbox_02', ST_AsGeoJson(GeomFromEWKT('LINESTRING(1 1, 2 2, 3 3, 4 4)'), 0, 1);
+SELECT 'geojson_bbox_03', ST_AsGeoJson(GeomFromEWKT('LINESTRING(1 1, 2 2, 3 3, 4 4)'), 0, 3);
+SELECT 'geojson_bbox_04', ST_AsGeoJson(GeomFromEWKT('LINESTRING(1 1, 2 2, 3 3, 4 4)'), 0, 5);
+
+-- CRS and Bbox
+SELECT 'geojson_options_01', ST_AsGeoJson(GeomFromEWKT('SRID=-1;LINESTRING(1 1, 2 2, 3 3, 4 4)'), 0, 0);
+SELECT 'geojson_options_02', ST_AsGeoJson(GeomFromEWKT('SRID=4326;LINESTRING(1 1, 2 2, 3 3, 4 4)'), 0);
+SELECT 'geojson_options_03', ST_AsGeoJson(GeomFromEWKT('SRID=-1;LINESTRING(1 1, 2 2, 3 3, 4 4)'), 0, 1);
+SELECT 'geojson_options_04', ST_AsGeoJson(GeomFromEWKT('SRID=4326;LINESTRING(1 1, 2 2, 3 3, 4 4)'), 0, 1);
+SELECT 'geojson_options_05', ST_AsGeoJson(GeomFromEWKT('SRID=-1;LINESTRING(1 1, 2 2, 3 3, 4 4)'), 0, 2);
+SELECT 'geojson_options_06', ST_AsGeoJson(GeomFromEWKT('SRID=4326;LINESTRING(1 1, 2 2, 3 3, 4 4)'), 0, 2);
+SELECT 'geojson_options_07', ST_AsGeoJson(GeomFromEWKT('SRID=-1;LINESTRING(1 1, 2 2, 3 3, 4 4)'), 0, 3);
+SELECT 'geojson_options_08', ST_AsGeoJson(GeomFromEWKT('SRID=4326;LINESTRING(1 1, 2 2, 3 3, 4 4)'), 0, 3);
+SELECT 'geojson_options_09', ST_AsGeoJson(GeomFromEWKT('SRID=-1;LINESTRING(1 1, 2 2, 3 3, 4 4)'), 0, 4);
+SELECT 'geojson_options_10', ST_AsGeoJson(GeomFromEWKT('SRID=4326;LINESTRING(1 1, 2 2, 3 3, 4 4)'), 0, 4);
+SELECT 'geojson_options_11', ST_AsGeoJson(GeomFromEWKT('SRID=-1;LINESTRING(1 1, 2 2, 3 3, 4 4)'), 0, 5);
+SELECT 'geojson_options_12', ST_AsGeoJson(GeomFromEWKT('SRID=4326;LINESTRING(1 1, 2 2, 3 3, 4 4)'), 0, 5);
+SELECT 'geojson_options_13', ST_AsGeoJson(GeomFromEWKT('SRID=-1;LINESTRING(1 1, 2 2, 3 3, 4 4)'), 0, 6);
+SELECT 'geojson_options_14', ST_AsGeoJson(GeomFromEWKT('SRID=4326;LINESTRING(1 1, 2 2, 3 3, 4 4)'), 0, 6);
+SELECT 'geojson_options_15', ST_AsGeoJson(GeomFromEWKT('SRID=-1;LINESTRING(1 1, 2 2, 3 3, 4 4)'), 0, 7);
+SELECT 'geojson_options_16', ST_AsGeoJson(GeomFromEWKT('SRID=4326;LINESTRING(1 1, 2 2, 3 3, 4 4)'), 0, 7);
+
+
+--
+-- Delete inserted spatial data
+--
+DELETE FROM spatial_ref_sys;
--- /dev/null
+gml_empty_geom|
+gml_precision_01|<gml:Point srsName="EPSG:4326"><gml:coordinates>1,1</gml:coordinates></gml:Point>
+gml_precision_02|<gml:Point srsName="EPSG:4326"><gml:coordinates>1.1111111,1.1111111</gml:coordinates></gml:Point>
+gml_version_01|<gml:Point srsName="EPSG:4326"><gml:coordinates>1,1</gml:coordinates></gml:Point>
+gml_version_02|<gml:Point srsName="EPSG:4326"><gml:pos srsDimension="2">1 1</gml:pos></gml:Point>
+ERROR: Only GML 2 and GML 3 are supported
+ERROR: Only GML 2 and GML 3 are supported
+gml_option_01|<gml:Point srsName="EPSG:4326"><gml:coordinates>1,1</gml:coordinates></gml:Point>
+gml_option_02|<gml:Point srsName="urn:ogc:def:crs:EPSG:4326"><gml:pos srsDimension="2">1 1</gml:pos></gml:Point>
+gml_deegree_01|<gml:Point srsName="EPSG:4326"><gml:pos srsDimension="2">1 2</gml:pos></gml:Point>
+gml_deegree_02|<gml:Point srsName="EPSG:4326"><gml:coordinates>1,2</gml:coordinates></gml:Point>
+gml_deegree_03|<gml:Point srsName="EPSG:4326"><gml:pos srsDimension="2">2 1</gml:pos></gml:Point>
+gml_deegree_04|<gml:Point srsName="EPSG:4326"><gml:pos srsDimension="3">1 2 3</gml:pos></gml:Point>
+gml_deegree_05|<gml:Point srsName="EPSG:4326"><gml:coordinates>1,2,3</gml:coordinates></gml:Point>
+gml_deegree_06|<gml:Point srsName="EPSG:4326"><gml:pos srsDimension="3">2 1 3</gml:pos></gml:Point>
+ERROR: GetProj4StringSPI: Cannot find SRID (10) in spatial_ref_sys
+ERROR: Input geometry has unknown (-1) SRID
+kml_empty_geom|
+kml_precision_01|<Point><coordinates>1,1</coordinates></Point>
+kml_precision_02|<Point><coordinates>1.1111111,1.1111111</coordinates></Point>
+kml_version_01|<Point><coordinates>1,1</coordinates></Point>
+ERROR: Only KML 2 is supported
+ERROR: Only KML 2 is supported
+kml_projection_01|<Point><coordinates>-74.078,4.596</coordinates></Point>
+svg_empty_geom|
+svg_option_01|M 1 -1 L 4 -4 5 -7
+svg_option_02|M 1 -1 l 3 -3 1 -3
+svg_option_03|M 1 -1 L 4 -4 5 -7
+svg_option_04|M 1 -1 l 3 -3 1 -3
+svg_precision_01|x="1" y="-1"
+svg_precision_02|x="1.1111111" y="-1.1111111"
+geojson_empty_geom|
+geojson_precision_01|{"type":"Point","coordinates":[1,1]}
+geojson_precision_02|{"type":"Point","coordinates":[1.1111111,1.1111111]}
+geojson_version_01|{"type":"Point","coordinates":[1,1]}
+ERROR: Only GeoJSON 1 is supported
+ERROR: Only GeoJSON 1 is supported
+geojson_crs_01|{"type":"Point","crs":{"type":"name","properties":{"name":"EPSG:4326"}},"coordinates":[1,1]}
+geojson_crs_02|{"type":"Point","coordinates":[1,1]}
+geojson_crs_03|{"type":"Point","crs":{"type":"name","properties":{"name":"urn:ogc:def:crs:EPSG:4326"}},"coordinates":[1,1]}
+geojson_crs_04|{"type":"Point","coordinates":[1,1]}
+ERROR: SRID 1 unknown in spatial_ref_sys table
+ERROR: SRID 1 unknown in spatial_ref_sys table
+geojson_bbox_01|{"type":"LineString","coordinates":[[1,1],[2,2],[3,3],[4,4]]}
+geojson_bbox_02|{"type":"LineString","bbox":[1,1,4,4],"coordinates":[[1,1],[2,2],[3,3],[4,4]]}
+geojson_bbox_03|{"type":"LineString","bbox":[1,1,4,4],"coordinates":[[1,1],[2,2],[3,3],[4,4]]}
+geojson_bbox_04|{"type":"LineString","bbox":[1,1,4,4],"coordinates":[[1,1],[2,2],[3,3],[4,4]]}
+geojson_options_01|{"type":"LineString","coordinates":[[1,1],[2,2],[3,3],[4,4]]}
+geojson_options_02|{"type":"LineString","coordinates":[[1,1],[2,2],[3,3],[4,4]]}
+geojson_options_03|{"type":"LineString","bbox":[1,1,4,4],"coordinates":[[1,1],[2,2],[3,3],[4,4]]}
+geojson_options_04|{"type":"LineString","bbox":[1,1,4,4],"coordinates":[[1,1],[2,2],[3,3],[4,4]]}
+geojson_options_05|{"type":"LineString","coordinates":[[1,1],[2,2],[3,3],[4,4]]}
+geojson_options_06|{"type":"LineString","crs":{"type":"name","properties":{"name":"EPSG:4326"}},"coordinates":[[1,1],[2,2],[3,3],[4,4]]}
+geojson_options_07|{"type":"LineString","bbox":[1,1,4,4],"coordinates":[[1,1],[2,2],[3,3],[4,4]]}
+geojson_options_08|{"type":"LineString","crs":{"type":"name","properties":{"name":"EPSG:4326"}},"bbox":[1,1,4,4],"coordinates":[[1,1],[2,2],[3,3],[4,4]]}
+geojson_options_09|{"type":"LineString","coordinates":[[1,1],[2,2],[3,3],[4,4]]}
+geojson_options_10|{"type":"LineString","crs":{"type":"name","properties":{"name":"urn:ogc:def:crs:EPSG:4326"}},"coordinates":[[1,1],[2,2],[3,3],[4,4]]}
+geojson_options_11|{"type":"LineString","bbox":[1,1,4,4],"coordinates":[[1,1],[2,2],[3,3],[4,4]]}
+geojson_options_12|{"type":"LineString","crs":{"type":"name","properties":{"name":"urn:ogc:def:crs:EPSG:4326"}},"bbox":[1,1,4,4],"coordinates":[[1,1],[2,2],[3,3],[4,4]]}
+geojson_options_13|{"type":"LineString","coordinates":[[1,1],[2,2],[3,3],[4,4]]}
+geojson_options_14|{"type":"LineString","crs":{"type":"name","properties":{"name":"urn:ogc:def:crs:EPSG:4326"}},"coordinates":[[1,1],[2,2],[3,3],[4,4]]}
+geojson_options_15|{"type":"LineString","bbox":[1,1,4,4],"coordinates":[[1,1],[2,2],[3,3],[4,4]]}
+geojson_options_16|{"type":"LineString","crs":{"type":"name","properties":{"name":"urn:ogc:def:crs:EPSG:4326"}},"bbox":[1,1,4,4],"coordinates":[[1,1],[2,2],[3,3],[4,4]]}
+++ /dev/null
--- Empty Geometry
-SELECT 'empty_geom', ST_AsSVG(GeomFromEWKT(NULL));
-
--- Option
-SELECT 'option_01', ST_AsSVG(GeomFromEWKT('LINESTRING(1 1, 4 4, 5 7)'), 0);
-SELECT 'option_02', ST_AsSVG(GeomFromEWKT('LINESTRING(1 1, 4 4, 5 7)'), 1);
-SELECT 'option_03', ST_AsSVG(GeomFromEWKT('LINESTRING(1 1, 4 4, 5 7)'), 0, 0);
-SELECT 'option_04', ST_AsSVG(GeomFromEWKT('LINESTRING(1 1, 4 4, 5 7)'), 1, 0);
-
--- Precision
-SELECT 'precision_01', ST_AsSVG(GeomFromEWKT('POINT(1.1111111 1.1111111)'), 1, -2);
-SELECT 'precision_02', ST_AsSVG(GeomFromEWKT('POINT(1.1111111 1.1111111)'), 1, 19);
-
+++ /dev/null
-empty_geom|
-option_01|M 1 -1 L 4 -4 5 -7
-option_02|M 1 -1 l 3 -3 1 -3
-option_03|M 1 -1 L 4 -4 5 -7
-option_04|M 1 -1 l 3 -3 1 -3
-precision_01|x="1" y="-1"
-precision_02|x="1.1111111" y="-1.1111111"