]> granicus.if.org Git - postgis/commitdiff
Improve GeoJSON SRID handling.
authorDarafei Praliaskouski <me@komzpa.net>
Tue, 6 Aug 2019 19:15:24 +0000 (19:15 +0000)
committerDarafei Praliaskouski <me@komzpa.net>
Tue, 6 Aug 2019 19:15:24 +0000 (19:15 +0000)
If SRID is not specified, set it to 4326 by default on parsing, following RFC7946.
If SRID is not 4326 on serialization, it will be marked in JSON unless disabled, making round trips almost lossless.

Fixes spatial_ref_sys truncation in all the tests.
Closes #4377
Closes https://github.com/postgis/postgis/pull/455

git-svn-id: http://svn.osgeo.org/postgis/trunk@17678 b70326c6-7e19-0410-871a-916f4a2858ee

42 files changed:
NEWS
doc/reference_input.xml
doc/reference_output.xml
extras/ogc_test_suite/3_cleanup.sql
liblwgeom/liblwgeom.h.in
postgis/lwgeom_export.c
postgis/lwgeom_in_geojson.c
postgis/postgis.sql.in
postgis/postgis_after_upgrade.sql
raster/test/regress/loader/Projected-post.sql
raster/test/regress/loader/Projected-pre.sql
regress/core/geography.sql
regress/core/in_geojson.sql
regress/core/in_geojson_expected
regress/core/in_gml.sql
regress/core/in_kml.sql
regress/core/knn_recheck.sql
regress/core/legacy.sql
regress/core/out_geography.sql
regress/core/out_geography_expected
regress/core/out_geometry.sql
regress/core/out_geometry_expected
regress/core/regress_management.sql
regress/core/regress_proj.sql
regress/core/tickets.sql
regress/loader/ReprojectPts-post.sql
regress/loader/ReprojectPts-pre.sql
regress/loader/ReprojectPtsD-post.sql
regress/loader/ReprojectPtsD-pre.sql
regress/loader/ReprojectPtsGeog-post.sql
regress/loader/ReprojectPtsGeog-pre.sql
regress/loader/ReprojectPtsGeogD-post.sql
regress/loader/ReprojectPtsGeogD-pre.sql
regress/run_test.pl
topology/test/regress/copytopology.sql
topology/test/regress/gml.sql
topology/test/regress/st_createtopogeo.sql
topology/test/regress/st_modedgesplit.sql
topology/test/regress/st_newedgessplit.sql
topology/test/regress/st_remedgemodface.sql
topology/test/regress/st_remedgenewface.sql
topology/test/regress/topogeo_addlinestring.sql

diff --git a/NEWS b/NEWS
index e712de95726c173cc09405640418163323d6d4f3..3285489a15a2b5164fca70f37bb8bff7bc967138 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -197,8 +197,11 @@ Additional features enabled if you are running Proj6+ and PostgreSQL 12
   - #4410, More descriptive error messages about SRID mismatch (Darafei Praliaskouski)
   - #4399, TIN and Triangle output support in all output functions (Darafei
            Praliaskouski)
-  - #3719, Impose minimun number of segments per arc during linearization
+  - #3719, Impose minimum number of segments per arc during linearization
            (Dan Baston / City of Helsinki, Raúl Marín)
+  - #4277, ST_GeomFromGeoJSON now marks SRID=4326 by default as per RFC7946,
+           ST_AsGeoJSON sets SRID in JSON output if it differs from 4326.
+           (Darafei Praliaskouski)
 
 * Fixes *
   - #4342, Move deprecated functions into legacy.sql file
index 578d08e37ca9e2bdeec79a7d42f7b227036d0978..a275a00bb676e5d0851a877c9af4348b7f7d464e 100644 (file)
@@ -1544,6 +1544,7 @@ SELECT ST_AsText(ST_GeomFromGeoHash('9qqj7nmxncgyy4d0dbxqz0', 10));
                <para>Constructs a PostGIS geometry object from the GeoJSON representation.</para>
                <para>ST_GeomFromGeoJSON works only for JSON Geometry fragments. It throws an error if you try to use it on a whole JSON document.</para>
 
+               <para>Enhanced: 3.0.0 parsed geometry defaults to SRID=4326 if not specified otherwise.</para>
                <para>Enhanced: 2.5.0 can now accept json and jsonb as inputs.</para>
                <para>Availability: 2.0.0 requires - JSON-C &gt;= 0.9</para>
                <note><para>If you do not have JSON-C enabled, support you will get an error notice instead of seeing an output.
index 9fc4a53032da96741cdff1cfce1146fa373e32fe..a98999d68dd3775cf324c5e36be7e6fe156bbe8b 100644 (file)
@@ -555,7 +555,7 @@ POINT(111.11 1.11)
                                <funcdef>text <function>ST_AsGeoJSON</function></funcdef>
                                <paramdef><type>geometry </type> <parameter>geom</parameter></paramdef>
                                <paramdef choice="opt"><type>integer </type> <parameter>maxdecimaldigits=15</parameter></paramdef>
-                               <paramdef choice="opt"><type>integer </type> <parameter>options=0</parameter></paramdef>
+                               <paramdef choice="opt"><type>integer </type> <parameter>options=8</parameter></paramdef>
                        </funcprototype>
                        <funcprototype>
                                <funcdef>text <function>ST_AsGeoJSON</function></funcdef>
@@ -577,7 +577,7 @@ POINT(111.11 1.11)
                        <para>The <varname>options</varname> argument could be used to add BBOX or CRS in GeoJSON output:
                          <itemizedlist>
                                <listitem>
-                                 <para>0: means no option (default value)</para>
+                                 <para>0: means no option</para>
                                </listitem>
 
                                <listitem>
@@ -591,6 +591,10 @@ POINT(111.11 1.11)
                                <listitem>
                                  <para>4: GeoJSON Long CRS (e.g urn:ogc:def:crs:EPSG::4326)</para>
                                </listitem>
+
+                               <listitem>
+                                 <para>8: GeoJSON Short CRS if not EPSG:4326 (default)</para>
+                               </listitem>
                          </itemizedlist>
                        </para>
 
@@ -598,6 +602,7 @@ POINT(111.11 1.11)
                        <para>Availability: 1.5.0 geography support was introduced.</para>
                        <para>Changed: 2.0.0 support default args and named args.</para>
                        <para>Changed: 3.0.0 support records as input</para>
+                       <para>Changed: 3.0.0 output SRID if not EPSG:4326.</para>
                        <para>&Z_support;</para>
          </refsection>
 
index 3ccd9c3f8315f5764ed6f055e46ae5538bba2c80..8240dbd3c8a63c2dc1d32db14692099c2d48717f 100644 (file)
@@ -4,7 +4,7 @@
 -- OGC will not examine this script for adaptations.
 -- Please add any other cleanup to this script.
 --
-DELETE FROM spatial_ref_sys;
+--DELETE FROM spatial_ref_sys;
 DELETE FROM geometry_columns;
 DROP TABLE lakes;
 DROP TABLE road_segments;
index 11a93275ee75b96720cfcc3ca3f5c6b39776a56a..47573b63f747d69fe1fe11376474ff899bbd8437 100644 (file)
@@ -160,6 +160,7 @@ typedef enum LWORD_T {
 #define WGS84_INVERSE_FLATTENING 298.257223563
 #define WGS84_MINOR_AXIS (WGS84_MAJOR_AXIS - WGS84_MAJOR_AXIS / WGS84_INVERSE_FLATTENING)
 #define WGS84_RADIUS ((2.0 * WGS84_MAJOR_AXIS + WGS84_MINOR_AXIS ) / 3.0)
+#define WGS84_SRID 4326
 
 
 /**
index 7759b8970f10b5eff742db83f0b6800e80775ee7..fa30d5701bfd448e0173c7346d059d836fb35187 100644 (file)
@@ -354,15 +354,20 @@ Datum LWGEOM_asGeoJson(PG_FUNCTION_ARGS)
        LWGEOM *lwgeom;
        char *geojson;
        text *result;
-       int has_bbox = 0;
        int precision = DBL_DIG;
+       int output_bbox = LW_FALSE;
+       int output_long_crs = LW_FALSE;
+       int output_short_crs = LW_FALSE;
+       int output_guess_short_srid = LW_FALSE;
        char *srs = NULL;
+       int32_t srid;
 
        /* Get the geometry */
-       if ( PG_ARGISNULL(0) )
+       if (PG_ARGISNULL(0))
                PG_RETURN_NULL();
 
        geom = PG_GETARG_GSERIALIZED_P(0);
+       srid = gserialized_get_srid(geom);
 
        /* Retrieve precision if any (default is max) */
        if ( PG_NARGS() > 1 && !PG_ARGISNULL(1) )
@@ -375,42 +380,39 @@ Datum LWGEOM_asGeoJson(PG_FUNCTION_ARGS)
        }
 
        /* Retrieve output option
-        * 0 = without option (default)
+        * 0 = without option
         * 1 = bbox
         * 2 = short crs
         * 4 = long crs
+        * 8 = guess if CRS is needed (default)
         */
-       if ( PG_NARGS() > 2 && !PG_ARGISNULL(2) )
+       if (PG_NARGS() > 2 && !PG_ARGISNULL(2))
        {
                int option = PG_GETARG_INT32(2);
+               output_guess_short_srid = (option & 8) ? LW_TRUE : LW_FALSE;
+               output_short_crs = (option & 2) ? LW_TRUE : LW_FALSE;
+               output_long_crs = (option & 4) ? LW_TRUE : LW_FALSE;
+               output_bbox = (option & 1) ? LW_TRUE : LW_FALSE;
+       }
+       else
+               output_guess_short_srid = LW_TRUE;
 
-               if ( option & 2 || option & 4 )
+       if (output_guess_short_srid && srid != WGS84_SRID && srid != SRID_UNKNOWN)
+               output_short_crs = LW_TRUE;
+
+       if (srid != SRID_UNKNOWN && (output_short_crs || output_long_crs))
+       {
+               srs = getSRSbySRID(srid, !output_long_crs);
+
+               if (!srs)
                {
-                       int32_t srid = gserialized_get_srid(geom);
-                       if ( srid != SRID_UNKNOWN )
-                       {
-                               if ( option & 2 )
-                                       srs = getSRSbySRID(srid, true);
-
-                               if ( option & 4 )
-                                       srs = getSRSbySRID(srid, false);
-
-                               if ( !srs )
-                               {
-                                       elog(ERROR,
-                                             "SRID %i unknown in spatial_ref_sys table",
-                                             srid);
-                                       PG_RETURN_NULL();
-                               }
-                       }
+                       elog(ERROR, "SRID %i unknown in spatial_ref_sys table", srid);
+                       PG_RETURN_NULL();
                }
-
-               if (option & 1)
-                       has_bbox = 1;
        }
 
        lwgeom = lwgeom_from_gserialized(geom);
-       geojson = lwgeom_to_geojson(lwgeom, srs, precision, has_bbox);
+       geojson = lwgeom_to_geojson(lwgeom, srs, precision, output_bbox);
        lwgeom_free(lwgeom);
 
        if (srs) pfree(srs);
index c39d9dd5e41f0966af4b624ddf395f85e84d7324..9d8bd77506b718b5b6686425c9149f1da8823105 100644 (file)
@@ -91,6 +91,7 @@ Datum geom_from_geojson(PG_FUNCTION_ARGS)
        text *geojson_input;
        char *geojson;
        char *srs = NULL;
+       int32_t srid = WGS84_SRID;
 
        /* Get the geojson stream */
        if (PG_ARGISNULL(0))
@@ -100,23 +101,23 @@ Datum geom_from_geojson(PG_FUNCTION_ARGS)
        geojson = text2cstring(geojson_input);
 
        lwgeom = lwgeom_from_geojson(geojson, &srs);
-       if ( ! lwgeom )
+       if (!lwgeom)
        {
                /* Shouldn't get here */
                elog(ERROR, "lwgeom_from_geojson returned NULL");
                PG_RETURN_NULL();
        }
 
-       if ( srs )
+       if (srs)
        {
-               lwgeom_set_srid(lwgeom, getSRIDbySRS(srs));
+               srid = getSRIDbySRS(srs);
                lwfree(srs);
        }
 
+       lwgeom_set_srid(lwgeom, srid);
        geom = geometry_serialize(lwgeom);
        lwgeom_free(lwgeom);
 
        PG_RETURN_POINTER(geom);
 #endif
 }
-
index bebef6444053728ecbbc8bd2215239bd7244b5da..140efb6828f97211e1015f6da252f1b1f89ddccf 100644 (file)
@@ -4600,8 +4600,9 @@ CREATE OR REPLACE FUNCTION ST_AsKML(geom geometry, maxdecimaldigits int4 DEFAULT
 -----------------------------------------------------------------------
 
 -- ST_AsGeoJson(geom, precision, options) / version=1
--- Changed 2.0.0 to use default args and named args
-CREATE OR REPLACE FUNCTION ST_AsGeoJson(geom geometry, maxdecimaldigits int4 DEFAULT 15, options int4 DEFAULT 0)
+-- Changed: 2.0.0 to use default args and named args
+-- Changed: 3.0.0 change default args mode
+CREATE OR REPLACE FUNCTION ST_AsGeoJson(geom geometry, maxdecimaldigits int4 DEFAULT 15, options int4 DEFAULT 8)
        RETURNS text
        AS 'MODULE_PATHNAME','LWGEOM_asGeoJson'
        LANGUAGE 'c' IMMUTABLE STRICT _PARALLEL
index 41797174c53f0086f373b81a8f200311769b4ebb..fc46e1c49819d431c2e8b9f917627a699f4b2c25 100644 (file)
@@ -62,8 +62,8 @@ DROP FUNCTION IF EXISTS ST_AsGeoJson(geometry, int4); -- this one changed to use
 DROP FUNCTION IF EXISTS ST_AsGeoJson(geography, int4); -- this one changed to use default args
 DROP FUNCTION IF EXISTS ST_AsGeoJson(int4, geometry); -- this one changed to use default args
 DROP FUNCTION IF EXISTS ST_AsGeoJson(int4, geography); -- this one changed to use default args
-DROP FUNCTION IF EXISTS ST_AsGeoJson(int4, geometry,int4); -- this one changed to use default args
-DROP FUNCTION IF EXISTS ST_AsGeoJson(int4, geography,int4); -- this one changed to use default args
+DROP FUNCTION IF EXISTS ST_AsGeoJson(int4, geometry, int4); -- this one changed to use default args
+DROP FUNCTION IF EXISTS ST_AsGeoJson(int4, geography, int4); -- this one changed to use default args
 DROP FUNCTION IF EXISTS ST_AsGeoJson(int4, geography, int4, int4); -- dropped because the version-first signature is dumb
 DROP FUNCTION IF EXISTS _ST_AsGeoJson(int4, geometry, int4, int4); -- dropped in PostGIS-3.0 (r17300)
 DROP FUNCTION IF EXISTS _ST_AsGeoJson(int4, geography, int4, int4); -- dropped in PostGIS-3.0 (r17300)
index 2fc7692e69c90565626a7c5ff9a0488eccdf1386..dfbc6c47f6263eb3687cd1123f7d3fa247089a9a 100644 (file)
@@ -1,4 +1,2 @@
-TRUNCATE spatial_ref_sys;
--- should this be done automatically ?
 -- "loadedrast" is removed automatically !
 DROP TABLE o_2_loadedrast;
index 61918bd1de5ee2b863d9e3f6de6cf4d2be715958..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,8 +0,0 @@
--- NOTE: the need for truncation here reveals a leak bug in previous tests
-TRUNCATE spatial_ref_sys;
-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"]],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 ')
-,
-('3857','EPSG','3857','PROJCS["WGS 84 / Pseudo-Mercator",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]],UNIT["metre",1,AUTHORITY["EPSG","9001"]],PROJECTION["Mercator_1SP"],PARAMETER["central_meridian",0],PARAMETER["scale_factor",1],PARAMETER["false_easting",0],PARAMETER["false_northing",0],EXTENSION["PROJ4","+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext  +no_defs"],AUTHORITY["EPSG","3857"],AXIS["X",EAST],AXIS["Y",NORTH]]','+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext  +no_defs')
-;
index 409437ac50e53edb3661c4c512185dd815efcde3..f17bcdfec91f1fb8d4b7103bc23022d798aca255 100644 (file)
@@ -1,21 +1,3 @@
-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"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]]',
- '+proj=longlat +datum=WGS84 +no_defs'
-);
-
-INSERT INTO spatial_ref_sys (srid, auth_name, auth_srid, srtext, proj4text)
-VALUES (
- '4269',
- 'EPSG',
- '4269',
- 'GEOGCS["NAD83",DATUM["North_American_Datum_1983",SPHEROID["GRS 1980",6378137,298.257222101,AUTHORITY["EPSG","7019"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6269"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4269"]]',
- '+proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +no_defs'
-);
-
 -- Do cached and uncached distance agree?
 SELECT c, abs(ST_Distance(ply::geography, pt::geography) - _ST_DistanceUnCached(ply::geography, pt::geography)) < 0.01 FROM
 ( VALUES
@@ -142,6 +124,3 @@ select 'dwithin_poly_line_1', ST_DWithin('POLYGON((1 1, 2 2, 3 0, 1 1))'::geogra
 select 'dwithin_poly_poly_1', ST_DWithin('POLYGON((0 0, -2 -2, -3 0, 0 0))'::geography, 'POLYGON((1 1, 2 2, 3 0, 1 1))'::geography, 10);
 select 'dwithin_poly_poly_2', ST_DWithin('POLYGON((0 0, -2 -2, -3 0, 0 0))'::geography, 'POLYGON((1 1, 2 2, 3 0, 1 1))'::geography, 300000);
 select 'dwithin_poly_poly_3', ST_DWithin('POLYGON((1 1, -2 -2, -3 0, 1 1))'::geography, 'POLYGON((1 1, 2 2, 3 0, 1 1))'::geography, 300000);
-
--- Clean up spatial_ref_sys
-DELETE FROM spatial_ref_sys WHERE srid IN (4269, 4326);
index f3b6fede127bb99d761ae145b06e197c3e8e3244..df6b7d672a0e6fc843802ac9783c1e94d5d6550c 100644 (file)
@@ -1,12 +1,13 @@
 -- FromGeoJSON
-select 'geomfromgeojson_01',st_asewkt(st_geomfromgeojson(st_asgeojson('SRID=3005;MULTIPOINT(1 1, 1 1)')));
-select 'geomfromgeojson_02',st_astext(st_geomfromgeojson(st_asgeojson('SRID=3005;MULTIPOINT(1 1, 1 1)')));
-select 'geomfromgeojson_03',st_astext(st_geomfromgeojson(st_asgeojson('POINT(1 1)')));
-select 'geomfromgeojson_04',st_astext(st_geomfromgeojson(st_asgeojson('LINESTRING(0 0,1 1)')));
-select 'geomfromgeojson_05',st_astext(st_geomfromgeojson(st_asgeojson('POLYGON((0 0,1 1,1 0,0 0))')));
-select 'geomfromgeojson_06',st_astext(st_geomfromgeojson(st_asgeojson('MULTIPOLYGON(((0 0,1 1,1 0,0 0)))')));
-select 'geomfromgeojson_07',st_astext(st_geomfromgeojson(st_asgeojson('MULTIPOLYGON(((0 0,1 1,1 0,0 0)))')::json));
-select 'geomfromgeojson_08',st_astext(st_geomfromgeojson(st_asgeojson('MULTIPOLYGON(((0 0,1 1,1 0,0 0)))')::jsonb));
+select 'geomfromgeojson_01',st_asewkt(st_geomfromgeojson(st_asgeojson('SRID=3005;MULTIPOINT(1 1, 1 1)'::geometry)));
+select 'geomfromgeojson_02',st_astext(st_geomfromgeojson(st_asgeojson('SRID=3005;MULTIPOINT(1 1, 1 1)'::geometry)));
+select 'geomfromgeojson_03',st_astext(st_geomfromgeojson(st_asgeojson('POINT(1 1)'::geometry)));
+select 'geomfromgeojson_04',st_astext(st_geomfromgeojson(st_asgeojson('LINESTRING(0 0,1 1)'::geometry)));
+select 'geomfromgeojson_05',st_astext(st_geomfromgeojson(st_asgeojson('POLYGON((0 0,1 1,1 0,0 0))'::geometry)));
+select 'geomfromgeojson_06',st_astext(st_geomfromgeojson(st_asgeojson('MULTIPOLYGON(((0 0,1 1,1 0,0 0)))'::geometry)));
+select 'geomfromgeojson_07',st_astext(st_geomfromgeojson(st_asgeojson('MULTIPOLYGON(((0 0,1 1,1 0,0 0)))'::geometry)::json));
+select 'geomfromgeojson_08',st_astext(st_geomfromgeojson(st_asgeojson('MULTIPOLYGON(((0 0,1 1,1 0,0 0)))'::geometry)::jsonb));
+select 'geomfromgeojson_09',st_asewkt(st_geomfromgeojson(st_asgeojson('SRID=3005;MULTIPOINT(1 1, 1 1)'::geography)));
 -- #1434
 select '#1434: Next two errors';
 select '#1434.1',ST_GeomFromGeoJSON('{ "type": "Point", "crashme": [100.0, 0.0] }');
@@ -33,19 +34,19 @@ SELECT '#2697', ST_GeomFromGeoJSON('{"type":"Polygon","coordinates":[1]}');
 SELECT '#2697', ST_GeomFromGeoJSON('{"type":"Polygon","coordinates":[1,1]}');
 
 -- FromGeoJSON 3D
-
 SELECT 'geomfromgeojson_z_01', ST_AsEWKT(ST_GeomFromGeoJSON('{"type":"Point","coordinates":[1,2,3]}'));
 SELECT 'geomfromgeojson_z_02', ST_AsEWKT(ST_GeomFromGeoJSON('{"type":"LineString","coordinates":[[1,2,3],[2,3,4]]}'));
 
 -- FromGeoJSON 4D
-
 SELECT 'geomfromgeojson_zm_01', ST_AsEWKT(ST_GeomFromGeoJSON('{"type":"Point","coordinates":[1,2,3,4]}'));
 SELECT 'geomfromgeojson_zm_02', ST_AsEWKT(ST_GeomFromGeoJSON('{"type":"LineString","coordinates":[[1,2,3,4],[2,3,4,5]]}'));
 
-SELECT 'geomfromgeojson_srs_1', ST_AsEWKT(ST_GeomFromGeoJSON('{"type":"GeometryCollection","geometries":[{"type":"Point","coordinates":[100.0,0.0]},{"type":"LineString","coordinates":[[101.0,0.0],[102.0,1.0]]}],"crs":{"type":"name","properties":{"name":"urn:ogc:def:crs:EPSG::4326"}}}'));
-SELECT 'geomfromgeojson_srs_2', ST_AsEWKT(ST_GeomFromGeoJSON('{"type":"GeometryCollection","geometries":[{"type":"Point","coordinates":[100.0,0.0]},{"type":"LineString","coordinates":[[101.0,0.0],[102.0,1.0]]}],"crs":{"type":"name","properties":{"name":"EPSG:4326"}}}'));
-SELECT 'geomfromgeojson_srs_3', ST_AsEWKT(ST_GeomFromGeoJSON('{"type":"GeometryCollection","geometries":[{"type":"Point","coordinates":[100.0,0.0]},{"type":"LineString","coordinates":[[101.0,0.0],[102.0,1.0]]}],"crs":{"type":"name","props":{"name":"urn:ogc:def:crs:EPSG::4326"}}}'));
-SELECT 'geomfromgeojson_srs_4', ST_AsEWKT(ST_GeomFromGeoJSON('{"type":"GeometryCollection","geometries":[{"type":"Point","coordinates":[100.0,0.0]},{"type":"LineString","coordinates":[[101.0,0.0],[102.0,1.0]]}],"crs":{"type":"name","properties":{"nm":"EPSG:4326"}}}'));
+-- correct srs
+SELECT 'geomfromgeojson_srs_1', ST_AsEWKT(ST_GeomFromGeoJSON('{"type":"GeometryCollection","geometries":[{"type":"Point","coordinates":[100.0,0.0]},{"type":"LineString","coordinates":[[101.0,0.0],[102.0,1.0]]}],"crs":{"type":"name","properties":{"name":"urn:ogc:def:crs:EPSG::3395"}}}'));
+SELECT 'geomfromgeojson_srs_2', ST_AsEWKT(ST_GeomFromGeoJSON('{"type":"GeometryCollection","geometries":[{"type":"Point","coordinates":[100.0,0.0]},{"type":"LineString","coordinates":[[101.0,0.0],[102.0,1.0]]}],"crs":{"type":"name","properties":{"name":"EPSG:3395"}}}'));
+-- bad srs
+SELECT 'geomfromgeojson_srs_3', ST_AsEWKT(ST_GeomFromGeoJSON('{"type":"GeometryCollection","geometries":[{"type":"Point","coordinates":[100.0,0.0]},{"type":"LineString","coordinates":[[101.0,0.0],[102.0,1.0]]}],"crs":{"type":"name","props":{"name":"urn:ogc:def:crs:EPSG::3395"}}}'));
+SELECT 'geomfromgeojson_srs_4', ST_AsEWKT(ST_GeomFromGeoJSON('{"type":"GeometryCollection","geometries":[{"type":"Point","coordinates":[100.0,0.0]},{"type":"LineString","coordinates":[[101.0,0.0],[102.0,1.0]]}],"crs":{"type":"name","properties":{"nm":"EPSG:3395"}}}'));
 
 SELECT '#3583', ST_AsText(ST_GeomFromGeoJSON('{"type":"MultiPolygon", "coordinates":[[[139.10030364990232,35.16777444430609],5842.4224490305424]]}'));
 SELECT '#4164', ST_AsText(ST_GeomFromGeoJSON('{"type": "Polygon", "coordinates": [[0,0],[0,5],[5, 5],[5,0],[0,0]]}'));
index ad807b1c3ac7bab0708956f746fc8a2f370aadfe..0a0e7de1d4eecf695a731b79ab92550bdc35a80c 100644 (file)
@@ -1,4 +1,4 @@
-geomfromgeojson_01|MULTIPOINT(1 1,1 1)
+geomfromgeojson_01|SRID=3005;MULTIPOINT(1 1,1 1)
 geomfromgeojson_02|MULTIPOINT(1 1,1 1)
 geomfromgeojson_03|POINT(1 1)
 geomfromgeojson_04|LINESTRING(0 0,1 1)
@@ -6,6 +6,7 @@ geomfromgeojson_05|POLYGON((0 0,1 1,1 0,0 0))
 geomfromgeojson_06|MULTIPOLYGON(((0 0,1 1,1 0,0 0)))
 geomfromgeojson_07|MULTIPOLYGON(((0 0,1 1,1 0,0 0)))
 geomfromgeojson_08|MULTIPOLYGON(((0 0,1 1,1 0,0 0)))
+ERROR:  Only lon/lat coordinate systems are supported in geography. at character 71
 #1434: Next two errors
 ERROR:  Unable to find 'coordinates' in GeoJSON string
 ERROR:  unexpected character (at offset 0)
@@ -21,14 +22,14 @@ ERROR:  Unable to find 'coordinates' in GeoJSON string
 #2619|MULTIPOLYGON EMPTY
 ERROR:  The 'coordinates' in GeoJSON ring are not an array
 ERROR:  The 'coordinates' in GeoJSON ring are not an array
-geomfromgeojson_z_01|POINT(1 2 3)
-geomfromgeojson_z_02|LINESTRING(1 2 3,2 3 4)
-geomfromgeojson_zm_01|POINT(1 2 3)
-geomfromgeojson_zm_02|LINESTRING(1 2 3,2 3 4)
-geomfromgeojson_srs_1|GEOMETRYCOLLECTION(POINT(100 0),LINESTRING(101 0,102 1))
-geomfromgeojson_srs_2|GEOMETRYCOLLECTION(POINT(100 0),LINESTRING(101 0,102 1))
-geomfromgeojson_srs_3|GEOMETRYCOLLECTION(POINT(100 0),LINESTRING(101 0,102 1))
-geomfromgeojson_srs_4|GEOMETRYCOLLECTION(POINT(100 0),LINESTRING(101 0,102 1))
+geomfromgeojson_z_01|SRID=4326;POINT(1 2 3)
+geomfromgeojson_z_02|SRID=4326;LINESTRING(1 2 3,2 3 4)
+geomfromgeojson_zm_01|SRID=4326;POINT(1 2 3)
+geomfromgeojson_zm_02|SRID=4326;LINESTRING(1 2 3,2 3 4)
+geomfromgeojson_srs_1|SRID=3395;GEOMETRYCOLLECTION(POINT(100 0),LINESTRING(101 0,102 1))
+geomfromgeojson_srs_2|SRID=3395;GEOMETRYCOLLECTION(POINT(100 0),LINESTRING(101 0,102 1))
+geomfromgeojson_srs_3|SRID=4326;GEOMETRYCOLLECTION(POINT(100 0),LINESTRING(101 0,102 1))
+geomfromgeojson_srs_4|SRID=4326;GEOMETRYCOLLECTION(POINT(100 0),LINESTRING(101 0,102 1))
 ERROR:  The 'coordinates' in GeoJSON are not sufficiently nested
 ERROR:  The 'coordinates' in GeoJSON are not sufficiently nested
 #4470.a|POLYGON((0 0))
index aca18fdd7af53b34f1abe93356e7e548237eff2b..4ff83a0eb7c4e3a11fca9f622beb57c0d650419f 100644 (file)
@@ -3,19 +3,6 @@
 -- Written by Olivier Courtin - Oslandia
 --
 
---
--- spatial_ref_sys datas
---
-
--- EPSG 4326 : WGS 84
-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 ');
-
---- EPSG 27562 : NTF (Paris) / Lambert Centre France
-INSERT INTO "spatial_ref_sys" ("srid","auth_name","auth_srid","srtext","proj4text") VALUES (27562,'EPSG',27562,'PROJCS["NTF (Paris) / Lambert Centre France",GEOGCS["NTF (Paris)",DATUM["Nouvelle_Triangulation_Francaise_Paris",SPHEROID["Clarke 1880 (IGN)",6378249.2,293.4660212936265,AUTHORITY["EPSG","7011"]],TOWGS84[-168,-60,320,0,0,0,0],AUTHORITY["EPSG","6807"]],PRIMEM["Paris",2.33722917,AUTHORITY["EPSG","8903"]],UNIT["grad",0.01570796326794897,AUTHORITY["EPSG","9105"]],AUTHORITY["EPSG","4807"]],UNIT["metre",1,AUTHORITY["EPSG","9001"]],PROJECTION["Lambert_Conformal_Conic_1SP"],PARAMETER["latitude_of_origin",52],PARAMETER["central_meridian",0],PARAMETER["scale_factor",0.99987742],PARAMETER["false_easting",600000],PARAMETER["false_northing",200000],AUTHORITY["EPSG","27562"],AXIS["X",EAST],AXIS["Y",NORTH]]','+proj=lcc +lat_1=46.8 +lat_0=46.8 +lon_0=0 +k_0=0.99987742 +x_0=600000 +y_0=200000 +a=6378249.2 +b=6356515 +towgs84=-168,-60,320,0,0,0,0 +pm=paris +units=m +no_defs ');
-
---- EPSG 27582 : NTF (Paris) / France II (deprecated)
-INSERT INTO "spatial_ref_sys" ("srid","auth_name","auth_srid","srtext","proj4text") VALUES (27582,'EPSG',27582,'PROJCS["NTF (Paris) / France II (deprecated)",GEOGCS["NTF (Paris)",DATUM["Nouvelle_Triangulation_Francaise_Paris",SPHEROID["Clarke 1880 (IGN)",6378249.2,293.4660212936265,AUTHORITY["EPSG","7011"]],TOWGS84[-168,-60,320,0,0,0,0],AUTHORITY["EPSG","6807"]],PRIMEM["Paris",2.33722917,AUTHORITY["EPSG","8903"]],UNIT["grad",0.01570796326794897,AUTHORITY["EPSG","9105"]],AUTHORITY["EPSG","4807"]],UNIT["metre",1,AUTHORITY["EPSG","9001"]],PROJECTION["Lambert_Conformal_Conic_1SP"],PARAMETER["latitude_of_origin",52],PARAMETER["central_meridian",0],PARAMETER["scale_factor",0.99987742],PARAMETER["false_easting",600000],PARAMETER["false_northing",2200000],AUTHORITY["EPSG","27582"],AXIS["X",EAST],AXIS["Y",NORTH]]','+proj=lcc +lat_1=46.8 +lat_0=46.8 +lon_0=0 +k_0=0.99987742 +x_0=600000 +y_0=2200000 +a=6378249.2 +b=6356515 +towgs84=-168,-60,320,0,0,0,0 +pm=paris +units=m +no_defs ');
-
 -- Empty Geometry
 SELECT 'empty_geom', ST_AsEWKT(ST_GeomFromGML(NULL));
 
@@ -1260,10 +1247,3 @@ SELECT 'double_30', ST_AsEWKT(ST_GeomFromGML('<gml:Point><gml:pos>1 -1.23E 2</gm
 
 -- ERROR: Junk
 SELECT 'double_31', ST_AsEWKT(ST_GeomFromGML('<gml:Point><gml:pos>1 $0%@#$^%#</gml:pos></gml:Point>'));
-
---
--- Delete inserted spatial data
---
-DELETE FROM spatial_ref_sys WHERE srid = 4326;
-DELETE FROM spatial_ref_sys WHERE srid = 27562;
-DELETE FROM spatial_ref_sys WHERE srid = 27582;
index 1b40f903414a26339303421e3c4ad4fb7f71bb9a..f0c5f2f41e60ee2da7a4ad7f0cfd0070eb0c3a18 100644 (file)
@@ -2,14 +2,6 @@
 -- GeomFromKML regression test
 -- Written by Olivier Courtin - Oslandia
 --
-
---
--- spatial_ref_sys datas
---
-
--- EPSG 4326 : WGS 84
-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_AsEWKT(ST_GeomFromKML(NULL));
 
@@ -328,8 +320,3 @@ SELECT 'double_31', ST_AsEWKT(ST_GeomFromKML('<kml:Point><kml:coordinates>1,$0%@
 -- ERROR: mixed coordinate dimension
 SELECT 'mixed_dims_1', ST_AsEWKT(ST_GeomFromKML('<kml:Point><kml:coordinates>1,2 1,2,3</kml:coordinates></kml:Point>'));
 SELECT 'mixed_dims_2', ST_AsEWKT(ST_GeomFromKML('<kml:Point><kml:coordinates>1,2,3 1,2</kml:coordinates></kml:Point>'));
-
---
--- Delete inserted spatial data
---
-DELETE FROM spatial_ref_sys WHERE srid = 4326;
index 0c2ebc6ba0c40dd4260bf804821897d9a850d307..313bb80e39b452a4f7d5f7467c8823e74be3faf1 100644 (file)
@@ -65,10 +65,6 @@ ORDER BY a.gid, true_rn, b.gid;
 
 DROP TABLE knn_recheck_geom;
 
--- geography tests
-DELETE FROM spatial_ref_sys where srid = 4326;
-INSERT INTO "spatial_ref_sys" ("srid","auth_name","auth_srid","proj4text")
-    VALUES (4326,'EPSG',4326,'+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs ');
 -- create table
 CREATE TABLE knn_recheck_geog(gid serial primary key, geog geography);
 INSERT INTO knn_recheck_geog(gid,geog)
@@ -130,11 +126,6 @@ ORDER BY a.gid;
 
 DROP TABLE knn_recheck_geog;
 
---
--- Delete inserted spatial data
---
-DELETE FROM spatial_ref_sys WHERE srid = 4326;
-
 --now the nd operator tests
 -- create table and load
 CREATE TABLE knn_recheck_geom_nd(gid serial primary key, geom geometry);
index 57bd4ab27f62d01f7d551a43c9fa6e1171bb8496..fa148cf71bd005a3871126e4e64862d033db0c80 100644 (file)
@@ -11,9 +11,6 @@ SET client_min_messages TO WARNING;
 \cd :scriptdir
 \i legacy.sql
 
-TRUNCATE spatial_ref_sys;
-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 ');
-
 SELECT 'Starting up MapServer/Geoserver tests...';
 -- Set up the data table
 SELECT 'Setting up the data table...';
@@ -54,6 +51,4 @@ SELECT 'Done.';
 -- test #1869 ST_AsBinary is not unique --
 SELECT 1869 As ticket_id, ST_AsText(ST_AsBinary('POINT(1 2)'));
 
-DELETE FROM spatial_ref_sys WHERE SRID = '4326';
-
 \i uninstall_legacy.sql
index a104733361f787145b03c121982303461fad58c4..d6e848e897f5fa1639dc8764b65c1055d07ff1ae 100644 (file)
@@ -1,14 +1,3 @@
-
---
--- spatial_ref_sys data
---
-
-TRUNCATE spatial_ref_sys;
-
-INSERT INTO "spatial_ref_sys" ("srid","auth_name","auth_srid","proj4text") VALUES (4326,'EPSG',4326,'+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs ');
-
-INSERT INTO "spatial_ref_sys" ("srid", "proj4text") VALUES (102189, '+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
 --
@@ -64,9 +53,7 @@ SELECT 'kml_empty_geom', ST_AsKML(geography(ST_GeomFromEWKT(NULL)));
 SELECT 'kml_precision_01', ST_AsKML(geography(ST_GeomFromEWKT('SRID=4326;POINT(1.1111111 1.1111111)')), -2);
 SELECT 'kml_precision_02', ST_AsKML(geography(ST_GeomFromEWKT('SRID=4326;POINT(1.1111111 1.1111111)')), 19);
 
--- Projected
--- National Astronomical Observatory of Colombia - Bogota, Colombia (Placemark)
-SELECT 'kml_projection_01', ST_AsKML(geography(ST_GeomFromEWKT('SRID=102189;POINT(1000000 1000000)')), 3);
+-- Projected -- there's no projected geography
 
 --
 -- SVG
@@ -135,9 +122,3 @@ SELECT 'geojson_options_16', ST_AsGeoJSON(geography(ST_GeomFromEWKT('SRID=4326;L
 -- Precision
 SELECT 'text_precision_01', ST_AsText(geography(GeomFromEWKT('SRID=4326;POINT(111.1111111 1.1111111)')));
 SELECT 'text_precision_02', ST_AsText(geography(GeomFromEWKT('SRID=4326;POINT(111.1111111 1.1111111)')),2);
-
-
---
--- Delete inserted spatial data
---
-DELETE FROM spatial_ref_sys;
index da95beee478729191e55147588784799714e8ca6..aee87b7b5582e3790fdf1036c5d3698317cc963a 100644 (file)
@@ -25,7 +25,6 @@ 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>
-ERROR:  Only lon/lat coordinate systems are 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
index c2b4ee93d24f359e17bdc6d871a5e2a962c3e36a..fdc9a5cd6c2ba594dcfdadd00f220324b6420fcb 100644 (file)
@@ -1,12 +1,3 @@
---
--- spatial_ref_sys data
---
-DELETE FROM "spatial_ref_sys";
-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 (102189, '+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
 --
@@ -81,7 +72,7 @@ SELECT 'kml_prefix_02', ST_AsKML(ST_GeomFromEWKT('SRID=4326;POINT(1 2)'), 0, 'km
 
 -- Projected
 -- National Astronomical Observatory of Colombia - Bogota, Colombia (Placemark)
-SELECT 'kml_projection_01', ST_AsKML(ST_GeomFromEWKT('SRID=102189;POINT(1000000 1000000)'), 3);
+SELECT 'kml_projection_01', ST_AsKML(ST_GeomFromEWKT('SRID=3116;POINT(1000000 1000000)'), 3);
 
 --
 -- Encoded Polyline
@@ -129,6 +120,7 @@ SELECT 'geojson_crs_03', ST_AsGeoJSON(ST_GeomFromEWKT('SRID=4326;POINT(1 1)'), 0
 SELECT 'geojson_crs_04', ST_AsGeoJSON(ST_GeomFromEWKT('SRID=0;POINT(1 1)'), 0, 4);
 SELECT 'geojson_crs_05', ST_AsGeoJSON(ST_GeomFromEWKT('SRID=1;POINT(1 1)'), 0, 2);
 SELECT 'geojson_crs_06', ST_AsGeoJSON(ST_GeomFromEWKT('SRID=1;POINT(1 1)'), 0, 4);
+SELECT 'geojson_crs_07', ST_AsGeoJSON(ST_GeomFromEWKT('SRID=3005;POINT(1 1)'));
 
 -- Bbox
 SELECT 'geojson_bbox_01', ST_AsGeoJSON(ST_GeomFromEWKT('LINESTRING(1 1, 2 2, 3 3, 4 4)'), 0);
@@ -174,9 +166,3 @@ SELECT 'pgcast_06',ST_AsText('((0,0),(0,1),(1,1),(1,0))'::polygon::geometry);
 -- Precision
 SELECT 'text_precision_01', ST_AsText(GeomFromEWKT('SRID=4326;POINT(111.1111111 1.1111111)'));
 SELECT 'text_precision_02', ST_AsText(GeomFromEWKT('SRID=4326;POINT(111.1111111 1.1111111)'),2);
-
-
---
--- Delete inserted spatial data
---
-DELETE FROM spatial_ref_sys;
index 2ca30956814c41fc92181b7986c7c96cf1ae2fed..470720693939ee2854003fea86a23112bc8f6da0 100644 (file)
@@ -60,6 +60,7 @@ geojson_crs_03|{"type":"Point","crs":{"type":"name","properties":{"name":"urn:og
 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_crs_07|{"type":"Point","crs":{"type":"name","properties":{"name":"EPSG:3005"}},"coordinates":[1,1]}
 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]]}
index 567d81bdd0ae96485fa3ef368bdc928425d53677..c92b7aad0ab62d95d8d60f5048edd7eb9a382d03 100644 (file)
@@ -1,8 +1,6 @@
 -- Test the populate_geometry_columns,DropGeometryTable etc --
 \set VERBOSITY terse
 SET client_min_messages TO warning;
-DELETE FROM spatial_ref_sys WHERE srid = 4326;
-INSERT INTO spatial_ref_sys ( srid, proj4text ) VALUES( 4326, '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs');
 CREATE TABLE test_pt(gid SERIAL PRIMARY KEY, geom geometry);
 INSERT INTO test_pt(geom) VALUES(ST_GeomFromEWKT('SRID=4326;POINT M(1 2 3)'));
 SELECT populate_geometry_columns('test_pt'::regclass);
index bf8f2f17b69e60d69b2b46881a5e13c5e0b1ee24..411d1b9afd8981532ec144ffbd313c54f0b301b1 100644 (file)
@@ -56,14 +56,12 @@ SELECT 12, ST_AsEWKT(ST_Transform(
            ST_GeomFromEWKT('SRID=100002;POINT(16 48)'),
            'invalid projection'));
 
-DELETE FROM spatial_ref_sys WHERE srid >= 100000;
+DELETE FROM spatial_ref_sys WHERE srid in (100001, 100002);
 
 --- Overflow proj cache
-TRUNCATE spatial_ref_sys;
-\i ../../spatial_ref_sys.sql
 SELECT 13, count(*) FROM
 (
     SELECT ST_Transform('SRID=4326; POINT(0 0)'::geometry, srid) AS g
     FROM
         ( SELECT srid FROM spatial_ref_sys LIMIT 150 ) _a
-) _b WHERE g IS NOT NULL;
\ No newline at end of file
+) _b WHERE g IS NOT NULL;
index 3c0e7fca462cbc8b2002d9fb5e19961aa0ac1392..ba87cb8e37e0dc1b661b6b5a176c4d89dec57641 100644 (file)
@@ -3,17 +3,6 @@
 -- referenced by bug number for historical interest.
 --
 SET client_min_messages TO NOTICE;
--- NOTE: some tests _require_ spatial_ref_sys entries.
--- In particular, the GML output ones want auth_name and auth_srid too,
--- so we provide one for EPSG:4326
-DELETE FROM spatial_ref_sys;
-INSERT INTO spatial_ref_sys ( srid, proj4text ) VALUES ( 32611, '+proj=utm +zone=11 +ellps=WGS84 +datum=WGS84 +units=m +no_defs' );
-INSERT INTO spatial_ref_sys ( auth_name, auth_srid, srid, proj4text ) VALUES ( 'EPSG', 4326, 4326, '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs' );
-INSERT INTO spatial_ref_sys ( srid, proj4text ) VALUES ( 32602, '+proj=utm +zone=2 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ' );
-INSERT INTO spatial_ref_sys ( srid, proj4text ) VALUES ( 32702, '+proj=utm +zone=2 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs ' );
-INSERT INTO spatial_ref_sys ( srid, proj4text ) VALUES ( 3395, '+proj=merc +lon_0=0 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ' );
-
-INSERT INTO spatial_ref_sys (srid,proj4text) VALUES (32707,'+proj=utm +zone=7 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs ');
 
 -- #2 --
 SELECT '#2', ST_AsText(ST_Union(g)) FROM
@@ -569,6 +558,7 @@ FROM inp;
 insert into spatial_ref_sys (srid, proj4text) values (500001,NULL);
 insert into spatial_ref_sys (srid, proj4text) values (500002, '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs');
 select '#1150', st_astext(st_transform('SRID=500002;POINT(0 0)'::geometry,500001));
+delete from spatial_ref_sys where srid in (500001,500002);
 
 -- #1038
 select '#1038', ST_AsSVG('POLYGON EMPTY'::geometry);
@@ -1239,10 +1229,6 @@ FROM (SELECT 'POLYGON((0 0,1 0,1 1,0 1,0 0))'::geometry AS g) AS f;
 SELECT '#4304a', ST_3DMakeBox(ST_GeomFromText('POINT EMPTY',4326), ST_GeomFromText('POINT EMPTY',4326)) IS NULL;
 SELECT '#4304b', ST_MakeBox2D(ST_GeomFromText('POINT EMPTY',4326), ST_GeomFromText('POINT EMPTY',4326)) IS NULL;
 
-
--- Clean up
-DELETE FROM spatial_ref_sys;
-
 SELECT '#4176', ST_Intersects('POLYGON((0 0, 10 10, 3 5, 0 0))', 'GEOMETRYCOLLECTION(POINT(10 10), LINESTRING(0 0, 3 3))');
 
 with mj as (select 'POINT(0 0)'::geometry geom) select '#4394' from mj a full join mj b on a.geom = b.geom;
index 03ec0db9f2f936af8de29caf2d127b3d73f301d4..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,2 +0,0 @@
--- Cleanup
-DELETE FROM spatial_ref_sys;
index 20c08f6872d80c73b751744ec6a65c8e19a9114c..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,11 +0,0 @@
---- In case this test is running in an extension context
-TRUNCATE spatial_ref_sys;
----
---- EPSG 4326 : WGS 84
----
-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"]],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 ');
----
---- EPSG 2260 : NAD83 / New York East (ftUS)
----
-INSERT INTO "spatial_ref_sys" ("srid","auth_name","auth_srid","srtext","proj4text") VALUES (2260,'EPSG',2260,'PROJCS["NAD83 / New York East (ftUS)",GEOGCS["NAD83",DATUM["North_American_Datum_1983",SPHEROID["GRS 1980",6378137,298.257222101,AUTHORITY["EPSG","7019"]],AUTHORITY["EPSG","6269"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4269"]],UNIT["US survey foot",0.3048006096012192,AUTHORITY["EPSG","9003"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",38.83333333333334],PARAMETER["central_meridian",-74.5],PARAMETER["scale_factor",0.9999],PARAMETER["false_easting",492125],PARAMETER["false_northing",0],AUTHORITY["EPSG","2260"],AXIS["X",EAST],AXIS["Y",NORTH]]','+proj=tmerc +lat_0=38.83333333333334 +lon_0=-74.5 +k=0.9999 +x_0=150000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=us-ft +no_defs ');
-
index 4d480c650a4035d4674d8f890ab874c1905186ea..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,2 +0,0 @@
--- Cleanup\r
-DELETE FROM spatial_ref_sys;\r
index 4e642fb964b616585a269894d35534391e995755..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,11 +0,0 @@
---- In case this test is running in an extension context\r
-TRUNCATE spatial_ref_sys;\r
----\r
---- EPSG 4326 : WGS 84\r
----\r
-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"]],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 ');\r
----\r
---- EPSG 2260 : NAD83 / New York East (ftUS)\r
----\r
-INSERT INTO "spatial_ref_sys" ("srid","auth_name","auth_srid","srtext","proj4text") VALUES (2260,'EPSG',2260,'PROJCS["NAD83 / New York East (ftUS)",GEOGCS["NAD83",DATUM["North_American_Datum_1983",SPHEROID["GRS 1980",6378137,298.257222101,AUTHORITY["EPSG","7019"]],AUTHORITY["EPSG","6269"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4269"]],UNIT["US survey foot",0.3048006096012192,AUTHORITY["EPSG","9003"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",38.83333333333334],PARAMETER["central_meridian",-74.5],PARAMETER["scale_factor",0.9999],PARAMETER["false_easting",492125],PARAMETER["false_northing",0],AUTHORITY["EPSG","2260"],AXIS["X",EAST],AXIS["Y",NORTH]]','+proj=tmerc +lat_0=38.83333333333334 +lon_0=-74.5 +k=0.9999 +x_0=150000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=us-ft +no_defs ');\r
-\r
index 1f3bcbdab6f121968c1ecbdc4605b7b1bc1ac27c..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,2 +0,0 @@
--- cleanup
-DELETE FROM spatial_ref_sys;
index dfe50eab6868897b5d0997fb8516fc8ec3efccda..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,9 +0,0 @@
----
---- EPSG 4326 : WGS 84
----
-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"]],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 ');
----
---- EPSG 2260 : NAD83 / New York East (ftUS)
----
-INSERT INTO "spatial_ref_sys" ("srid","auth_name","auth_srid","srtext","proj4text") VALUES (2260,'EPSG',2260,'PROJCS["NAD83 / New York East (ftUS)",GEOGCS["NAD83",DATUM["North_American_Datum_1983",SPHEROID["GRS 1980",6378137,298.257222101,AUTHORITY["EPSG","7019"]],AUTHORITY["EPSG","6269"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4269"]],UNIT["US survey foot",0.3048006096012192,AUTHORITY["EPSG","9003"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",38.83333333333334],PARAMETER["central_meridian",-74.5],PARAMETER["scale_factor",0.9999],PARAMETER["false_easting",492125],PARAMETER["false_northing",0],AUTHORITY["EPSG","2260"],AXIS["X",EAST],AXIS["Y",NORTH]]','+proj=tmerc +lat_0=38.83333333333334 +lon_0=-74.5 +k=0.9999 +x_0=150000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=us-ft +no_defs ');
-
index b188c1aaf9fcd637ab8b52b0b918848b7184c1e7..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,2 +0,0 @@
--- cleanup\r
-DELETE FROM spatial_ref_sys;\r
index 8ae5d8e84e8edcb80bd581f119e6c4f39f3e7cf7..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,9 +0,0 @@
----\r
---- EPSG 4326 : WGS 84\r
----\r
-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"]],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 ');\r
----\r
---- EPSG 2260 : NAD83 / New York East (ftUS)\r
----\r
-INSERT INTO "spatial_ref_sys" ("srid","auth_name","auth_srid","srtext","proj4text") VALUES (2260,'EPSG',2260,'PROJCS["NAD83 / New York East (ftUS)",GEOGCS["NAD83",DATUM["North_American_Datum_1983",SPHEROID["GRS 1980",6378137,298.257222101,AUTHORITY["EPSG","7019"]],AUTHORITY["EPSG","6269"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4269"]],UNIT["US survey foot",0.3048006096012192,AUTHORITY["EPSG","9003"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",38.83333333333334],PARAMETER["central_meridian",-74.5],PARAMETER["scale_factor",0.9999],PARAMETER["false_easting",492125],PARAMETER["false_northing",0],AUTHORITY["EPSG","2260"],AXIS["X",EAST],AXIS["Y",NORTH]]','+proj=tmerc +lat_0=38.83333333333334 +lon_0=-74.5 +k=0.9999 +x_0=150000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=us-ft +no_defs ');\r
-\r
index d337097a6cbe0384cbf93e6561f60f02c8e1e1ad..dc1f02f723291e970be90e1a71b3e55fe40610f4 100755 (executable)
@@ -396,10 +396,14 @@ print "\nRunning tests\n\n";
 
 foreach $TEST (@ARGV)
 {
+       my $TEST_OBJ_COUNT_PRE;
+       my $TEST_OBJ_COUNT_POST;
+
        # catch a common mistake (strip trailing .sql)
        $TEST =~ s/.sql$//;
 
        start_test($TEST);
+       $TEST_OBJ_COUNT_PRE = count_postgis_objects();
 
        # Check for a "-pre.pl" file in case there are setup commands
     eval_file("${TEST}-pre.pl");
@@ -454,6 +458,14 @@ foreach $TEST (@ARGV)
        # Check for a "-post.pl" file in case there are teardown commands
     eval_file("${TEST}-post.pl");
 
+       $TEST_OBJ_COUNT_POST = count_postgis_objects();
+
+       if ( $TEST_OBJ_COUNT_POST != $TEST_OBJ_COUNT_PRE )
+       {
+               fail("PostGIS object count pre-test ($TEST_OBJ_COUNT_POST) != post-test ($TEST_OBJ_COUNT_PRE)");
+               return 0;
+       }
+
 }
 
 
@@ -1203,13 +1215,29 @@ sub count_db_objects
                select count(*) from pg_opclass union all
                select count(*) from pg_namespace
                        where nspname NOT LIKE 'pg_%' union all
-               select count(*) from pg_opfamily )
+               select count(*) from pg_opfamily
+               )
                select sum(count) from counts");
 
        return $count;
 }
 
 
+##################################################################
+# Count postgis objects
+##################################################################
+sub count_postgis_objects
+{
+       my $count = sql("WITH counts as (
+               select count(*) from spatial_ref_sys
+               )
+               select sum(count) from counts");
+
+       return $count;
+}
+
+
+
 ##################################################################
 # Create the spatial database
 ##################################################################
@@ -1366,6 +1394,7 @@ sub prepare_spatial
        load_sql_file("${STAGED_SCRIPTS_DIR}/postgis.sql", 1);
        load_sql_file("${STAGED_SCRIPTS_DIR}/postgis_comments.sql", 0);
        load_sql_file("${STAGED_SCRIPTS_DIR}/postgis_proc_set_search_path.sql", 0);
+       load_sql_file("${STAGED_SCRIPTS_DIR}/spatial_ref_sys.sql", 0);
 
        if ( $OPT_WITH_TOPO )
        {
index 182ff493cb8d9fd731efbd88637b73fa6d4ea919..74408282142b5f7a17d73d7982caca52d845a5a1 100644 (file)
@@ -1,6 +1,5 @@
 set client_min_messages to WARNING;
 
-INSERT INTO spatial_ref_sys ( auth_name, auth_srid, srid, proj4text ) VALUES ( 'EPSG', 4326, 4326, '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs' );
 \i load_topology-4326.sql
 \i load_features.sql
 \i more_features.sql
@@ -56,5 +55,3 @@ select '#2184.1', topology.createTopology('t3d', 0, 0, true) > 0;
 select '#2184.2', st_addisonode('t3d', NULL, 'POINT(1 2 3)');
 select '#2184.3', topology.copyTopology('t3d', 't3d-bis') > 0;
 select '#2184.4', length(topology.dropTopology('t3d')) > 0, length(topology.dropTopology('t3d-bis')) > 0;
-
-DELETE FROM spatial_ref_sys where srid = 4326;
index aadbe017dc0ca41e475181c87686679ca5254f3b..58fcb519e3d1705da430157bf5e39e46de35c667 100644 (file)
@@ -1,7 +1,5 @@
 set client_min_messages to WARNING;
 
-INSERT INTO spatial_ref_sys ( auth_name, auth_srid, srid, proj4text ) VALUES ( 'EPSG', 4326, 4326, '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs' );
-
 \i load_topology-4326.sql
 \i load_features.sql
 \i more_features.sql
@@ -218,5 +216,4 @@ ORDER BY name;
 
 SELECT topology.DropTopology('city_data');
 DROP SCHEMA features CASCADE;
-DELETE FROM spatial_ref_sys where srid = 4326;
 DROP TABLE visited;
index 2d0b4ce70c7cf784b0d904e541543885cee6f85a..8d25a2bb8ac6a67f587ee409bf8ee82023141f73 100644 (file)
@@ -1,9 +1,6 @@
 \set VERBOSITY terse
 set client_min_messages to ERROR;
 
-TRUNCATE spatial_ref_sys;
-INSERT INTO spatial_ref_sys ( auth_name, auth_srid, srid, proj4text ) VALUES ( 'EPSG', 4326, 4326, '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs' );
-
 -- Invalid topologies
 select topology.st_createtopogeo('', 'GEOMETRYCOLLECTION(POINT(0 0))');
 select topology.st_createtopogeo('t', 'GEOMETRYCOLLECTION(POINT(0 0))');
@@ -248,6 +245,5 @@ select * from print_isolated_nodes('T17');
 select null from ( select topology.DropTopology('t') ) as dt;
 
 -- clean up
-DELETE FROM spatial_ref_sys where srid = 4326;
 DROP FUNCTION print_isolated_nodes(text);
 DROP FUNCTION print_elements_count(text);
index 2425f18e4401bfc4a59f43a94b3e75e4f2835926..c813d14174e739913428037c006f2828853f3221 100644 (file)
@@ -2,8 +2,6 @@
 \set VERBOSITY terse
 set client_min_messages to WARNING;
 
-INSERT INTO spatial_ref_sys ( auth_name, auth_srid, srid, proj4text ) VALUES ( 'EPSG', 4326, 4326, '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs' );
-
 -- Import city_data
 \i load_topology-4326.sql
 
@@ -145,7 +143,6 @@ DROP TABLE t;
 
 DROP FUNCTION check_changes();
 SELECT DropTopology('city_data');
-DELETE FROM spatial_ref_sys where srid = 4326;
 
 -- See https://trac.osgeo.org/postgis/ticket/3401
 SELECT 't3401.start', CreateTopology('bug3401') > 1;
index 68b9d8a4f91080e56b03719247936cd0931dc27e..6cedc9702a5102c88d5168cd98808be5aee3ad2f 100644 (file)
@@ -2,8 +2,6 @@
 \set VERBOSITY terse
 set client_min_messages to ERROR;
 
-INSERT INTO spatial_ref_sys ( auth_name, auth_srid, srid, proj4text ) VALUES ( 'EPSG', 4326, 4326, '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs' );
-
 -- Import city_data
 \i load_topology-4326.sql
 
@@ -145,4 +143,3 @@ DROP TABLE t;
 
 DROP FUNCTION check_changes();
 SELECT DropTopology('city_data');
-DELETE FROM spatial_ref_sys where srid = 4326;
index 9fb5961987cbb8afdb92c6c556b4715e1f0bff9f..101b47539d36e88fef324b679cd328f4e259d6e7 100644 (file)
@@ -1,8 +1,6 @@
 \set VERBOSITY terse
 set client_min_messages to ERROR;
 
-INSERT INTO spatial_ref_sys ( auth_name, auth_srid, srid, proj4text ) VALUES ( 'EPSG', 4326, 4326, '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs' );
-
 -- Import city_data
 \i load_topology-4326.sql
 
@@ -424,5 +422,3 @@ DROP FUNCTION check_faces(text);
 DROP FUNCTION save_nodes();
 DROP FUNCTION check_nodes(text);
 DROP FUNCTION catch_error(text);
-DELETE FROM spatial_ref_sys where srid = 4326;
-
index ba7c101681b2a2622a9aa5db588db5d0134189de..90cf30b034d58c6a8f493ce31dc13d1d19c352fa 100644 (file)
@@ -1,8 +1,6 @@
 \set VERBOSITY terse
 set client_min_messages to ERROR;
 
-INSERT INTO spatial_ref_sys ( auth_name, auth_srid, srid, proj4text ) VALUES ( 'EPSG', 4326, 4326, '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs' );
-
 -- Import city_data
 \i load_topology-4326.sql
 
@@ -424,5 +422,3 @@ DROP FUNCTION check_faces(text);
 DROP FUNCTION save_nodes();
 DROP FUNCTION check_nodes(text);
 DROP FUNCTION catch_error(text);
-DELETE FROM spatial_ref_sys where srid = 4326;
-
index 2459448a72f3aeec006613a99293c7b49f7f600c..e278739b7795d17934b3f079cfec5d9566d29132 100644 (file)
@@ -1,8 +1,6 @@
 \set VERBOSITY terse
 set client_min_messages to ERROR;
 
-INSERT INTO spatial_ref_sys ( auth_name, auth_srid, srid, proj4text ) VALUES ( 'EPSG', 4326, 4326, '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs' );
-
 \i load_topology-4326.sql
 
 -- Save max node id
@@ -262,7 +260,6 @@ SELECT * FROM ValidateTopology('city_data');
 -- Cleanups
 DROP FUNCTION check_changes(text);
 SELECT DropTopology('city_data');
-DELETE FROM spatial_ref_sys where srid = 4326;
 
 -- See http://trac.osgeo.org/postgis/ticket/3280
 SELECT 't3280.start', topology.CreateTopology('bug3280') > 0;