- #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
<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 >= 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.
<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>
<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>
<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>
<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>
-- 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;
#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
/**
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) )
}
/* 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);
text *geojson_input;
char *geojson;
char *srs = NULL;
+ int32_t srid = WGS84_SRID;
/* Get the geojson stream */
if (PG_ARGISNULL(0))
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
}
-
-----------------------------------------------------------------------
-- 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
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)
-TRUNCATE spatial_ref_sys;
--- should this be done automatically ?
-- "loadedrast" is removed automatically !
DROP TABLE o_2_loadedrast;
--- 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')
-;
-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
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);
-- 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] }');
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]]}'));
-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)
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)
#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))
-- 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));
-- 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;
-- 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));
-- 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;
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)
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);
\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...';
-- 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
-
---
--- 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
--
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
-- 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;
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
---
--- 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
--
-- 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
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);
-- 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;
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]]}
-- 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);
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;
-- 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
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);
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;
--- Cleanup
-DELETE FROM spatial_ref_sys;
---- 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 ');
-
--- Cleanup\r
-DELETE FROM spatial_ref_sys;\r
---- 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
--- cleanup
-DELETE FROM 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 ');
-
--- cleanup\r
-DELETE FROM 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
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");
# 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;
+ }
+
}
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
##################################################################
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 )
{
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
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;
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
SELECT topology.DropTopology('city_data');
DROP SCHEMA features CASCADE;
-DELETE FROM spatial_ref_sys where srid = 4326;
DROP TABLE visited;
\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))');
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);
\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
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;
\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
DROP FUNCTION check_changes();
SELECT DropTopology('city_data');
-DELETE FROM spatial_ref_sys where srid = 4326;
\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
DROP FUNCTION save_nodes();
DROP FUNCTION check_nodes(text);
DROP FUNCTION catch_error(text);
-DELETE FROM spatial_ref_sys where srid = 4326;
-
\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
DROP FUNCTION save_nodes();
DROP FUNCTION check_nodes(text);
DROP FUNCTION catch_error(text);
-DELETE FROM spatial_ref_sys where srid = 4326;
-
\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
-- 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;