From a2c725a6fb17e8dea337019bde8f931c088b8df9 Mon Sep 17 00:00:00 2001 From: Paul Ramsey Date: Fri, 18 Mar 2011 15:40:31 +0000 Subject: [PATCH] Fixes the following shp2pgsql issues: #229: A new "-r" command line parameter to specify a "from" SRID for reprojecting (the existing -s is the "to"). #779: -S now works for points, and -w is documented. #864: MULTIPOINT shapefiles with single-vertex points now correctly load with all MULTIPOINTs. #865: no longer crashes when both -g and -G are used. git-svn-id: http://svn.osgeo.org/postgis/trunk@6922 b70326c6-7e19-0410-871a-916f4a2858ee --- doc/man/shp2pgsql.1 | 15 + doc/using_postgis_dataman.xml | 52 ++- loader/shp2pgsql-cli.c | 46 ++- loader/shp2pgsql-core.c | 371 +++++++----------- loader/shp2pgsql-core.h | 27 +- loader/shp2pgsql-gui.c | 16 +- regress/Makefile.in | 4 + ...Arc-wkb.expected => Arc-w.select.expected} | 0 .../{Arc-wkt.expected => Arc.select.expected} | 0 .../loader/{ArcM-wkb.sql => Arc.select.sql} | 0 regress/loader/Arc.shp.expected | Bin 0 -> 400 bytes ...cM-wkb.expected => ArcM-w.select.expected} | 0 regress/loader/ArcM-wkt.expected | 3 - regress/loader/ArcM-wkt.sql | 4 - regress/loader/ArcM.select.expected | 3 + .../loader/{Arc-wkb.sql => ArcM.select.sql} | 1 - regress/loader/ArcM.shp.expected | Bin 0 -> 348 bytes regress/loader/ArcZ-w.select.expected | 3 + regress/loader/ArcZ-wkb.expected | 1 - regress/loader/ArcZ-wkt.expected | 1 - regress/loader/ArcZ.select.expected | 3 + .../loader/{Arc-wkt.sql => ArcZ.select.sql} | 1 - regress/loader/ArcZ.shp.expected | Bin 0 -> 420 bytes ....expected => MultiPoint-w.select.expected} | 0 ...kt.expected => MultiPoint.select.expected} | 0 ...ltiPoint-wkb.sql => MultiPoint.select.sql} | 0 regress/loader/MultiPoint.shp.expected | Bin 0 -> 196 bytes ...expected => MultiPointM-w.select.expected} | 0 regress/loader/MultiPointM-wkt.expected | 1 - regress/loader/MultiPointM.select.expected | 1 + ...tiPoint-wkt.sql => MultiPointM.select.sql} | 0 regress/loader/MultiPointM.shp.expected | Bin 0 -> 236 bytes ...expected => MultiPointZ-w.select.expected} | 0 regress/loader/MultiPointZ-wkt.expected | 1 - regress/loader/MultiPointZ.select.expected | 1 + ...iPointM-wkb.sql => MultiPointZ.select.sql} | 0 regress/loader/MultiPointZ.shp.expected | Bin 0 -> 276 bytes .../MultiToSinglePoint-w.select.expected | 66 ++++ regress/loader/MultiToSinglePoint.dbf | Bin 0 -> 100 bytes regress/loader/MultiToSinglePoint.opts | 4 + .../loader/MultiToSinglePoint.select.expected | 66 ++++ ...-wkt.sql => MultiToSinglePoint.select.sql} | 0 regress/loader/MultiToSinglePoint.shp | Bin 0 -> 4324 bytes .../loader/MultiToSinglePoint.shp.expected | Bin 0 -> 1948 bytes regress/loader/MultiToSinglePoint.shx | Bin 0 -> 628 bytes ...xpected => NoTransPoint-w.select.expected} | 0 ....expected => NoTransPoint.select.expected} | 0 ...PointZ-wkb.sql => NoTransPoint.select.sql} | 0 regress/loader/NoTransPoint.shp.expected | Bin 0 -> 184 bytes .../NotReallyMultiPoint-w.select.expected | 66 ++++ regress/loader/NotReallyMultiPoint.dbf | Bin 0 -> 100 bytes .../NotReallyMultiPoint.select.expected | 66 ++++ ...wkt.sql => NotReallyMultiPoint.select.sql} | 0 regress/loader/NotReallyMultiPoint.shp | Bin 0 -> 4324 bytes .../loader/NotReallyMultiPoint.shp.expected | Bin 0 -> 4324 bytes regress/loader/NotReallyMultiPoint.shx | Bin 0 -> 628 bytes ...t-wkb.expected => Point-w.select.expected} | 0 ...int-wkt.expected => Point.select.expected} | 0 ...{NoTransPoint-wkb.sql => Point.select.sql} | 0 regress/loader/Point.shp.expected | Bin 0 -> 184 bytes ...-wkb.expected => PointM-w.select.expected} | 0 regress/loader/PointM-wkt.expected | 3 - regress/loader/PointM.select.expected | 3 + .../{PointM-wkb.sql => PointM.select.sql} | 0 regress/loader/PointM.shp.expected | Bin 0 -> 208 bytes ...-wkb.expected => PointZ-w.select.expected} | 0 regress/loader/PointZ-wkb.sql | 1 - regress/loader/PointZ-wkt.expected | 3 - regress/loader/PointZ-wkt.sql | 1 - regress/loader/PointZ.select.expected | 3 + .../{PointM-wkt.sql => PointZ.select.sql} | 0 regress/loader/PointZ.shp.expected | Bin 0 -> 232 bytes ...wkb.expected => Polygon-w.select.expected} | 0 ...n-wkt.expected => Polygon.select.expected} | 0 ...oTransPoint-wkt.sql => Polygon.select.sql} | 0 regress/loader/Polygon.shp.expected | Bin 0 -> 488 bytes ...kb.expected => PolygonM-w.select.expected} | 0 regress/loader/PolygonM.select.expected | 1 + .../{Point-wkb.sql => PolygonM.select.sql} | 0 regress/loader/PolygonM.shp.expected | Bin 0 -> 664 bytes ...kb.expected => PolygonZ-w.select.expected} | 0 regress/loader/PolygonZ-wkb.sql | 2 - regress/loader/PolygonZ-wkt.expected | 1 - regress/loader/PolygonZ-wkt.sql | 2 - regress/loader/PolygonZ.select.expected | 1 + .../{Point-wkt.sql => PolygonZ.select.sql} | 0 regress/loader/PolygonZ.shp.expected | Bin 0 -> 840 bytes regress/loader/README | 51 ++- regress/loader/ReprojectPts-pre.sql | 12 + regress/loader/ReprojectPts-w.select.expected | 66 ++++ regress/loader/ReprojectPts.dbf | Bin 0 -> 100 bytes regress/loader/ReprojectPts.opts | 3 + regress/loader/ReprojectPts.select.expected | 66 ++++ ...olygon-wkb.sql => ReprojectPts.select.sql} | 0 regress/loader/ReprojectPts.shp | Bin 0 -> 4324 bytes regress/loader/ReprojectPts.shx | Bin 0 -> 628 bytes regress/loader/ReprojectPtsGeog-pre.sql | 12 + .../loader/ReprojectPtsGeog-w.select.expected | 66 ++++ regress/loader/ReprojectPtsGeog.dbf | Bin 0 -> 100 bytes regress/loader/ReprojectPtsGeog.opts | 3 + .../loader/ReprojectPtsGeog.select.expected | 66 ++++ regress/loader/ReprojectPtsGeog.select.sql | 2 + regress/loader/ReprojectPtsGeog.shp | Bin 0 -> 4324 bytes regress/loader/ReprojectPtsGeog.shx | Bin 0 -> 628 bytes ....expected => TSIPolygon-w.select.expected} | 0 regress/loader/TSIPolygon-wkb.sql | 2 - regress/loader/TSIPolygon-wkt.sql | 2 - ...kb.expected => TSIPolygon.select.expected} | 0 ...{Polygon-wkt.sql => TSIPolygon.select.sql} | 0 regress/loader/TSIPolygon.shp.expected | Bin 0 -> 488 bytes ...expected => TSTIPolygon-w.select.expected} | 0 regress/loader/TSTIPolygon-wkb.sql | 2 - regress/loader/TSTIPolygon-wkt.sql | 2 - ...b.expected => TSTIPolygon.select.expected} | 0 ...olygonM-wkb.sql => TSTIPolygon.select.sql} | 0 regress/loader/TSTIPolygon.shp.expected | Bin 0 -> 488 bytes ....expected => TSTPolygon-w.select.expected} | 0 regress/loader/TSTPolygon-wkb.sql | 2 - regress/loader/TSTPolygon-wkt.expected | 1 - regress/loader/TSTPolygon-wkt.sql | 2 - ...kb.expected => TSTPolygon.select.expected} | 0 ...PolygonM-wkt.sql => TSTPolygon.select.sql} | 0 regress/loader/TSTPolygon.shp.expected | Bin 0 -> 488 bytes regress/out_geometry.sql | 1 + regress/run_test | 294 ++++++-------- 125 files changed, 1029 insertions(+), 470 deletions(-) rename regress/loader/{Arc-wkb.expected => Arc-w.select.expected} (100%) rename regress/loader/{Arc-wkt.expected => Arc.select.expected} (100%) rename regress/loader/{ArcM-wkb.sql => Arc.select.sql} (100%) create mode 100644 regress/loader/Arc.shp.expected rename regress/loader/{ArcM-wkb.expected => ArcM-w.select.expected} (100%) delete mode 100644 regress/loader/ArcM-wkt.expected delete mode 100644 regress/loader/ArcM-wkt.sql create mode 100644 regress/loader/ArcM.select.expected rename regress/loader/{Arc-wkb.sql => ArcM.select.sql} (99%) create mode 100644 regress/loader/ArcM.shp.expected create mode 100644 regress/loader/ArcZ-w.select.expected delete mode 100644 regress/loader/ArcZ-wkb.expected delete mode 100644 regress/loader/ArcZ-wkt.expected create mode 100644 regress/loader/ArcZ.select.expected rename regress/loader/{Arc-wkt.sql => ArcZ.select.sql} (99%) create mode 100644 regress/loader/ArcZ.shp.expected rename regress/loader/{MultiPoint-wkb.expected => MultiPoint-w.select.expected} (100%) rename regress/loader/{MultiPoint-wkt.expected => MultiPoint.select.expected} (100%) rename regress/loader/{MultiPoint-wkb.sql => MultiPoint.select.sql} (100%) create mode 100644 regress/loader/MultiPoint.shp.expected rename regress/loader/{MultiPointM-wkb.expected => MultiPointM-w.select.expected} (100%) delete mode 100644 regress/loader/MultiPointM-wkt.expected create mode 100644 regress/loader/MultiPointM.select.expected rename regress/loader/{MultiPoint-wkt.sql => MultiPointM.select.sql} (100%) create mode 100644 regress/loader/MultiPointM.shp.expected rename regress/loader/{MultiPointZ-wkb.expected => MultiPointZ-w.select.expected} (100%) delete mode 100644 regress/loader/MultiPointZ-wkt.expected create mode 100644 regress/loader/MultiPointZ.select.expected rename regress/loader/{MultiPointM-wkb.sql => MultiPointZ.select.sql} (100%) create mode 100644 regress/loader/MultiPointZ.shp.expected create mode 100644 regress/loader/MultiToSinglePoint-w.select.expected create mode 100644 regress/loader/MultiToSinglePoint.dbf create mode 100644 regress/loader/MultiToSinglePoint.opts create mode 100644 regress/loader/MultiToSinglePoint.select.expected rename regress/loader/{MultiPointM-wkt.sql => MultiToSinglePoint.select.sql} (100%) create mode 100644 regress/loader/MultiToSinglePoint.shp create mode 100644 regress/loader/MultiToSinglePoint.shp.expected create mode 100644 regress/loader/MultiToSinglePoint.shx rename regress/loader/{NoTransPoint-wkb.expected => NoTransPoint-w.select.expected} (100%) rename regress/loader/{NoTransPoint-wkt.expected => NoTransPoint.select.expected} (100%) rename regress/loader/{MultiPointZ-wkb.sql => NoTransPoint.select.sql} (100%) create mode 100644 regress/loader/NoTransPoint.shp.expected create mode 100644 regress/loader/NotReallyMultiPoint-w.select.expected create mode 100644 regress/loader/NotReallyMultiPoint.dbf create mode 100644 regress/loader/NotReallyMultiPoint.select.expected rename regress/loader/{MultiPointZ-wkt.sql => NotReallyMultiPoint.select.sql} (100%) create mode 100644 regress/loader/NotReallyMultiPoint.shp create mode 100644 regress/loader/NotReallyMultiPoint.shp.expected create mode 100644 regress/loader/NotReallyMultiPoint.shx rename regress/loader/{Point-wkb.expected => Point-w.select.expected} (100%) rename regress/loader/{Point-wkt.expected => Point.select.expected} (100%) rename regress/loader/{NoTransPoint-wkb.sql => Point.select.sql} (100%) create mode 100644 regress/loader/Point.shp.expected rename regress/loader/{PointM-wkb.expected => PointM-w.select.expected} (100%) delete mode 100644 regress/loader/PointM-wkt.expected create mode 100644 regress/loader/PointM.select.expected rename regress/loader/{PointM-wkb.sql => PointM.select.sql} (100%) create mode 100644 regress/loader/PointM.shp.expected rename regress/loader/{PointZ-wkb.expected => PointZ-w.select.expected} (100%) delete mode 100644 regress/loader/PointZ-wkb.sql delete mode 100644 regress/loader/PointZ-wkt.expected delete mode 100644 regress/loader/PointZ-wkt.sql create mode 100644 regress/loader/PointZ.select.expected rename regress/loader/{PointM-wkt.sql => PointZ.select.sql} (100%) create mode 100644 regress/loader/PointZ.shp.expected rename regress/loader/{Polygon-wkb.expected => Polygon-w.select.expected} (100%) rename regress/loader/{Polygon-wkt.expected => Polygon.select.expected} (100%) rename regress/loader/{NoTransPoint-wkt.sql => Polygon.select.sql} (100%) create mode 100644 regress/loader/Polygon.shp.expected rename regress/loader/{PolygonM-wkb.expected => PolygonM-w.select.expected} (100%) create mode 100644 regress/loader/PolygonM.select.expected rename regress/loader/{Point-wkb.sql => PolygonM.select.sql} (100%) create mode 100644 regress/loader/PolygonM.shp.expected rename regress/loader/{PolygonZ-wkb.expected => PolygonZ-w.select.expected} (100%) delete mode 100644 regress/loader/PolygonZ-wkb.sql delete mode 100644 regress/loader/PolygonZ-wkt.expected delete mode 100644 regress/loader/PolygonZ-wkt.sql create mode 100644 regress/loader/PolygonZ.select.expected rename regress/loader/{Point-wkt.sql => PolygonZ.select.sql} (100%) create mode 100644 regress/loader/PolygonZ.shp.expected create mode 100644 regress/loader/ReprojectPts-pre.sql create mode 100644 regress/loader/ReprojectPts-w.select.expected create mode 100644 regress/loader/ReprojectPts.dbf create mode 100644 regress/loader/ReprojectPts.opts create mode 100644 regress/loader/ReprojectPts.select.expected rename regress/loader/{Polygon-wkb.sql => ReprojectPts.select.sql} (100%) create mode 100644 regress/loader/ReprojectPts.shp create mode 100644 regress/loader/ReprojectPts.shx create mode 100644 regress/loader/ReprojectPtsGeog-pre.sql create mode 100644 regress/loader/ReprojectPtsGeog-w.select.expected create mode 100644 regress/loader/ReprojectPtsGeog.dbf create mode 100644 regress/loader/ReprojectPtsGeog.opts create mode 100644 regress/loader/ReprojectPtsGeog.select.expected create mode 100644 regress/loader/ReprojectPtsGeog.select.sql create mode 100644 regress/loader/ReprojectPtsGeog.shp create mode 100644 regress/loader/ReprojectPtsGeog.shx rename regress/loader/{PolygonM-wkt.expected => TSIPolygon-w.select.expected} (100%) delete mode 100644 regress/loader/TSIPolygon-wkb.sql delete mode 100644 regress/loader/TSIPolygon-wkt.sql rename regress/loader/{TSIPolygon-wkb.expected => TSIPolygon.select.expected} (100%) rename regress/loader/{Polygon-wkt.sql => TSIPolygon.select.sql} (100%) create mode 100644 regress/loader/TSIPolygon.shp.expected rename regress/loader/{TSIPolygon-wkt.expected => TSTIPolygon-w.select.expected} (100%) delete mode 100644 regress/loader/TSTIPolygon-wkb.sql delete mode 100644 regress/loader/TSTIPolygon-wkt.sql rename regress/loader/{TSTIPolygon-wkb.expected => TSTIPolygon.select.expected} (100%) rename regress/loader/{PolygonM-wkb.sql => TSTIPolygon.select.sql} (100%) create mode 100644 regress/loader/TSTIPolygon.shp.expected rename regress/loader/{TSTIPolygon-wkt.expected => TSTPolygon-w.select.expected} (100%) delete mode 100644 regress/loader/TSTPolygon-wkb.sql delete mode 100644 regress/loader/TSTPolygon-wkt.expected delete mode 100644 regress/loader/TSTPolygon-wkt.sql rename regress/loader/{TSTPolygon-wkb.expected => TSTPolygon.select.expected} (100%) rename regress/loader/{PolygonM-wkt.sql => TSTPolygon.select.sql} (100%) create mode 100644 regress/loader/TSTPolygon.shp.expected diff --git a/doc/man/shp2pgsql.1 b/doc/man/shp2pgsql.1 index ca293f5dd..12dee56bc 100644 --- a/doc/man/shp2pgsql.1 +++ b/doc/man/shp2pgsql.1 @@ -53,6 +53,10 @@ Use the PostgreSQL "dump" format for the output data. This can be combined with -a, -c and -d. It is much faster to load than the default "insert" SQL format. Use this for very large data sets. .TP +\fB\-w\fR +Output WKT format, instead of WKB. Note that this can +introduce coordinate drifts due to loss of precision. +.TP \fB\-e\fR Execute each statement on its own, without using a transaction. This allows loading of the majority of good data when there are some bad @@ -62,6 +66,17 @@ geometries that generate errors. Note that this cannot be used with the \fB\-s\fR <\fISRID\fR> Creates and populates the geometry tables with the specified SRID. .TP +\fB\-r\fR <\fISRID\fR> +Specifies that the input shapefile uses the given SRID. If -s is not +specified, this SRID will be used to populate the geometry table. If +-s is specified, the geometries will be reprojected to the SRID given +in the -s parameter. If -G is specified, but -s is not, the geometries +will be reprojected to 4326. This parameter cannot be used with -D. +.TP +\fB\-G\fR +Use the geography type instead of geometry. Geography is used to store +lat/lon data. At the moment the only spatial reference supported is 4326. +.TP \fB\-g\fR <\fIgeometry_column\fR> Specify the name of the geometry column (mostly useful in append mode). .TP diff --git a/doc/using_postgis_dataman.xml b/doc/using_postgis_dataman.xml index 63b44d3b9..12ce0093c 100644 --- a/doc/using_postgis_dataman.xml +++ b/doc/using_postgis_dataman.xml @@ -1734,6 +1734,19 @@ COMMIT; + + -r <SRID> + + + Specifies that the input shapefile uses the given SRID. If -s is not + specified, this SRID will be used to populate the geometry table. If + -s is specified, the geometries will be reprojected to the SRID given + in the -s parameter. If -G is specified, but -s is not, the geometries + will be reprojected to 4326. This parameter cannot be used with -D. + + + + -k @@ -1766,7 +1779,9 @@ COMMIT; -S - Generate simple geometries instead of MULTI geometries. + Generate simple geometries instead of MULTI geometries. Will only succeed if + all the geometries are actually single (I.E. a MULTIPOLYGON with a single shell, or + or a MULTIPOINT with a single vertex). @@ -1775,8 +1790,20 @@ COMMIT; -w - Output WKT format, for use with older (0.x) versions of PostGIS. Note that this will - introduce coordinate drifts and will drop M values from shapefiles. + Output WKT format, instead of WKB. Note that this can + introduce coordinate drifts due to loss of precision. + + + + + + -e + + + Execute each statement on its own, without using a transaction. + This allows loading of the majority of good data when there are some bad + geometries that generate errors. Note that this cannot be used with the + -D flag as the "dump" format always uses a transaction. @@ -1819,6 +1846,25 @@ COMMIT; + + -T <tablespace> + + + Specify the tablespace for the new table. Indexes will still use the + default tablespace unless the -X parameter is also used. The PostgreSQL + documentation has a good description on when to use custom tablespaces. + + + + + -X <tablespace> + + + Specify the tablespace for the new table's indexes. This applies to + the primary key index, and the GIST spatial index if -I is also used. + + + diff --git a/loader/shp2pgsql-cli.c b/loader/shp2pgsql-cli.c index e98deada0..64db3ffa4 100644 --- a/loader/shp2pgsql-cli.c +++ b/loader/shp2pgsql-cli.c @@ -22,8 +22,10 @@ usage() printf(_( "RELEASE: %s (r%s)\n" ), POSTGIS_VERSION, RCSID); printf(_( "USAGE: shp2pgsql [] [.]\n" "OPTIONS:\n" )); - printf(_( " -s Set the SRID field. Defaults to -1.\n" - " (-d|a|c|p) These are mutually exclusive options:\n" + printf(_( " -s Set the SRID field. Defaults to %d.\n" + " -r Specify the SRID to reproject from (if -s or -G is also used).\n" + " Cannot be used with -D.\n"), SRID_UNKNOWN); + printf(_( " (-d|a|c|p) These are mutually exclusive options:\n" " -d Drops the table, then recreates it and populates\n" " it with current shape file data.\n" " -a Appends shape file into current table, must be\n" @@ -36,11 +38,13 @@ usage() printf(_( " -D Use postgresql dump format (defaults to SQL insert statments).\n" )); printf(_( " -e Execute each statement individually, do not use a transaction.\n" " Not compatible with -D.\n" )); - printf(_( " -G Use geography type (requires lon/lat data).\n" )); + printf(_( " -G Use geography type (requires lon/lat data or -r to reproject).\n" )); printf(_( " -k Keep postgresql identifiers case.\n" )); printf(_( " -i Use int4 type for all integer dbf fields.\n" )); printf(_( " -I Create a spatial index on the geocolumn.\n" )); printf(_( " -S Generate simple geometries instead of MULTI geometries.\n" )); + printf(_( " -w Output WKT instead of WKB. Note that this can result in\n" + " coordinate drift.\n" )); printf(_( " -W Specify the character encoding of Shape's\n" " attribute column. (default: \"UTF-8\")\n" )); printf(_( " -N NULL geometries handling policy (insert*,skip,abort).\n" )); @@ -82,7 +86,7 @@ main (int argc, char **argv) set_config_defaults(config); /* Keep the flag list alphabetic so it's easy to see what's left. */ - while ((c = pgis_getopt(argc, argv, "acdeg:iknps:wDGIN:ST:W:X:")) != EOF) + while ((c = pgis_getopt(argc, argv, "acdeg:iknpr:s:wDGIN:ST:W:X:")) != EOF) { switch (c) { @@ -100,6 +104,11 @@ main (int argc, char **argv) fprintf(stderr, "Cannot use both -D and -e.\n"); exit(1); } + if (config->shp_sr_id != SRID_UNKNOWN) + { + fprintf(stderr, "Cannot use both -D and -r.\n"); + exit(1); + } break; case 'G': @@ -122,9 +131,26 @@ main (int argc, char **argv) exit(0); } break; + case 'r': + if (config->dump_format) + { + fprintf(stderr, "Cannot use both -D and -r.\n"); + exit(1); + } + if (pgis_optarg) + { + sscanf(pgis_optarg, "%d", &(config->shp_sr_id)); + } + else + { + /* With -r, user must specify SRID */ + usage(); + exit(0); + } + break; case 'g': - config->geom = pgis_optarg; + config->geo_col = pgis_optarg; break; case 'k': @@ -140,7 +166,7 @@ main (int argc, char **argv) break; case 'w': - config->hwgeom = 1; + config->use_wkt = 1; break; case 'n': @@ -263,14 +289,6 @@ main (int argc, char **argv) strtolower(config->schema); } - /* Make the geocolumn name consistent with the load type (geometry or geography) */ - if ( config->geography ) - { - if (config->geom) free(config->geom); - config->geom = strdup(GEOGRAPHY_DEFAULT); - } - - /* Create the shapefile state object */ state = ShpLoaderCreate(config); diff --git a/loader/shp2pgsql-core.c b/loader/shp2pgsql-core.c index 0d627d091..9f016dfd4 100644 --- a/loader/shp2pgsql-core.c +++ b/loader/shp2pgsql-core.c @@ -49,7 +49,7 @@ int utf8(const char *fromcode, char *inputbuf, char **outputbuf); char *escape_copy_string(char *str); char *escape_insert_string(char *str); -int GeneratePointGeometry(SHPLOADERSTATE *state, SHPObject *obj, char **geometry); +int GeneratePointGeometry(SHPLOADERSTATE *state, SHPObject *obj, char **geometry, int force_multi); int GenerateLineStringGeometry(SHPLOADERSTATE *state, SHPObject *obj, char **geometry); int PIP(Point P, Point *V, int n); int FindPolygons(SHPObject *obj, Ring ***Out); @@ -243,33 +243,24 @@ escape_insert_string(char *str) /** * @brief Generate an allocated geometry string for shapefile object obj using the state parameters + * if "force_multi" is true, single points will instead be created as multipoints with a single vertice. */ int -GeneratePointGeometry(SHPLOADERSTATE *state, SHPObject *obj, char **geometry) +GeneratePointGeometry(SHPLOADERSTATE *state, SHPObject *obj, char **geometry, int force_multi) { LWGEOM **lwmultipoints; LWGEOM *lwgeom = NULL; POINT4D point4d; - int dims = 0, hasz = 0, hasm = 0; + int dims = 0; int u; char *mem; size_t mem_length; - - /* Determine the correct dimensions: note that in hwgeom-compatible mode we cannot use - the M coordinate */ - if (state->wkbtype & WKBZOFFSET) - hasz = 1; - - if (!state->config->hwgeom) - if (state->wkbtype & WKBMOFFSET) - hasm = 1; - - FLAGS_SET_Z(dims, hasz?1:0); - FLAGS_SET_M(dims, hasm?1:0); + FLAGS_SET_Z(dims, state->has_z); + FLAGS_SET_M(dims, state->has_m); /* Allocate memory for our array of LWPOINTs and our dynptarrays */ lwmultipoints = malloc(sizeof(LWPOINT *) * obj->nVertices); @@ -278,29 +269,29 @@ GeneratePointGeometry(SHPLOADERSTATE *state, SHPObject *obj, char **geometry) for (u = 0; u < obj->nVertices; u++) { /* Create a ptarray containing a single point */ - POINTARRAY *pa = ptarray_construct_empty(hasz, hasm, 1); + POINTARRAY *pa = ptarray_construct_empty(state->has_z, state->has_m, 1); /* Generate the point */ point4d.x = obj->padfX[u]; point4d.y = obj->padfY[u]; - if (state->wkbtype & WKBZOFFSET) + if (state->has_z) point4d.z = obj->padfZ[u]; - if (state->wkbtype & WKBMOFFSET) + if (state->has_m) point4d.m = obj->padfM[u]; /* Add in the point! */ ptarray_append_point(pa, &point4d, REPEATED_POINTS_OK); /* Generate the LWPOINT */ - lwmultipoints[u] = lwpoint_as_lwgeom(lwpoint_construct(state->config->sr_id, NULL, pa)); + lwmultipoints[u] = lwpoint_as_lwgeom(lwpoint_construct(state->from_srid, NULL, pa)); } /* If we have more than 1 vertex then we are working on a MULTIPOINT and so generate a MULTIPOINT rather than a POINT */ - if (obj->nVertices > 1) + if ((obj->nVertices > 1) || force_multi) { - lwgeom = lwcollection_as_lwgeom(lwcollection_construct(MULTIPOINTTYPE, state->config->sr_id, NULL, obj->nVertices, lwmultipoints)); + lwgeom = lwcollection_as_lwgeom(lwcollection_construct(MULTIPOINTTYPE, state->from_srid, NULL, obj->nVertices, lwmultipoints)); } else { @@ -308,14 +299,12 @@ GeneratePointGeometry(SHPLOADERSTATE *state, SHPObject *obj, char **geometry) lwfree(lwmultipoints); } - if (state->config->hwgeom) + if (state->config->use_wkt) { - /* Old style "heavy" geometries (PostGIS < 1.0) */ mem = lwgeom_to_wkt(lwgeom, WKT_EXTENDED, 12, &mem_length); } else { - /* New "lightweight" geometries (PostGIS >= 1.0) */ mem = lwgeom_to_hexwkb(lwgeom, WKB_EXTENDED, &mem_length); } @@ -345,23 +334,14 @@ GenerateLineStringGeometry(SHPLOADERSTATE *state, SHPObject *obj, char **geometr LWGEOM **lwmultilinestrings; LWGEOM *lwgeom = NULL; POINT4D point4d; - int dims = 0, hasz = 0, hasm = 0; + int dims = 0; int u, v, start_vertex, end_vertex; char *mem; size_t mem_length; - /* Determine the correct dimensions: note that in hwgeom-compatible mode we cannot use - the M coordinate */ - if (state->wkbtype & WKBZOFFSET) - hasz = 1; - - if (!state->config->hwgeom) - if (state->wkbtype & WKBMOFFSET) - hasm = 1; - - FLAGS_SET_Z(dims, hasz?1:0); - FLAGS_SET_M(dims, hasm?1:0); + FLAGS_SET_Z(dims, state->has_z); + FLAGS_SET_M(dims, state->has_m); if (state->config->simple_geometries == 1 && obj->nParts > 1) { @@ -377,7 +357,7 @@ GenerateLineStringGeometry(SHPLOADERSTATE *state, SHPObject *obj, char **geometr for (u = 0; u < obj->nParts; u++) { /* Create a ptarray containing the line points */ - POINTARRAY *pa = ptarray_construct_empty(hasz, hasm, obj->nParts); + POINTARRAY *pa = ptarray_construct_empty(state->has_z, state->has_m, obj->nParts); /* Set the start/end vertices depending upon whether this is a MULTILINESTRING or not */ @@ -394,22 +374,22 @@ GenerateLineStringGeometry(SHPLOADERSTATE *state, SHPObject *obj, char **geometr point4d.x = obj->padfX[v]; point4d.y = obj->padfY[v]; - if (state->wkbtype & WKBZOFFSET) + if (state->has_z) point4d.z = obj->padfZ[v]; - if (state->wkbtype & WKBMOFFSET) + if (state->has_m) point4d.m = obj->padfM[v]; ptarray_append_point(pa, &point4d, REPEATED_POINTS_NOT_OK); } /* Generate the LWLINE */ - lwmultilinestrings[u] = lwline_as_lwgeom(lwline_construct(state->config->sr_id, NULL, pa)); + lwmultilinestrings[u] = lwline_as_lwgeom(lwline_construct(state->from_srid, NULL, pa)); } /* If using MULTILINESTRINGs then generate the serialized collection, otherwise just a single LINESTRING */ if (state->config->simple_geometries == 0) { - lwgeom = lwcollection_as_lwgeom(lwcollection_construct(MULTILINETYPE, state->config->sr_id, NULL, obj->nParts, lwmultilinestrings)); + lwgeom = lwcollection_as_lwgeom(lwcollection_construct(MULTILINETYPE, state->from_srid, NULL, obj->nParts, lwmultilinestrings)); } else { @@ -417,7 +397,7 @@ GenerateLineStringGeometry(SHPLOADERSTATE *state, SHPObject *obj, char **geometr lwfree(lwmultilinestrings); } - if (!state->config->hwgeom) + if (!state->config->use_wkt) mem = lwgeom_to_hexwkb(lwgeom, WKB_EXTENDED, &mem_length); else mem = lwgeom_to_wkt(lwgeom, WKT_EXTENDED, 12, &mem_length); @@ -647,22 +627,13 @@ GeneratePolygonGeometry(SHPLOADERSTATE *state, SHPObject *obj, char **geometry) POINT4D point4d; - int dims = 0, hasz = 0, hasm = 0; + int dims = 0; char *mem; size_t mem_length; - /* Determine the correct dimensions: note that in hwgeom-compatible mode we cannot use - the M coordinate */ - if (state->wkbtype & WKBZOFFSET) - hasz = 1; - - if (!state->config->hwgeom) - if (state->wkbtype & WKBMOFFSET) - hasm = 1; - - FLAGS_SET_Z(dims, hasz?1:0); - FLAGS_SET_M(dims, hasm?1:0); + FLAGS_SET_Z(dims, state->has_z); + FLAGS_SET_M(dims, state->has_m); polygon_total = FindPolygons(obj, &Outer); @@ -679,7 +650,7 @@ GeneratePolygonGeometry(SHPLOADERSTATE *state, SHPObject *obj, char **geometry) /* Cycle through each individual polygon */ for (pi = 0; pi < polygon_total; pi++) { - LWPOLY *lwpoly = lwpoly_construct_empty(state->config->sr_id, hasz, hasm); + LWPOLY *lwpoly = lwpoly_construct_empty(state->from_srid, state->has_z, state->has_m); Ring *polyring; int ring_index = 0; @@ -699,7 +670,7 @@ GeneratePolygonGeometry(SHPLOADERSTATE *state, SHPObject *obj, char **geometry) while (polyring) { /* Create a POINTARRAY containing the points making up the ring */ - POINTARRAY *pa = ptarray_construct_empty(hasz, hasm, polyring->n); + POINTARRAY *pa = ptarray_construct_empty(state->has_z, state->has_m, polyring->n); for (vi = 0; vi < polyring->n; vi++) { @@ -707,9 +678,9 @@ GeneratePolygonGeometry(SHPLOADERSTATE *state, SHPObject *obj, char **geometry) point4d.x = polyring->list[vi].x; point4d.y = polyring->list[vi].y; - if (state->wkbtype & WKBZOFFSET) + if (state->has_z) point4d.z = polyring->list[vi].z; - if (state->wkbtype & WKBMOFFSET) + if (state->has_m) point4d.m = polyring->list[vi].m; ptarray_append_point(pa, &point4d, REPEATED_POINTS_OK); @@ -729,7 +700,7 @@ GeneratePolygonGeometry(SHPLOADERSTATE *state, SHPObject *obj, char **geometry) /* If using MULTIPOLYGONS then generate the serialized collection, otherwise just a single POLYGON */ if (state->config->simple_geometries == 0) { - lwgeom = lwcollection_as_lwgeom(lwcollection_construct(MULTIPOLYGONTYPE, state->config->sr_id, NULL, polygon_total, lwpolygons)); + lwgeom = lwcollection_as_lwgeom(lwcollection_construct(MULTIPOLYGONTYPE, state->from_srid, NULL, polygon_total, lwpolygons)); } else { @@ -737,7 +708,7 @@ GeneratePolygonGeometry(SHPLOADERSTATE *state, SHPObject *obj, char **geometry) lwfree(lwpolygons); } - if (!state->config->hwgeom) + if (!state->config->use_wkt) mem = lwgeom_to_hexwkb(lwgeom, WKB_EXTENDED, &mem_length); else mem = lwgeom_to_wkt(lwgeom, WKT_EXTENDED, 12, &mem_length); @@ -784,7 +755,7 @@ set_config_defaults(SHPLOADERCONFIG *config) config->opt = 'c'; config->table = NULL; config->schema = NULL; - config->geom = strdup(GEOMETRY_DEFAULT); + config->geo_col = NULL; config->shp_file = NULL; config->dump_format = 0; config->simple_geometries = 0; @@ -795,8 +766,9 @@ set_config_defaults(SHPLOADERCONFIG *config) config->readshape = 1; config->encoding = strdup(ENCODING_DEFAULT); config->null_policy = POLICY_NULL_INSERT; - config->sr_id = -1; - config->hwgeom = 0; + config->sr_id = SRID_UNKNOWN; + config->shp_sr_id = SRID_UNKNOWN; + config->use_wkt = 0; config->tablespace = NULL; config->idxtablespace = NULL; config->usetransaction = 1; @@ -815,12 +787,39 @@ ShpLoaderCreate(SHPLOADERCONFIG *config) /* Set any state defaults */ state->hSHPHandle = NULL; state->hDBFHandle = NULL; - state->wkbtype = 0; + state->has_z = 0; + state->has_m = 0; state->types = NULL; state->widths = NULL; state->precisions = NULL; state->col_names = NULL; + state->from_srid = config->shp_sr_id; + state->to_srid = config->sr_id; + /* If only one has a valid SRID, use it for both. */ + if (state->to_srid == SRID_UNKNOWN) + { + if (config->geography) + { + state->to_srid = 4326; + } + else + { + state->to_srid = state->from_srid; + } + } + if (state->from_srid == SRID_UNKNOWN) + { + state->from_srid = state->to_srid; + } + + /* If the geo col name is not set, use one of the defaults. */ + state->geo_col = config->geo_col; + if (!state->geo_col) + { + state->geo_col = strdup(config->geography ? GEOGRAPHY_DEFAULT : GEOMETRY_DEFAULT); + } + return state; } @@ -892,155 +891,114 @@ ShpLoaderOpenShape(SHPLOADERSTATE *state) } /* Check the shapefile type */ + int geomtype = 0; switch (state->shpfiletype) { case SHPT_POINT: /* Point */ state->pgtype = "POINT"; - state->wkbtype = POINTTYPE; + geomtype = POINTTYPE; state->pgdims = 2; break; case SHPT_ARC: /* PolyLine */ state->pgtype = "MULTILINESTRING"; - state->wkbtype = MULTILINETYPE ; + geomtype = MULTILINETYPE ; state->pgdims = 2; break; case SHPT_POLYGON: /* Polygon */ state->pgtype = "MULTIPOLYGON"; - state->wkbtype = MULTIPOLYGONTYPE; + geomtype = MULTIPOLYGONTYPE; state->pgdims = 2; break; case SHPT_MULTIPOINT: /* MultiPoint */ state->pgtype = "MULTIPOINT"; - state->wkbtype = MULTIPOINTTYPE; + geomtype = MULTIPOINTTYPE; state->pgdims = 2; break; case SHPT_POINTM: /* PointM */ - state->wkbtype = POINTTYPE | WKBMOFFSET; - - if (!state->config->hwgeom) - { - state->pgtype = "POINTM"; - state->pgdims = 3; - state->istypeM = 1; - } - else - { - state->pgtype = "POINT"; - state->pgdims = 2; - } + geomtype = POINTTYPE; + state->has_m = 1; + state->pgtype = "POINTM"; + state->pgdims = 3; + state->istypeM = 1; break; case SHPT_ARCM: /* PolyLineM */ - state->wkbtype = MULTILINETYPE | WKBMOFFSET; - - if (!state->config->hwgeom) - { - state->pgtype = "MULTILINESTRINGM"; - state->pgdims = 3; - state->istypeM = 1; - } - else - { - state->pgtype = "MULTILINESTRING"; - state->pgdims = 2; - } + geomtype = MULTILINETYPE; + state->has_m = 1; + state->pgtype = "MULTILINESTRINGM"; + state->pgdims = 3; + state->istypeM = 1; break; case SHPT_POLYGONM: /* PolygonM */ - state->wkbtype = MULTIPOLYGONTYPE | WKBMOFFSET; - - if (!state->config->hwgeom) - { - state->pgtype = "MULTIPOLYGONM"; - state->pgdims = 3; - state->istypeM = 1; - } - else - { - state->pgtype = "MULTIPOLYGON"; - state->pgdims = 2; - } + geomtype = MULTIPOLYGONTYPE; + state->has_m = 1; + state->pgtype = "MULTIPOLYGONM"; + state->pgdims = 3; + state->istypeM = 1; break; case SHPT_MULTIPOINTM: /* MultiPointM */ - state->wkbtype = MULTIPOINTTYPE | WKBMOFFSET; - - if (!state->config->hwgeom) - { - state->pgtype = "MULTIPOINTM"; - state->pgdims = 3; - state->istypeM = 1; - } - else - { - state->pgtype = "MULTIPOINT"; - state->pgdims = 2; - } + geomtype = MULTIPOINTTYPE; + state->has_m = 1; + state->pgtype = "MULTIPOINTM"; + state->pgdims = 3; + state->istypeM = 1; break; case SHPT_POINTZ: /* PointZ */ - state->wkbtype = POINTTYPE | WKBMOFFSET | WKBZOFFSET; + geomtype = POINTTYPE; + state->has_m = 1; + state->has_z = 1; state->pgtype = "POINT"; - - if (!state->config->hwgeom) - state->pgdims = 4; - else - state->pgdims = 3; - + state->pgdims = 4; break; case SHPT_ARCZ: /* PolyLineZ */ state->pgtype = "MULTILINESTRING"; - state->wkbtype = MULTILINETYPE | WKBZOFFSET | WKBMOFFSET; - - if (!state->config->hwgeom) - state->pgdims = 4; - else - state->pgdims = 3; - + geomtype = MULTILINETYPE; + state->has_z = 1; + state->has_m = 1; + state->pgdims = 4; break; case SHPT_POLYGONZ: /* MultiPolygonZ */ state->pgtype = "MULTIPOLYGON"; - state->wkbtype = MULTIPOLYGONTYPE | WKBZOFFSET | WKBMOFFSET; - - if (!state->config->hwgeom) - state->pgdims = 4; - else - state->pgdims = 3; - + geomtype = MULTIPOLYGONTYPE; + state->has_z = 1; + state->has_m = 1; + state->pgdims = 4; break; case SHPT_MULTIPOINTZ: /* MultiPointZ */ state->pgtype = "MULTIPOINT"; - state->wkbtype = MULTIPOINTTYPE | WKBZOFFSET | WKBMOFFSET; - - if (!state->config->hwgeom) - state->pgdims = 4; - else - state->pgdims = 3; - + geomtype = MULTIPOINTTYPE; + state->has_z = 1; + state->has_m = 1; + state->pgdims = 4; break; default: state->pgtype = "GEOMETRY"; - state->wkbtype = COLLECTIONTYPE | WKBZOFFSET | WKBMOFFSET; + geomtype = COLLECTIONTYPE; + state->has_z = 1; + state->has_m = 1; state->pgdims = 4; snprintf(state->message, SHPLOADERMSGLEN, _("Unknown geometry type: %d\n"), state->shpfiletype); @@ -1052,11 +1010,11 @@ ShpLoaderOpenShape(SHPLOADERSTATE *state) /* If in simple geometry mode, alter names for CREATE TABLE by skipping MULTI */ if (state->config->simple_geometries) { - if ((state->wkbtype & 0x7) == MULTIPOLYGONTYPE) - state->pgtype += 5; - - if ((state->wkbtype & 0x7) == MULTILINETYPE) + if ((geomtype == MULTIPOLYGONTYPE) || (geomtype == MULTILINETYPE) || (geomtype == MULTIPOINTTYPE)) + { + /* Chop off the "MULTI" from the string. */ state->pgtype += 5; + } } } @@ -1172,7 +1130,7 @@ ShpLoaderOpenShape(SHPLOADERSTATE *state) /* Append the geometry column if required */ if (state->config->readshape == 1) - strcat(state->col_names, state->config->geom); + strcat(state->col_names, state->geo_col); strcat(state->col_names, ")"); @@ -1222,7 +1180,7 @@ ShpLoaderGetSQLHeader(SHPLOADERSTATE *state, char **strheader) if (state->config->readshape == 1 && (! state->config->geography) ) { stringbuffer_aprintf(sb, "SELECT DropGeometryColumn('%s','%s','%s');\n", - state->config->schema, state->config->table, state->config->geom); + state->config->schema, state->config->table, state->geo_col); } stringbuffer_aprintf(sb, "DROP TABLE \"%s\".\"%s\";\n", state->config->schema, @@ -1233,7 +1191,7 @@ ShpLoaderGetSQLHeader(SHPLOADERSTATE *state, char **strheader) if (state->config->readshape == 1 && (! state->config->geography) ) { stringbuffer_aprintf(sb, "SELECT DropGeometryColumn('','%s','%s');\n", - state->config->table, state->config->geom); + state->config->table, state->geo_col); } stringbuffer_aprintf(sb, "DROP TABLE \"%s\";\n", state->config->table); @@ -1331,13 +1289,13 @@ ShpLoaderGetSQLHeader(SHPLOADERSTATE *state, char **strheader) dimschar = "ZM"; else dimschar = ""; - if (state->config->sr_id != SRID_UNKNOWN && state->config->sr_id != 4326) + if (state->to_srid != SRID_UNKNOWN && state->to_srid != 4326) { - snprintf(state->message, SHPLOADERMSGLEN, _("Invalid SRID for geography type: %x"), state->config->sr_id); + snprintf(state->message, SHPLOADERMSGLEN, _("Invalid SRID for geography type: %x"), state->to_srid); stringbuffer_destroy(sb); return SHPLOADERERR; } - stringbuffer_aprintf(sb, ",\n\"%s\" geography(%s%s,%d)", state->config->geom, state->pgtype, dimschar, 4326); + stringbuffer_aprintf(sb, ",\n\"%s\" geography(%s%s,%d)", state->geo_col, state->pgtype, dimschar, 4326); } stringbuffer_aprintf(sb, ")"); @@ -1385,15 +1343,17 @@ ShpLoaderGetSQLHeader(SHPLOADERSTATE *state, char **strheader) /* Create the geometry column with an addgeometry call */ if (state->config->readshape == 1 && (!state->config->geography)) { + /* If they didn't specify a target SRID, see if they specified a source SRID. */ + int srid = state->to_srid; if (state->config->schema) { stringbuffer_aprintf(sb, "SELECT AddGeometryColumn('%s','%s','%s','%d',", - state->config->schema, state->config->table, state->config->geom, state->config->sr_id); + state->config->schema, state->config->table, state->geo_col, srid); } else { stringbuffer_aprintf(sb, "SELECT AddGeometryColumn('','%s','%s','%d',", - state->config->table, state->config->geom, state->config->sr_id); + state->config->table, state->geo_col, srid); } stringbuffer_aprintf(sb, "'%s',%d);\n", state->pgtype, state->pgdims); @@ -1649,97 +1609,68 @@ ShpLoaderGenerateSQLRowStatement(SHPLOADERSTATE *state, int item, char **strreco case SHPT_POLYGONM: case SHPT_POLYGONZ: res = GeneratePolygonGeometry(state, obj, &geometry); - if (res != SHPLOADEROK) - { - /* Error message has already been set */ - SHPDestroyObject(obj); - stringbuffer_destroy(sbwarn); - stringbuffer_destroy(sb); - - return SHPLOADERERR; - } break; case SHPT_POINT: case SHPT_POINTM: case SHPT_POINTZ: + res = GeneratePointGeometry(state, obj, &geometry, 0); + break; + case SHPT_MULTIPOINT: case SHPT_MULTIPOINTM: case SHPT_MULTIPOINTZ: - res = GeneratePointGeometry(state, obj, &geometry); - if (res != SHPLOADEROK) - { - /* Error message has already been set */ - SHPDestroyObject(obj); - stringbuffer_destroy(sbwarn); - stringbuffer_destroy(sb); - - return SHPLOADERERR; - } + /* Force it to multi unless using -S */ + res = GeneratePointGeometry(state, obj, &geometry, + state->config->simple_geometries ? 0 : 1); break; case SHPT_ARC: case SHPT_ARCM: case SHPT_ARCZ: res = GenerateLineStringGeometry(state, obj, &geometry); - if (res != SHPLOADEROK) - { - /* Error message has already been set */ - SHPDestroyObject(obj); - stringbuffer_destroy(sbwarn); - stringbuffer_destroy(sb); - - return SHPLOADERERR; - } break; default: snprintf(state->message, SHPLOADERMSGLEN, _("Shape type is not supported, type id = %d"), obj->nSHPType); - SHPDestroyObject(obj); stringbuffer_destroy(sbwarn); stringbuffer_destroy(sb); return SHPLOADERERR; } + /* The default returns out of the function, so res will always have been set. */ + if (res != SHPLOADEROK) + { + /* Error message has already been set */ + SHPDestroyObject(obj); + stringbuffer_destroy(sbwarn); + stringbuffer_destroy(sb); + return SHPLOADERERR; + } /* Now generate the geometry string according to the current configuration */ - if (state->config->hwgeom) + if (!state->config->dump_format) { - /* Old-style hwgeom (WKT) */ - if (!state->config->dump_format) - stringbuffer_aprintf(sb, "GeomFromText('"); - else + if (state->to_srid != state->from_srid) { - /* Output SRID if relevant */ - if (state->config->sr_id != 0) - stringbuffer_aprintf(sb, "SRID=%d;", state->config->sr_id); + stringbuffer_aprintf(sb, "ST_Transform("); } + stringbuffer_aprintf(sb, "'"); + } - stringbuffer_aprintf(sb, "%s", geometry); - - if (!state->config->dump_format) - { - stringbuffer_aprintf(sb, "'"); + stringbuffer_aprintf(sb, "%s", geometry); - /* Output SRID if relevant */ - if (state->config->sr_id != 0) - stringbuffer_aprintf(sb, ", %d)", state->config->sr_id); - else - stringbuffer_aprintf(sb, ")"); - } - } - else + if (!state->config->dump_format) { - /* New style lwgeom (HEXEWKB) */ - if (!state->config->dump_format) - stringbuffer_aprintf(sb, "'"); + stringbuffer_aprintf(sb, "'"); - stringbuffer_aprintf(sb, "%s", geometry); - - if (!state->config->dump_format) - stringbuffer_aprintf(sb, "'"); + /* Close the ST_Transform if reprojecting. */ + if (state->to_srid != state->from_srid) + { + stringbuffer_aprintf(sb, ", %d)", state->to_srid); + } } free(geometry); @@ -1800,13 +1731,13 @@ ShpLoaderGetSQLFooter(SHPLOADERSTATE *state, char **strfooter) /* Create gist index if specified and not in "prepare" mode */ if (state->config->createindex) { - stringbuffer_aprintf(sb, "CREATE INDEX \"%s_%s_gist\" ON ", state->config->table, state->config->geom); + stringbuffer_aprintf(sb, "CREATE INDEX \"%s_%s_gist\" ON ", state->config->table, state->geo_col); /* Schema is optional, include if present. */ if (state->config->schema) { stringbuffer_aprintf(sb, "\"%s\".",state->config->schema); } - stringbuffer_aprintf(sb, "\"%s\" USING GIST (\"%s\" %s)", state->config->table, state->config->geom, ops); + stringbuffer_aprintf(sb, "\"%s\" USING GIST (\"%s\" %s)", state->config->table, state->geo_col, ops); /* Tablespace is also optional. */ if (state->config->idxtablespace != NULL) { diff --git a/loader/shp2pgsql-core.h b/loader/shp2pgsql-core.h index 060a1d9ef..d44325d75 100644 --- a/loader/shp2pgsql-core.h +++ b/loader/shp2pgsql-core.h @@ -93,8 +93,8 @@ typedef struct shp_loader_config /* schema to load into */ char *schema; - /* geometry column name to use */ - char *geom; + /* geometry/geography column name specified by the user, may be null. */ + char *geo_col; /* the shape file (without the .shp extension) */ char *shp_file; @@ -135,8 +135,11 @@ typedef struct shp_loader_config /* SRID specified */ int sr_id; - /* 0 = new style (PostGIS 1.x) geometries, 1 = old style (PostGIS 0.9.x) geometries */ - int hwgeom; + /* SRID of the shape file */ + int shp_sr_id; + + /* 0 = WKB (more precise), 1 = WKT (may have coordinate drift). */ + int use_wkt; /* whether to do a single transaction or run each statement on its own */ int usetransaction; @@ -186,8 +189,10 @@ typedef struct shp_loader_state /* String containing the PostGIS geometry type, e.g. POINT, POLYGON etc. */ char *pgtype; - /* PostGIS geometry type (numeric version) */ - uint32 wkbtype; + /* Flag for whether the geometry has Z coordinates or not. */ + int has_z; + /* Flag for whether the geometry has M coordinates or not. */ + int has_m; /* Number of dimensions to output */ int pgdims; @@ -198,6 +203,16 @@ typedef struct shp_loader_state /* Last (error) message */ char message[SHPLOADERMSGLEN]; + /* SRID of the shape file. If not reprojecting, will be the same as to_srid. */ + int from_srid; + + /* SRID of the table. If not reprojecting, will be the same as from_srid. */ + int to_srid; + + /* geometry/geography column name to use. Will be set to the default if the config did + not specify a column name. */ + char *geo_col; + } SHPLOADERSTATE; diff --git a/loader/shp2pgsql-gui.c b/loader/shp2pgsql-gui.c index 67e2f5944..ef41cf88c 100644 --- a/loader/shp2pgsql-gui.c +++ b/loader/shp2pgsql-gui.c @@ -718,8 +718,8 @@ pgui_set_config_from_options_ui() current_node->tree_iterator, GEOMETRY_COLUMN, GEOGRAPHY_DEFAULT, -1); - free(config->geom); - config->geom = strdup(GEOGRAPHY_DEFAULT); + free(config->geo_col); + config->geo_col = strdup(GEOGRAPHY_DEFAULT); } current_node = get_next_node(current_node); } @@ -739,8 +739,8 @@ pgui_set_config_from_options_ui() current_node->tree_iterator, GEOMETRY_COLUMN, GEOMETRY_DEFAULT, -1); - free(config->geom); - config->geom = strdup(GEOMETRY_DEFAULT); + free(config->geo_col); + config->geo_col = strdup(GEOMETRY_DEFAULT); } current_node = get_next_node(current_node); } @@ -814,9 +814,9 @@ pgui_set_config_from_ui(FILENODE *file_node) config->schema = strdup(file_node->schema); if (strlen(file_node->geom_column) == 0) - config->geom = strdup(GEOMETRY_DEFAULT); + config->geo_col = strdup(GEOMETRY_DEFAULT); else - config->geom = strdup(file_node->geom_column); + config->geo_col = strdup(file_node->geom_column); /* Set the destination filename: note the shp2pgsql core engine simply wants the file without the .shp extension */ @@ -1229,7 +1229,7 @@ pgui_validate_config() return 0; } - if ( ! config->geom || strlen(config->geom) == 0 ) + if ( ! config->geo_col || strlen(config->geo_col) == 0 ) { pgui_seterr(_("Fill in the destination column.")); return 0; @@ -1746,7 +1746,7 @@ pgui_action_import(GtkWidget *widget, gpointer data) } pgui_logf("\n=============================="); - pgui_logf("Importing with configuration: %s, %s, %s, %s, mode=%c, dump=%d, simple=%d, geography=%d, index=%d, shape=%d, srid=%d", config->table, config->schema, config->geom, config->shp_file, config->opt, config->dump_format, config->simple_geometries, config->geography, config->createindex, config->readshape, config->sr_id); + pgui_logf("Importing with configuration: %s, %s, %s, %s, mode=%c, dump=%d, simple=%d, geography=%d, index=%d, shape=%d, srid=%d", config->table, config->schema, config->geo_col, config->shp_file, config->opt, config->dump_format, config->simple_geometries, config->geography, config->createindex, config->readshape, config->sr_id); /* Log what we know so far */ connection_sanitized = strdup(connection_string); diff --git a/regress/Makefile.in b/regress/Makefile.in index a11e2249b..7762955cd 100644 --- a/regress/Makefile.in +++ b/regress/Makefile.in @@ -41,6 +41,10 @@ TESTS = \ loader/TSIPolygon \ loader/TSTIPolygon \ loader/NoTransPoint \ + loader/NotReallyMultiPoint \ + loader/MultiToSinglePoint \ + loader/ReprojectPts \ + loader/ReprojectPtsGeog \ regress \ regress_index \ regress_index_nulls \ diff --git a/regress/loader/Arc-wkb.expected b/regress/loader/Arc-w.select.expected similarity index 100% rename from regress/loader/Arc-wkb.expected rename to regress/loader/Arc-w.select.expected diff --git a/regress/loader/Arc-wkt.expected b/regress/loader/Arc.select.expected similarity index 100% rename from regress/loader/Arc-wkt.expected rename to regress/loader/Arc.select.expected diff --git a/regress/loader/ArcM-wkb.sql b/regress/loader/Arc.select.sql similarity index 100% rename from regress/loader/ArcM-wkb.sql rename to regress/loader/Arc.select.sql diff --git a/regress/loader/Arc.shp.expected b/regress/loader/Arc.shp.expected new file mode 100644 index 0000000000000000000000000000000000000000..db615cf1d7cd318df6d2825d6da8f988cda59f72 GIT binary patch literal 400 zcmZQzQ0HR64o=1*%nqcmL3L#N2dto%pUKovHKTsdS4u~Nl L4yZItABO_~j#&-k literal 0 HcmV?d00001 diff --git a/regress/loader/ArcM-wkb.expected b/regress/loader/ArcM-w.select.expected similarity index 100% rename from regress/loader/ArcM-wkb.expected rename to regress/loader/ArcM-w.select.expected diff --git a/regress/loader/ArcM-wkt.expected b/regress/loader/ArcM-wkt.expected deleted file mode 100644 index b894f93a9..000000000 --- a/regress/loader/ArcM-wkt.expected +++ /dev/null @@ -1,3 +0,0 @@ -01050000000300000001020000000200000000000000000000000000000000000000000000000000F03F000000000000F03F0102000000020000000000000000000840000000000000084000000000000010400000000000001040010200000003000000000000000000244000000000000024400000000000001440000000000000144000000000000008400000000000000840 -000000000500000003000000000200000002000000000000000000000000000000003FF00000000000003FF00000000000000000000002000000024008000000000000400800000000000040100000000000004010000000000000000000000200000003402400000000000040240000000000004014000000000000401400000000000040080000000000004008000000000000 -MULTILINESTRING((0 0,1 1),(3 3,4 4),(10 10,5 5,3 3)) diff --git a/regress/loader/ArcM-wkt.sql b/regress/loader/ArcM-wkt.sql deleted file mode 100644 index 4ac611ce5..000000000 --- a/regress/loader/ArcM-wkt.sql +++ /dev/null @@ -1,4 +0,0 @@ -select ST_Ashexewkb(the_geom, 'NDR') from loadedshp; -select ST_Ashexewkb(the_geom, 'XDR') from loadedshp; -select ST_Asewkt(the_geom) from loadedshp; - diff --git a/regress/loader/ArcM.select.expected b/regress/loader/ArcM.select.expected new file mode 100644 index 000000000..284c66800 --- /dev/null +++ b/regress/loader/ArcM.select.expected @@ -0,0 +1,3 @@ +01050000400300000001020000400200000000000000000000000000000000000000000000000000F03F000000000000F03F000000000000F03F0000000000000040010200004002000000000000000000084000000000000008400000000000000840000000000000104000000000000010400000000000001040010200004003000000000000000000244000000000000024400000000000001440000000000000144000000000000014400000000000001840000000000000084000000000000008400000000000001C40 +004000000500000003004000000200000002000000000000000000000000000000003FF00000000000003FF00000000000003FF0000000000000400000000000000000400000020000000240080000000000004008000000000000400800000000000040100000000000004010000000000000401000000000000000400000020000000340240000000000004024000000000000401400000000000040140000000000004014000000000000401800000000000040080000000000004008000000000000401C000000000000 +MULTILINESTRINGM((0 0 1,1 1 2),(3 3 3,4 4 4),(10 10 5,5 5 6,3 3 7)) diff --git a/regress/loader/Arc-wkb.sql b/regress/loader/ArcM.select.sql similarity index 99% rename from regress/loader/Arc-wkb.sql rename to regress/loader/ArcM.select.sql index a7700903d..c11025de2 100644 --- a/regress/loader/Arc-wkb.sql +++ b/regress/loader/ArcM.select.sql @@ -1,4 +1,3 @@ - select ST_Ashexewkb(the_geom, 'NDR') from loadedshp; select ST_Ashexewkb(the_geom, 'XDR') from loadedshp; select ST_Asewkt(the_geom) from loadedshp; diff --git a/regress/loader/ArcM.shp.expected b/regress/loader/ArcM.shp.expected new file mode 100644 index 0000000000000000000000000000000000000000..673dc421b3692c3291e3795f4848d2108fc1bae1 GIT binary patch literal 348 zcmZQzQ0HR64%WS3W?&G>(mDAa#sDTtSRkKr0#8ffxjsfS3i$ z!bZT%htV7k5LGZ*0Lq8aFn7Xe5vV+jhUtURFmu7~2O16IGeGsh)WOV$nIi#}mvI09 Dl&%lO literal 0 HcmV?d00001 diff --git a/regress/loader/ArcZ-w.select.expected b/regress/loader/ArcZ-w.select.expected new file mode 100644 index 000000000..0f5dde7b8 --- /dev/null +++ b/regress/loader/ArcZ-w.select.expected @@ -0,0 +1,3 @@ +01050000C00300000001020000C00200000000000000000000000000000000000000000000000000F03F0000000000002240000000000000F03F000000000000F03F0000000000000040000000000000204001020000C0020000000000000000000840000000000000084000000000000008400000000000001C40000000000000104000000000000010400000000000001040000000000000184001020000C00300000000000000000024400000000000002440000000000000144000000000000014400000000000001440000000000000144000000000000018400000000000001040000000000000084000000000000008400000000000001C400000000000001040 +00C00000050000000300C000000200000002000000000000000000000000000000003FF000000000000040220000000000003FF00000000000003FF00000000000004000000000000000402000000000000000C000000200000002400800000000000040080000000000004008000000000000401C000000000000401000000000000040100000000000004010000000000000401800000000000000C0000002000000034024000000000000402400000000000040140000000000004014000000000000401400000000000040140000000000004018000000000000401000000000000040080000000000004008000000000000401C0000000000004010000000000000 +MULTILINESTRING((0 0 1 9,1 1 2 8),(3 3 3 7,4 4 4 6),(10 10 5 5,5 5 6 4,3 3 7 4)) diff --git a/regress/loader/ArcZ-wkb.expected b/regress/loader/ArcZ-wkb.expected deleted file mode 100644 index e4381fc73..000000000 --- a/regress/loader/ArcZ-wkb.expected +++ /dev/null @@ -1 +0,0 @@ -1|01050000C00300000001020000C00200000000000000000000000000000000000000000000000000F03F0000000000002240000000000000F03F000000000000F03F0000000000000040000000000000204001020000C0020000000000000000000840000000000000084000000000000008400000000000001C40000000000000104000000000000010400000000000001040000000000000184001020000C00300000000000000000024400000000000002440000000000000144000000000000014400000000000001440000000000000144000000000000018400000000000001040000000000000084000000000000008400000000000001C400000000000001040 diff --git a/regress/loader/ArcZ-wkt.expected b/regress/loader/ArcZ-wkt.expected deleted file mode 100644 index 22619e3b3..000000000 --- a/regress/loader/ArcZ-wkt.expected +++ /dev/null @@ -1 +0,0 @@ -1|01050000800300000001020000800200000000000000000000000000000000000000000000000000F03F000000000000F03F000000000000F03F0000000000000040010200008002000000000000000000084000000000000008400000000000000840000000000000104000000000000010400000000000001040010200008003000000000000000000244000000000000024400000000000001440000000000000144000000000000014400000000000001840000000000000084000000000000008400000000000001C40 diff --git a/regress/loader/ArcZ.select.expected b/regress/loader/ArcZ.select.expected new file mode 100644 index 000000000..0f5dde7b8 --- /dev/null +++ b/regress/loader/ArcZ.select.expected @@ -0,0 +1,3 @@ +01050000C00300000001020000C00200000000000000000000000000000000000000000000000000F03F0000000000002240000000000000F03F000000000000F03F0000000000000040000000000000204001020000C0020000000000000000000840000000000000084000000000000008400000000000001C40000000000000104000000000000010400000000000001040000000000000184001020000C00300000000000000000024400000000000002440000000000000144000000000000014400000000000001440000000000000144000000000000018400000000000001040000000000000084000000000000008400000000000001C400000000000001040 +00C00000050000000300C000000200000002000000000000000000000000000000003FF000000000000040220000000000003FF00000000000003FF00000000000004000000000000000402000000000000000C000000200000002400800000000000040080000000000004008000000000000401C000000000000401000000000000040100000000000004010000000000000401800000000000000C0000002000000034024000000000000402400000000000040140000000000004014000000000000401400000000000040140000000000004018000000000000401000000000000040080000000000004008000000000000401C0000000000004010000000000000 +MULTILINESTRING((0 0 1 9,1 1 2 8),(3 3 3 7,4 4 4 6),(10 10 5 5,5 5 6 4,3 3 7 4)) diff --git a/regress/loader/Arc-wkt.sql b/regress/loader/ArcZ.select.sql similarity index 99% rename from regress/loader/Arc-wkt.sql rename to regress/loader/ArcZ.select.sql index a7700903d..c11025de2 100644 --- a/regress/loader/Arc-wkt.sql +++ b/regress/loader/ArcZ.select.sql @@ -1,4 +1,3 @@ - select ST_Ashexewkb(the_geom, 'NDR') from loadedshp; select ST_Ashexewkb(the_geom, 'XDR') from loadedshp; select ST_Asewkt(the_geom) from loadedshp; diff --git a/regress/loader/ArcZ.shp.expected b/regress/loader/ArcZ.shp.expected new file mode 100644 index 0000000000000000000000000000000000000000..ed061a29afa8cae5e7c7b3db9d73fab8e1d932b1 GIT binary patch literal 420 zcmZQzQ0HR64lcc5W?)rp8!p}G+vSsD62z^SwJh%0L*+P2Z#iQ{rds_ C4h@h1 literal 0 HcmV?d00001 diff --git a/regress/loader/MultiPointM-wkb.expected b/regress/loader/MultiPointM-w.select.expected similarity index 100% rename from regress/loader/MultiPointM-wkb.expected rename to regress/loader/MultiPointM-w.select.expected diff --git a/regress/loader/MultiPointM-wkt.expected b/regress/loader/MultiPointM-wkt.expected deleted file mode 100644 index 791f6f1ed..000000000 --- a/regress/loader/MultiPointM-wkt.expected +++ /dev/null @@ -1 +0,0 @@ -MULTIPOINT(0 1,9 -1,9 -1) diff --git a/regress/loader/MultiPointM.select.expected b/regress/loader/MultiPointM.select.expected new file mode 100644 index 000000000..f0a0a857d --- /dev/null +++ b/regress/loader/MultiPointM.select.expected @@ -0,0 +1 @@ +MULTIPOINTM(0 1 3,9 -1 -3,9 -1 -123) diff --git a/regress/loader/MultiPoint-wkt.sql b/regress/loader/MultiPointM.select.sql similarity index 100% rename from regress/loader/MultiPoint-wkt.sql rename to regress/loader/MultiPointM.select.sql diff --git a/regress/loader/MultiPointM.shp.expected b/regress/loader/MultiPointM.shp.expected new file mode 100644 index 0000000000000000000000000000000000000000..4d7d5e3ec13f4ffe07fccd4e0f2bbc0bdfc7be89 GIT binary patch literal 236 zcmZQzQ0HR64$59IGcd?t$bHxk5mIu1&>!p}G#Ysz?f^uD!vRP$0!p}w8;So&ENp055z(F93Va;5Qh+B7SKvG o05f070V086Kh!;F_A@};!N70;q7N#M>Mo!Z*nJ=xq7Enz01%lOiU0rr literal 0 HcmV?d00001 diff --git a/regress/loader/MultiToSinglePoint-w.select.expected b/regress/loader/MultiToSinglePoint-w.select.expected new file mode 100644 index 000000000..38fcb4035 --- /dev/null +++ b/regress/loader/MultiToSinglePoint-w.select.expected @@ -0,0 +1,66 @@ +POINT(580936.142823 819465.261819) +POINT(506358.893822 607539.2573) +POINT(630565.963577 527840.45893) +POINT(315456.492218 345306.814089) +POINT(471022.700766 736736.493044) +POINT(500018.609208 615679.275076) +POINT(219498.722492 315980.37513) +POINT(319224.669259 318928.062446) +POINT(568650.774422 460462.130344) +POINT(556409.113539 729253.309903) +POINT(513863.46763 702618.742175) +POINT(578737.939007 752848.936015) +POINT(574438.608452 769113.196327) +POINT(542424.351008 668316.880131) +POINT(400265.835331 734407.033596) +POINT(451759.863004 412686.100724) +POINT(569910.583609 459856.20941) +POINT(463382.922609 699974.019885) +POINT(604477.021809 740527.999129) +POINT(507899.651882 708318.275563) +POINT(417174.241779 505305.090948) +POINT(577806.699527 694316.933395) +POINT(576210.383288 714992.288047) +POINT(577656.942501 695830.735896) +POINT(581803.779115 693852.464253) +POINT(483239.070139 239264.868231) +POINT(584627.388419 693322.924134) +POINT(531622.192358 716647.040901) +POINT(581975.365599 694284.048852) +POINT(446160.135881 550892.865026) +POINT(529311.590366 610942.506187) +POINT(581808.726988 695841.703111) +POINT(504782.468511 615893.186212) +POINT(622500.156248 752230.030257) +POINT(349366.222335 363016.921232) +POINT(594903.330738 545923.436928) +POINT(441308.570186 229022.749014) +POINT(605633.269659 771823.45975) +POINT(318054.396825 406677.968765) +POINT(606814.490943 683559.837391) +POINT(427202.245584 526355.921119) +POINT(585605.654583 428734.299959) +POINT(348498.220291 696622.254661) +POINT(447753.888233 552268.218021) +POINT(562081.950511 696159.347585) +POINT(449917.461534 516567.922516) +POINT(509151.607038 594632.163261) +POINT(565466.435276 673573.123642) +POINT(492421.362356 719117.799265) +POINT(613346.499962 691449.747539) +POINT(341505.393226 347633.860111) +POINT(335130.109224 221738.458568) +POINT(520476.8592 607380.893421) +POINT(610931.065288 690104.943361) +POINT(577692.981622 695342.840693) +POINT(623744.425212 697297.799336) +POINT(439667.994099 646984.255696) +POINT(507141.1403 606418.246119) +POINT(575383.92723 737533.321867) +POINT(413215.495254 523736.836314) +POINT(561887.180888 504214.422383) +POINT(583428.220764 759656.92773) +POINT(421018.925049 813910.215413) +POINT(621373.929808 690044.792874) +POINT(470983.159332 620692.73333) +POINT(508947.758357 706720.507141) diff --git a/regress/loader/MultiToSinglePoint.dbf b/regress/loader/MultiToSinglePoint.dbf new file mode 100644 index 0000000000000000000000000000000000000000..cfaee4bf1f5d8bff0e1f627fc791a19b59289c47 GIT binary patch literal 100 acmZS1XBKo~U|>*WU<8twfLDQHAO!$+fnG9{pfmZs)Wsh}YueZMw8XZ(!(_j&KW_L$$!E{~Iw!`Oq`L=JX%MQPB)SVKp8CzfT^`K3cldg~GA4(tkdFFKO96^uekH$_sgXFP> z`P+sS?9v`u+;T^3oH{FiE%@c4)0eEY`_S$Wr!Lb8w|H!v_?`U!{OYw2zxMByeHPop z_oB9Vybq@*lwaQF@^2?H(bcq4N;CNpZt>VSJ*j*{QStFzdxPk+*je}XW!VY0cx;@y zDDOS!=kysNt=!9E5Hcl?etFs&trZ4U}%tW}wW8)-8_u%~Y_8I&2?^z}q zd+^49_)HVw7LSdSoAQUVSc`NVZH7UU{ z)1OLa_wvo3ZYSL0u}M;X`-B~H_7++wF(PbQ?;Zh!TRb*SzRJg*tcjeFs?o8k^po+v zL4;d8HcnlYAN}^eiU~u5sCII+`|@OiaEr&r$)xa$eRgZ}(b*aEr&r$?u`R@Y$Wj`2qB2vX+usZ>2)m4?Hxs-IU)mK74BM zdW|Am{`fVihe5c-W8?I+^6L`&AKX~XpTCO>i_V=e2)B4_ocxvd%vkaJjZ%$LUOl`Z zs;@z~#be_XpnSgVa(=>ojY4uOukU=;Al%}yaSBx4eO29%l10H3U9aEl65~m@#be`S zQU3n9rbAQfHEQt;Z!8Ws2)B4_VwE3t^u5U=<7||1^B;3flR>z}W8)O8e81z}zb`+a z(Fz}b?n?pe10u4_oofw^T#b78z)Wq(6Rf^#?@M>PgKIhEk||2Egl;uUHLb^ z?ie$)L#J`I?|UC>wi9mg*yJIV?_0a|e8X5ja(N};o6zuXgj+l|PGQQ&E*n=??$BxF zz3peal-UTkcx;>u<=YQ54axXBkQyV}+FP1E2)B4_ob1Xsm-{Ts&eG}WNvT(x@*IR) zJT^`aVSMJV6p z-Gyzgra;4yYe9>=12m8^* zTa&Ys2O5N1JT^|xD!<7$FVFG1g^YQn>0g}U{~uwC$Hpm2`9CIu_I@cb~sEgl=Ep32{u?m5TL%Sw$e#jUp7GzhnNY@D7`zR+a8>e2%Tk6URpKLJGPd@u+9gg)Q+~ToudS3bFw1)I|=9(W~3*i=z zjZ=*BD=c;Ca}I{k;Ix@XB0kXxw|H!vUQqsxv>Dn({@!ly>2!X!w?VkYW8)O7{9OC0 z+i~kOGQX8xp3>VO+~Tou>aG0sH@|Ciato#0l7Xu?3^53|cx;^Fl)vQH(pvjVAYEH~ zCA*+HlyHm3#;K3;k&Rncn47IsG|qX^#w9x87LSe7i^_j|bU->@#x08OYDSO zJT^{!m5(|d+V+0$09sr#IdRIJ5W+1U8>fEC@0z|gx!Tak)BI6I(jhD17LScnf8`@u zU1q!1XtaJ#$Eg$14#F)S8>a!vSGvVlrBw#dd+UeK+;%dYuRk8$;<0gxSH9@9_nEBQ zI*re}Rov=j5N`3Y*q4rLjooS^( IxW!}p4-ScbBLDyZ literal 0 HcmV?d00001 diff --git a/regress/loader/MultiToSinglePoint.shp.expected b/regress/loader/MultiToSinglePoint.shp.expected new file mode 100644 index 0000000000000000000000000000000000000000..6c33d96caa37caa79681c6cca76017beb366032b GIT binary patch literal 1948 zcmZwIdo;Mtp*jIE?enhS6e7*lP=bgQ0b&>RFpM{ z)H<=Na!x5((VjY1#Ic+bHmAkNqDWS%C6dNv=l6D=&h9zQAM?lWbH4BUJn#FQ-;cqN zvlt)!F&p}r48}CQT`$kCU0=rn-vQaxb(W@Zsn7q#Dt9Ry<*^fH7%1VR@&7-hmtoO= zE3L#U(@LrTW)08=Y`@HS^h^k4HDyP4BuVIX^%cC&;htUtZ~N~E#I${amaH>+I}JGS zJTwBqAFL@Y#@0bvBE1Huh?~?tD(6HxKc9J9W zR&wZ^FTglMpdK> zz)xwn(`7E7&RL?Vn;TSN!4%vt32*kaB>l}mTf6;E(WVtP&=};%N)8}BaM13jsZ0+> zO5k0KW@<|o*^i5su1h%ga!Lryq?wws9FpUGu%6SSe*5|GcK{U_+#;lFnTd9Lqhg2c z1qxInPyh0tOLDW&&ilDn=Vj{8rT1V)*8^f!Xza+;Cxf{Z1b$t6z+oXVK3a;nFU7Z# z0#Rb|i(9jaS);MeHZ9MNwFSo($&jHlo32HGHrdrtv!jKA5w=2`sUSHUv^8~yf>yhV zA#&&+ZbJt#TeL;>bABtVqF_Fk$+vpngAlDS*zO0<1p?sa_LOQH$;^w;p2aV9^pK0; z;i!r^kw<1%jK(Tg@7=2JVZ?cI=aTpRQD{=1%1+ltA-FmCZn;uNauT%7*QUHzOi5rv z<6-mr!{m;nXbT&!cDMTQ!00RAU!;nebnkX(>ZA?%g>ng;8o$wLm{01Ip-ohEERTF; z4O*pcVr1Bq&e@|47g{96$4Fq-*5KzI8Zx_bw6I-y1c-t1qOi%r!kc^z2;|V(cKx3 zS1jW}@9UuWfW_pFW}{uQ)M(`22tc+kH~hyovZe#t(@pukOXL)=etvVk+@0hc(Qd8D zZXMYtfFk?LMOzX@^nP>D%=VlMi{*%*zXfHPZs%4l+Au)S#*2U$-T+yEKM#dWdw1$D4{`j*ayb$RdN$m}jeb9f}x9d_Zvk%l0@ZKLEK7NM1f zfTWQS&-;%#8F$JNX9GG{`U7=)Xr-jH08JgQSPWXm@i`jJ+*HFfr{i6HdwC EU-e|;%K!iX literal 0 HcmV?d00001 diff --git a/regress/loader/MultiToSinglePoint.shx b/regress/loader/MultiToSinglePoint.shx new file mode 100644 index 0000000000000000000000000000000000000000..59f0cb91370a41d607691be2b879bfacf098c5cc GIT binary patch literal 628 zcmZw8F=|3V5XSNKy=Wd!EF7>)7ecU|(n5H(-H3?S*eeJgU@sBGDtmym7U}jB7O~kA zYzCF4lsIh8_b(Oqh!=f{KP714c}k oi(^4WLyrL?Cd|c&prWD2fDses;;W#dp~rv`6Xs$gsAv!W0lDZm3;+NC literal 0 HcmV?d00001 diff --git a/regress/loader/NoTransPoint-wkb.expected b/regress/loader/NoTransPoint-w.select.expected similarity index 100% rename from regress/loader/NoTransPoint-wkb.expected rename to regress/loader/NoTransPoint-w.select.expected diff --git a/regress/loader/NoTransPoint-wkt.expected b/regress/loader/NoTransPoint.select.expected similarity index 100% rename from regress/loader/NoTransPoint-wkt.expected rename to regress/loader/NoTransPoint.select.expected diff --git a/regress/loader/MultiPointZ-wkb.sql b/regress/loader/NoTransPoint.select.sql similarity index 100% rename from regress/loader/MultiPointZ-wkb.sql rename to regress/loader/NoTransPoint.select.sql diff --git a/regress/loader/NoTransPoint.shp.expected b/regress/loader/NoTransPoint.shp.expected new file mode 100644 index 0000000000000000000000000000000000000000..51d38e75d0d84b98527aef900b79e814ac0d7b6a GIT binary patch literal 184 zcmZQzQ0HR64q{#~GcYh>$bHxk5mIu1&>!p}G+q*93>Ox&Kzf-_<&+$Nd>{bZ19Snh NJ|zbr9|%6|2LKu+3Nioy literal 0 HcmV?d00001 diff --git a/regress/loader/NotReallyMultiPoint-w.select.expected b/regress/loader/NotReallyMultiPoint-w.select.expected new file mode 100644 index 000000000..e145e3150 --- /dev/null +++ b/regress/loader/NotReallyMultiPoint-w.select.expected @@ -0,0 +1,66 @@ +MULTIPOINT(580936.142823 819465.261819) +MULTIPOINT(506358.893822 607539.2573) +MULTIPOINT(630565.963577 527840.45893) +MULTIPOINT(315456.492218 345306.814089) +MULTIPOINT(471022.700766 736736.493044) +MULTIPOINT(500018.609208 615679.275076) +MULTIPOINT(219498.722492 315980.37513) +MULTIPOINT(319224.669259 318928.062446) +MULTIPOINT(568650.774422 460462.130344) +MULTIPOINT(556409.113539 729253.309903) +MULTIPOINT(513863.46763 702618.742175) +MULTIPOINT(578737.939007 752848.936015) +MULTIPOINT(574438.608452 769113.196327) +MULTIPOINT(542424.351008 668316.880131) +MULTIPOINT(400265.835331 734407.033596) +MULTIPOINT(451759.863004 412686.100724) +MULTIPOINT(569910.583609 459856.20941) +MULTIPOINT(463382.922609 699974.019885) +MULTIPOINT(604477.021809 740527.999129) +MULTIPOINT(507899.651882 708318.275563) +MULTIPOINT(417174.241779 505305.090948) +MULTIPOINT(577806.699527 694316.933395) +MULTIPOINT(576210.383288 714992.288047) +MULTIPOINT(577656.942501 695830.735896) +MULTIPOINT(581803.779115 693852.464253) +MULTIPOINT(483239.070139 239264.868231) +MULTIPOINT(584627.388419 693322.924134) +MULTIPOINT(531622.192358 716647.040901) +MULTIPOINT(581975.365599 694284.048852) +MULTIPOINT(446160.135881 550892.865026) +MULTIPOINT(529311.590366 610942.506187) +MULTIPOINT(581808.726988 695841.703111) +MULTIPOINT(504782.468511 615893.186212) +MULTIPOINT(622500.156248 752230.030257) +MULTIPOINT(349366.222335 363016.921232) +MULTIPOINT(594903.330738 545923.436928) +MULTIPOINT(441308.570186 229022.749014) +MULTIPOINT(605633.269659 771823.45975) +MULTIPOINT(318054.396825 406677.968765) +MULTIPOINT(606814.490943 683559.837391) +MULTIPOINT(427202.245584 526355.921119) +MULTIPOINT(585605.654583 428734.299959) +MULTIPOINT(348498.220291 696622.254661) +MULTIPOINT(447753.888233 552268.218021) +MULTIPOINT(562081.950511 696159.347585) +MULTIPOINT(449917.461534 516567.922516) +MULTIPOINT(509151.607038 594632.163261) +MULTIPOINT(565466.435276 673573.123642) +MULTIPOINT(492421.362356 719117.799265) +MULTIPOINT(613346.499962 691449.747539) +MULTIPOINT(341505.393226 347633.860111) +MULTIPOINT(335130.109224 221738.458568) +MULTIPOINT(520476.8592 607380.893421) +MULTIPOINT(610931.065288 690104.943361) +MULTIPOINT(577692.981622 695342.840693) +MULTIPOINT(623744.425212 697297.799336) +MULTIPOINT(439667.994099 646984.255696) +MULTIPOINT(507141.1403 606418.246119) +MULTIPOINT(575383.92723 737533.321867) +MULTIPOINT(413215.495254 523736.836314) +MULTIPOINT(561887.180888 504214.422383) +MULTIPOINT(583428.220764 759656.92773) +MULTIPOINT(421018.925049 813910.215413) +MULTIPOINT(621373.929808 690044.792874) +MULTIPOINT(470983.159332 620692.73333) +MULTIPOINT(508947.758357 706720.507141) diff --git a/regress/loader/NotReallyMultiPoint.dbf b/regress/loader/NotReallyMultiPoint.dbf new file mode 100644 index 0000000000000000000000000000000000000000..cfaee4bf1f5d8bff0e1f627fc791a19b59289c47 GIT binary patch literal 100 acmZS1XBKo~U|>*WU<8twfLDQHAO!$+fnG9{pfmZs)Wsh}YueZMw8XZ(!(_j&KW_L$$!E{~Iw!`Oq`L=JX%MQPB)SVKp8CzfT^`K3cldg~GA4(tkdFFKO96^uekH$_sgXFP> z`P+sS?9v`u+;T^3oH{FiE%@c4)0eEY`_S$Wr!Lb8w|H!v_?`U!{OYw2zxMByeHPop z_oB9Vybq@*lwaQF@^2?H(bcq4N;CNpZt>VSJ*j*{QStFzdxPk+*je}XW!VY0cx;@y zDDOS!=kysNt=!9E5Hcl?etFs&trZ4U}%tW}wW8)-8_u%~Y_8I&2?^z}q zd+^49_)HVw7LSdSoAQUVSc`NVZH7UU{ z)1OLa_wvo3ZYSL0u}M;X`-B~H_7++wF(PbQ?;Zh!TRb*SzRJg*tcjeFs?o8k^po+v zL4;d8HcnlYAN}^eiU~u5sCII+`|@OiaEr&r$)xa$eRgZ}(b*aEr&r$?u`R@Y$Wj`2qB2vX+usZ>2)m4?Hxs-IU)mK74BM zdW|Am{`fVihe5c-W8?I+^6L`&AKX~XpTCO>i_V=e2)B4_ocxvd%vkaJjZ%$LUOl`Z zs;@z~#be_XpnSgVa(=>ojY4uOukU=;Al%}yaSBx4eO29%l10H3U9aEl65~m@#be`S zQU3n9rbAQfHEQt;Z!8Ws2)B4_VwE3t^u5U=<7||1^B;3flR>z}W8)O8e81z}zb`+a z(Fz}b?n?pe10u4_oofw^T#b78z)Wq(6Rf^#?@M>PgKIhEk||2Egl;uUHLb^ z?ie$)L#J`I?|UC>wi9mg*yJIV?_0a|e8X5ja(N};o6zuXgj+l|PGQQ&E*n=??$BxF zz3peal-UTkcx;>u<=YQ54axXBkQyV}+FP1E2)B4_ob1Xsm-{Ts&eG}WNvT(x@*IR) zJT^`aVSMJV6p z-Gyzgra;4yYe9>=12m8^* zTa&Ys2O5N1JT^|xD!<7$FVFG1g^YQn>0g}U{~uwC$Hpm2`9CIu_I@cb~sEgl=Ep32{u?m5TL%Sw$e#jUp7GzhnNY@D7`zR+a8>e2%Tk6URpKLJGPd@u+9gg)Q+~ToudS3bFw1)I|=9(W~3*i=z zjZ=*BD=c;Ca}I{k;Ix@XB0kXxw|H!vUQqsxv>Dn({@!ly>2!X!w?VkYW8)O7{9OC0 z+i~kOGQX8xp3>VO+~Tou>aG0sH@|Ciato#0l7Xu?3^53|cx;^Fl)vQH(pvjVAYEH~ zCA*+HlyHm3#;K3;k&Rncn47IsG|qX^#w9x87LSe7i^_j|bU->@#x08OYDSO zJT^{!m5(|d+V+0$09sr#IdRIJ5W+1U8>fEC@0z|gx!Tak)BI6I(jhD17LScnf8`@u zU1q!1XtaJ#$Eg$14#F)S8>a!vSGvVlrBw#dd+UeK+;%dYuRk8$;<0gxSH9@9_nEBQ zI*re}Rov=j5N`3Y*q4rLjooS^( IxW!}p4-ScbBLDyZ literal 0 HcmV?d00001 diff --git a/regress/loader/NotReallyMultiPoint.shp.expected b/regress/loader/NotReallyMultiPoint.shp.expected new file mode 100644 index 0000000000000000000000000000000000000000..805fbb0b886e2bef0225d2d41a830546dff75283 GIT binary patch literal 4324 zcmZwKc~F#f9LI5#k}EEEF<@cY=YeMzC{Qy(%!99H-da`y3YkipF^b}WBV|ekWr7Hi zIbz{4qo@&qjgBcEV>+fnG9{pfmZs)Wsh}YueZMw8XZ(!(_j&KW_L$$!E{~Iw!`Oq`L=JX%MQPB)SVKp8CzfT^`K3cldg~GA4(tkdFFKO96^uekH$_sgXFP> z`P+sS?9v`u+;T^3oH{FiE%@c4)0eEY`_S$Wr!Lb8w|H!v_?`U!{OYw2zxMByeHPop z_oB9Vybq@*lwaQF@^2?H(bcq4N;CNpZt>VSJ*j*{QStFzdxPk+*je}XW!VY0cx;@y zDDOS!=kysNt=!9E5Hcl?etFs&trZ4U}%tW}wW8)-8_u%~Y_8I&2?^z}q zd+^49_)HVw7LSdSoAQUVSc`NVZH7UU{ z)1OLa_wvo3ZYSL0u}M;X`-B~H_7++wF(PbQ?;Zh!TRb*SzRJg*tcjeFs?o8k^po+v zL4;d8HcnlYAN}^eiU~u5sCII+`|@OiaEr&r$)xa$eRgZ}(b*aEr&r$?u`R@Y$Wj`2qB2vX+usZ>2)m4?Hxs-IU)mK74BM zdW|Am{`fVihe5c-W8?I+^6L`&AKX~XpTCO>i_V=e2)B4_ocxvd%vkaJjZ%$LUOl`Z zs;@z~#be_XpnSgVa(=>ojY4uOukU=;Al%}yaSBx4eO29%l10H3U9aEl65~m@#be`S zQU3n9rbAQfHEQt;Z!8Ws2)B4_VwE3t^u5U=<7||1^B;3flR>z}W8)O8e81z}zb`+a z(Fz}b?n?pe10u4_oofw^T#b78z)Wq(6Rf^#?@M>PgKIhEk||2Egl;uUHLb^ z?ie$)L#J`I?|UC>wi9mg*yJIV?_0a|e8X5ja(N};o6zuXgj+l|PGQQ&E*n=??$BxF zz3peal-UTkcx;>u<=YQ54axXBkQyV}+FP1E2)B4_ob1Xsm-{Ts&eG}WNvT(x@*IR) zJT^`aVSMJV6p z-Gyzgra;4yYe9>=12m8^* zTa&Ys2O5N1JT^|xD!<7$FVFG1g^YQn>0g}U{~uwC$Hpm2`9CIu_I@cb~sEgl=Ep32{u?m5TL%Sw$e#jUp7GzhnNY@D7`zR+a8>e2%Tk6URpKLJGPd@u+9gg)Q+~ToudS3bFw1)I|=9(W~3*i=z zjZ=*BD=c;Ca}I{k;Ix@XB0kXxw|H!vUQqsxv>Dn({@!ly>2!X!w?VkYW8)O7{9OC0 z+i~kOGQX8xp3>VO+~Tou>aG0sH@|Ciato#0l7Xu?3^53|cx;^Fl)vQH(pvjVAYEH~ zCA*+HlyHm3#;K3;k&Rncn47IsG|qX^#w9x87LSe7i^_j|bU->@#x08OYDSO zJT^{!m5(|d+V+0$09sr#IdRIJ5W+1U8>fEC@0z|gx!Tak)BI6I(jhD17LScnf8`@u zU1q!1XtaJ#$Eg$14#F)S8>a!vSGvVlrBw#dd+UeK+;%dYuRk8$;<0gxSH9@9_nEBQ zI*re}Rov=j5N`3Y*q4rLjooS^( IxW!}p4-ScbBLDyZ literal 0 HcmV?d00001 diff --git a/regress/loader/NotReallyMultiPoint.shx b/regress/loader/NotReallyMultiPoint.shx new file mode 100644 index 0000000000000000000000000000000000000000..59f0cb91370a41d607691be2b879bfacf098c5cc GIT binary patch literal 628 zcmZw8F=|3V5XSNKy=Wd!EF7>)7ecU|(n5H(-H3?S*eeJgU@sBGDtmym7U}jB7O~kA zYzCF4lsIh8_b(Oqh!=f{KP714c}k oi(^4WLyrL?Cd|c&prWD2fDses;;W#dp~rv`6Xs$gsAv!W0lDZm3;+NC literal 0 HcmV?d00001 diff --git a/regress/loader/Point-wkb.expected b/regress/loader/Point-w.select.expected similarity index 100% rename from regress/loader/Point-wkb.expected rename to regress/loader/Point-w.select.expected diff --git a/regress/loader/Point-wkt.expected b/regress/loader/Point.select.expected similarity index 100% rename from regress/loader/Point-wkt.expected rename to regress/loader/Point.select.expected diff --git a/regress/loader/NoTransPoint-wkb.sql b/regress/loader/Point.select.sql similarity index 100% rename from regress/loader/NoTransPoint-wkb.sql rename to regress/loader/Point.select.sql diff --git a/regress/loader/Point.shp.expected b/regress/loader/Point.shp.expected new file mode 100644 index 0000000000000000000000000000000000000000..51d38e75d0d84b98527aef900b79e814ac0d7b6a GIT binary patch literal 184 zcmZQzQ0HR64q{#~GcYh>$bHxk5mIu1&>!p}G+q*93>Ox&Kzf-_<&+$Nd>{bZ19Snh NJ|zbr9|%6|2LKu+3Nioy literal 0 HcmV?d00001 diff --git a/regress/loader/PointM-wkb.expected b/regress/loader/PointM-w.select.expected similarity index 100% rename from regress/loader/PointM-wkb.expected rename to regress/loader/PointM-w.select.expected diff --git a/regress/loader/PointM-wkt.expected b/regress/loader/PointM-wkt.expected deleted file mode 100644 index 680e99b43..000000000 --- a/regress/loader/PointM-wkt.expected +++ /dev/null @@ -1,3 +0,0 @@ -POINT(0 1) -POINT(9 -1) -POINT(9 -1) diff --git a/regress/loader/PointM.select.expected b/regress/loader/PointM.select.expected new file mode 100644 index 000000000..4004ce789 --- /dev/null +++ b/regress/loader/PointM.select.expected @@ -0,0 +1,3 @@ +POINTM(0 1 3) +POINTM(9 -1 -3) +POINTM(9 -1 -123) diff --git a/regress/loader/PointM-wkb.sql b/regress/loader/PointM.select.sql similarity index 100% rename from regress/loader/PointM-wkb.sql rename to regress/loader/PointM.select.sql diff --git a/regress/loader/PointM.shp.expected b/regress/loader/PointM.shp.expected new file mode 100644 index 0000000000000000000000000000000000000000..03da6b4863dc832854692886df3f3bed8a678c16 GIT binary patch literal 208 zcmZQzQ0HR64l-UaGcbr^$bHxk5mIu1&>!p}G#Ysz?f^uD!vRP$0x=&Jv!HsxYM4;f eC^-Q6KmfCk;{cEYbP=*SN)A9i5J1%c?F0Zcn-8u4 literal 0 HcmV?d00001 diff --git a/regress/loader/PointZ-wkb.expected b/regress/loader/PointZ-w.select.expected similarity index 100% rename from regress/loader/PointZ-wkb.expected rename to regress/loader/PointZ-w.select.expected diff --git a/regress/loader/PointZ-wkb.sql b/regress/loader/PointZ-wkb.sql deleted file mode 100644 index 031c1196e..000000000 --- a/regress/loader/PointZ-wkb.sql +++ /dev/null @@ -1 +0,0 @@ -select ST_Asewkt(the_geom) from loadedshp; diff --git a/regress/loader/PointZ-wkt.expected b/regress/loader/PointZ-wkt.expected deleted file mode 100644 index 6cadbea2c..000000000 --- a/regress/loader/PointZ-wkt.expected +++ /dev/null @@ -1,3 +0,0 @@ -POINT(0 1 2) -POINT(9 -1 -2) -POINT(9 -1 -20) diff --git a/regress/loader/PointZ-wkt.sql b/regress/loader/PointZ-wkt.sql deleted file mode 100644 index 031c1196e..000000000 --- a/regress/loader/PointZ-wkt.sql +++ /dev/null @@ -1 +0,0 @@ -select ST_Asewkt(the_geom) from loadedshp; diff --git a/regress/loader/PointZ.select.expected b/regress/loader/PointZ.select.expected new file mode 100644 index 000000000..ecb35160b --- /dev/null +++ b/regress/loader/PointZ.select.expected @@ -0,0 +1,3 @@ +POINT(0 1 2 3) +POINT(9 -1 -2 -3) +POINT(9 -1 -20 -123) diff --git a/regress/loader/PointM-wkt.sql b/regress/loader/PointZ.select.sql similarity index 100% rename from regress/loader/PointM-wkt.sql rename to regress/loader/PointZ.select.sql diff --git a/regress/loader/PointZ.shp.expected b/regress/loader/PointZ.shp.expected new file mode 100644 index 0000000000000000000000000000000000000000..9b9ab796b51293059bd072cac98d99b0d345910d GIT binary patch literal 232 zcmZQzQ0HR64oY4yGca&t$bHxk5mIu1&>!p}w8;So&ENp055z(F93Va;5DQ^33#u2Y qhXJgX3019<1CS2{FnbvefVm7DAR6dGWOJ1qfP5f;sfD@;=oSDxaT3M= literal 0 HcmV?d00001 diff --git a/regress/loader/Polygon-wkb.expected b/regress/loader/Polygon-w.select.expected similarity index 100% rename from regress/loader/Polygon-wkb.expected rename to regress/loader/Polygon-w.select.expected diff --git a/regress/loader/Polygon-wkt.expected b/regress/loader/Polygon.select.expected similarity index 100% rename from regress/loader/Polygon-wkt.expected rename to regress/loader/Polygon.select.expected diff --git a/regress/loader/NoTransPoint-wkt.sql b/regress/loader/Polygon.select.sql similarity index 100% rename from regress/loader/NoTransPoint-wkt.sql rename to regress/loader/Polygon.select.sql diff --git a/regress/loader/Polygon.shp.expected b/regress/loader/Polygon.shp.expected new file mode 100644 index 0000000000000000000000000000000000000000..997b43fbeb2263ef74bd704aecc954b149c23f63 GIT binary patch literal 488 zcmZQzQ0HR64!*o#W?*22%c&fIFyXWVlnS25lsCpQ!fP;@q9Hvj? F000LyBU%6e literal 0 HcmV?d00001 diff --git a/regress/loader/PolygonM-wkb.expected b/regress/loader/PolygonM-w.select.expected similarity index 100% rename from regress/loader/PolygonM-wkb.expected rename to regress/loader/PolygonM-w.select.expected diff --git a/regress/loader/PolygonM.select.expected b/regress/loader/PolygonM.select.expected new file mode 100644 index 000000000..194ac8c19 --- /dev/null +++ b/regress/loader/PolygonM.select.expected @@ -0,0 +1 @@ +MULTIPOLYGONM(((0 0 1,0 10 7,10 10 5,10 0 3,0 0 1),(5 5 9,8 5 15,8 8 13,5 8 11,5 5 9)),((-1 -1 -1,-1 -10 -7,-10 -10 -5,-10 -1 -3,-1 -1 -1),(-5 -5 -9,-8 -5 -15,-8 -8 -13,-5 -8 -11,-5 -5 -9))) diff --git a/regress/loader/Point-wkb.sql b/regress/loader/PolygonM.select.sql similarity index 100% rename from regress/loader/Point-wkb.sql rename to regress/loader/PolygonM.select.sql diff --git a/regress/loader/PolygonM.shp.expected b/regress/loader/PolygonM.shp.expected new file mode 100644 index 0000000000000000000000000000000000000000..4513ab79948e9ef91af4f4d1ae10ced4f572c11a GIT binary patch literal 664 zcma)(K?;K~5Jg97LAvQC6bddRhy@p3!5pA>ZjRHXN9fe~Kc%4q4dTno%p{``xt-+a zXztI0$hE}AY}3L72hBe3CEI*S%0{2dKYO*B9IQ}|%6D^TxQ{Ve%%fKsP)81qd+V$t zw}+inv;4Dc@!IQrdO$uoIPR^pj{Le4ZDm`npFSD+9UYwU2;c8gQ)l=DMv#5?S@ywm PJ2>MJ&VFY21jhUVzqmA< literal 0 HcmV?d00001 diff --git a/regress/loader/PolygonZ-wkb.expected b/regress/loader/PolygonZ-w.select.expected similarity index 100% rename from regress/loader/PolygonZ-wkb.expected rename to regress/loader/PolygonZ-w.select.expected diff --git a/regress/loader/PolygonZ-wkb.sql b/regress/loader/PolygonZ-wkb.sql deleted file mode 100644 index e68081804..000000000 --- a/regress/loader/PolygonZ-wkb.sql +++ /dev/null @@ -1,2 +0,0 @@ -select ST_Asewkt(the_geom) from loadedshp; - diff --git a/regress/loader/PolygonZ-wkt.expected b/regress/loader/PolygonZ-wkt.expected deleted file mode 100644 index 40d5bf345..000000000 --- a/regress/loader/PolygonZ-wkt.expected +++ /dev/null @@ -1 +0,0 @@ -MULTIPOLYGON(((0 0 0,0 10 6,10 10 4,10 0 2,0 0 0),(5 5 8,8 5 14,8 8 12,5 8 10,5 5 8)),((-1 -1 -1,-1 -10 -6,-10 -10 -4,-10 -1 -2,-1 -1 -1),(-5 -5 -8,-8 -5 -14,-8 -8 -12,-5 -8 -10,-5 -5 -8))) diff --git a/regress/loader/PolygonZ-wkt.sql b/regress/loader/PolygonZ-wkt.sql deleted file mode 100644 index e68081804..000000000 --- a/regress/loader/PolygonZ-wkt.sql +++ /dev/null @@ -1,2 +0,0 @@ -select ST_Asewkt(the_geom) from loadedshp; - diff --git a/regress/loader/PolygonZ.select.expected b/regress/loader/PolygonZ.select.expected new file mode 100644 index 000000000..7370e6346 --- /dev/null +++ b/regress/loader/PolygonZ.select.expected @@ -0,0 +1 @@ +MULTIPOLYGON(((0 0 0 1,0 10 6 7,10 10 4 5,10 0 2 3,0 0 0 1),(5 5 8 9,8 5 14 15,8 8 12 13,5 8 10 11,5 5 8 9)),((-1 -1 -1 -1,-1 -10 -6 -7,-10 -10 -4 -5,-10 -1 -2 -3,-1 -1 -1 -1),(-5 -5 -8 -9,-8 -5 -14 -15,-8 -8 -12 -13,-5 -8 -10 -11,-5 -5 -8 -9))) diff --git a/regress/loader/Point-wkt.sql b/regress/loader/PolygonZ.select.sql similarity index 100% rename from regress/loader/Point-wkt.sql rename to regress/loader/PolygonZ.select.sql diff --git a/regress/loader/PolygonZ.shp.expected b/regress/loader/PolygonZ.shp.expected new file mode 100644 index 0000000000000000000000000000000000000000..be7e41faa3d4817acb0726fc64429d28dfc09821 GIT binary patch literal 840 zcma))K?;K~5JgAYf^<_CE?l?}DON?s`qG))1^n~#Q8s^!9WM~<>}s|mT< znL~CNoy)V1Twk_c%D89V{8Xp&scXz9yNu4|Sx2U4WZj4~&PEj|q@{)b&$AujbHC}c z@5WnU1qw)?{j#4CKKF(G&mGbw*Smf+TDKvdUkOdWhu-dtze>QwdGK Mhh{$$^Z@q$1GIug1^@s6 literal 0 HcmV?d00001 diff --git a/regress/loader/README b/regress/loader/README index e9d206041..4b9ae6de0 100644 --- a/regress/loader/README +++ b/regress/loader/README @@ -1,19 +1,40 @@ -Sat Jun 17 11:40:38 CEST 2006 --strk; +A loader test requires, at a minimum, a shapefile: -The ../run_test script will load a provided shapefile using both DUMP and INSERT -mode and both WKT and WKB modes into a table name 'loadedshp'. -After each WKB load, the -wkb.sql test, if available, will be run -and output compared to -wkb.expected -After each WKT load, the -wkt.sql test, if available, will be run -and output compared to -wkt.expected -We need two separate tests for WKB and WKT as the WKT mode will not support M values. +.shp +.shx +.dbf -Also, the tester script will dump the WKB loaded table and compare the resulting -shapefile with the original one (only .shp, .dbf is not compared as field sizes are not -retained, we might use a dbf viewer for that, but that's not currently implemented) +The loader will be run against the shapefile with no command-line flags, +then the output will be run via psql to insert the table into PostGIS. -Optional: - You may provide a .opts file to set custom command line options for shp2pgsql. - The first line that does not begin with a # is used. +If there is no .opts file, the loader is then run with the -D flag, +and the output again run via psql. - Also see ../README for a description of optional setup/teardown script files. +See ../README for a description of optional setup/teardown script files. + +The following are optional files for each loader test: + +.opts - If this exists, the first line that does not begin with a # + is read and passed as command line arguments to the loader. This + allows testing any arbitrary command line arguments (-s, -G, etc). + NOTE: When this file exists, this test is NOT run a second time + with -D, because -D can conflict with some arguments. + +.sql.expected - If this exists, the output of the loader is compared + with this file before running it via psql. + +.select.sql and +.select.expected - If these are present, after the loader output is + loaded into the database, the query in .select.sql is run and + the psql output is compared with .select.expected. + +.select.sql and +-w.select.expected - If these are present, the loader is also run with + the -w flag to produce WKT output rather than WKB output. The query + in .select.sql is run again and compared against + -w.select.expected. + +.shp.expected - If this is present, the dumper is run (after running + the WKB version, not the WKT version, as WKT can lose precision) + and the .shp file produced by the dumper is compared with + .shp.expected. diff --git a/regress/loader/ReprojectPts-pre.sql b/regress/loader/ReprojectPts-pre.sql new file mode 100644 index 000000000..fe7040603 --- /dev/null +++ b/regress/loader/ReprojectPts-pre.sql @@ -0,0 +1,12 @@ +-- setup the spatial_ref_sys table with the two projections +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 '); + + diff --git a/regress/loader/ReprojectPts-w.select.expected b/regress/loader/ReprojectPts-w.select.expected new file mode 100644 index 000000000..23abda98a --- /dev/null +++ b/regress/loader/ReprojectPts-w.select.expected @@ -0,0 +1,66 @@ +SRID=4326;POINT(-74.1778249234186 41.0826336069621) +SRID=4326;POINT(-74.4488128587284 40.5013374405831) +SRID=4326;POINT(-74.0037635784151 40.2814968841599) +SRID=4326;POINT(-75.1286374176544 39.779738904917) +SRID=4326;POINT(-74.5762901403342 40.8559759516941) +SRID=4326;POINT(-74.4716040112965 40.5236906585587) +SRID=4326;POINT(-75.4689168308202 39.6968833405426) +SRID=4326;POINT(-75.1145861845468 39.7073923052707) +SRID=4326;POINT(-74.2264370070618 40.097265631898) +SRID=4326;POINT(-74.267669256308 40.835226153518) +SRID=4326;POINT(-74.4215203668629 40.7623218114584) +SRID=4326;POINT(-74.1866659762657 40.8998034100653) +SRID=4326;POINT(-74.2020187391779 40.9444882709976) +SRID=4326;POINT(-74.318666634379 40.668046504386) +SRID=4326;POINT(-74.8320596317968 40.8491289846163) +SRID=4326;POINT(-74.6440210088998 39.9663370779506) +SRID=4326;POINT(-74.2219402834666 40.0955914789689) +SRID=4326;POINT(-74.6037525547762 40.7550420759644) +SRID=4326;POINT(-74.0937601839482 40.8656933573937) +SRID=4326;POINT(-74.4430374038438 40.7779796708969) +SRID=4326;POINT(-74.7684170268845 40.2203845505147) +SRID=4326;POINT(-74.1907818170678 40.739145735004) +SRID=4326;POINT(-74.1962844392102 40.7959141570767) +SRID=4326;POINT(-74.1913030602141 40.7433025340713) +SRID=4326;POINT(-74.1763630799163 40.737831233597) +SRID=4326;POINT(-74.5314873084103 39.4902945583041) +SRID=4326;POINT(-74.1661805363706 40.7363486398654) +SRID=4326;POINT(-74.3573260684924 40.8007679302865) +SRID=4326;POINT(-74.1757381076133 40.7390141841291) +SRID=4326;POINT(-74.6649158055449 40.3457273489041) +SRID=4326;POINT(-74.3662532330192 40.5106137365586) +SRID=4326;POINT(-74.1763187562297 40.7432915904029) +SRID=4326;POINT(-74.4544664009791 40.5242723881508) +SRID=4326;POINT(-74.0283665597175 40.8975658415575) +SRID=4326;POINT(-75.0083397511198 39.8289502587993) +SRID=4326;POINT(-74.1313222061323 40.3316152829947) +SRID=4326;POINT(-74.6799952206859 39.4620385866365) +SRID=4326;POINT(-74.0890480643623 40.9515804026446) +SRID=4326;POINT(-75.1209106831221 39.9482691733624) +SRID=4326;POINT(-74.0862802471739 40.7092900894149) +SRID=4326;POINT(-74.7327024195045 40.2782515920205) +SRID=4326;POINT(-74.1662530255196 40.01000430686) +SRID=4326;POINT(-75.0183798167935 40.7447239779165) +SRID=4326;POINT(-74.6592065330533 40.3495109704879) +SRID=4326;POINT(-74.2475114317579 40.744341221767) +SRID=4326;POINT(-74.6512248373302 40.2515163382362) +SRID=4326;POINT(-74.4388020498744 40.4659008042768) +SRID=4326;POINT(-74.2355416979199 40.6823146575314) +SRID=4326;POINT(-74.4989293530256 40.8076383297076) +SRID=4326;POINT(-74.0625761975523 40.7308606221026) +SRID=4326;POINT(-75.0360016411834 39.7865925067772) +SRID=4326;POINT(-75.0559164322449 39.4408494224665) +SRID=4326;POINT(-74.3980433283985 40.5008690729179) +SRID=4326;POINT(-74.0713156694968 40.7272019085637) +SRID=4326;POINT(-74.1911791861301 40.7419629255487) +SRID=4326;POINT(-74.0249426200973 40.7467647928245) +SRID=4326;POINT(-74.688946675902 40.6094748964846) +SRID=4326;POINT(-74.4460022558058 40.49825883848) +SRID=4326;POINT(-74.198989906698 40.8577957099556) +SRID=4326;POINT(-74.7828046028596 40.2709499874624) +SRID=4326;POINT(-74.2501753633512 40.2174320022045) +SRID=4326;POINT(-74.169605505782 40.9184432569356) +SRID=4326;POINT(-74.7578885232984 41.0675476294558) +SRID=4326;POINT(-74.0336372902943 40.7268907140294) +SRID=4326;POINT(-74.5760699023108 40.537431636642) +SRID=4326;POINT(-74.4392566663626 40.7735918687511) diff --git a/regress/loader/ReprojectPts.dbf b/regress/loader/ReprojectPts.dbf new file mode 100644 index 0000000000000000000000000000000000000000..cfaee4bf1f5d8bff0e1f627fc791a19b59289c47 GIT binary patch literal 100 acmZS1XBKo~U|>*WU<8twfLDQHAO!$+fnG9{pfmZs)Wsh}YueZMw8XZ(!(_j&KW_L$$!E{~Iw!`Oq`L=JX%MQPB)SVKp8CzfT^`K3cldg~GA4(tkdFFKO96^uekH$_sgXFP> z`P+sS?9v`u+;T^3oH{FiE%@c4)0eEY`_S$Wr!Lb8w|H!v_?`U!{OYw2zxMByeHPop z_oB9Vybq@*lwaQF@^2?H(bcq4N;CNpZt>VSJ*j*{QStFzdxPk+*je}XW!VY0cx;@y zDDOS!=kysNt=!9E5Hcl?etFs&trZ4U}%tW}wW8)-8_u%~Y_8I&2?^z}q zd+^49_)HVw7LSdSoAQUVSc`NVZH7UU{ z)1OLa_wvo3ZYSL0u}M;X`-B~H_7++wF(PbQ?;Zh!TRb*SzRJg*tcjeFs?o8k^po+v zL4;d8HcnlYAN}^eiU~u5sCII+`|@OiaEr&r$)xa$eRgZ}(b*aEr&r$?u`R@Y$Wj`2qB2vX+usZ>2)m4?Hxs-IU)mK74BM zdW|Am{`fVihe5c-W8?I+^6L`&AKX~XpTCO>i_V=e2)B4_ocxvd%vkaJjZ%$LUOl`Z zs;@z~#be_XpnSgVa(=>ojY4uOukU=;Al%}yaSBx4eO29%l10H3U9aEl65~m@#be`S zQU3n9rbAQfHEQt;Z!8Ws2)B4_VwE3t^u5U=<7||1^B;3flR>z}W8)O8e81z}zb`+a z(Fz}b?n?pe10u4_oofw^T#b78z)Wq(6Rf^#?@M>PgKIhEk||2Egl;uUHLb^ z?ie$)L#J`I?|UC>wi9mg*yJIV?_0a|e8X5ja(N};o6zuXgj+l|PGQQ&E*n=??$BxF zz3peal-UTkcx;>u<=YQ54axXBkQyV}+FP1E2)B4_ob1Xsm-{Ts&eG}WNvT(x@*IR) zJT^`aVSMJV6p z-Gyzgra;4yYe9>=12m8^* zTa&Ys2O5N1JT^|xD!<7$FVFG1g^YQn>0g}U{~uwC$Hpm2`9CIu_I@cb~sEgl=Ep32{u?m5TL%Sw$e#jUp7GzhnNY@D7`zR+a8>e2%Tk6URpKLJGPd@u+9gg)Q+~ToudS3bFw1)I|=9(W~3*i=z zjZ=*BD=c;Ca}I{k;Ix@XB0kXxw|H!vUQqsxv>Dn({@!ly>2!X!w?VkYW8)O7{9OC0 z+i~kOGQX8xp3>VO+~Tou>aG0sH@|Ciato#0l7Xu?3^53|cx;^Fl)vQH(pvjVAYEH~ zCA*+HlyHm3#;K3;k&Rncn47IsG|qX^#w9x87LSe7i^_j|bU->@#x08OYDSO zJT^{!m5(|d+V+0$09sr#IdRIJ5W+1U8>fEC@0z|gx!Tak)BI6I(jhD17LScnf8`@u zU1q!1XtaJ#$Eg$14#F)S8>a!vSGvVlrBw#dd+UeK+;%dYuRk8$;<0gxSH9@9_nEBQ zI*re}Rov=j5N`3Y*q4rLjooS^( IxW!}p4-ScbBLDyZ literal 0 HcmV?d00001 diff --git a/regress/loader/ReprojectPts.shx b/regress/loader/ReprojectPts.shx new file mode 100644 index 0000000000000000000000000000000000000000..59f0cb91370a41d607691be2b879bfacf098c5cc GIT binary patch literal 628 zcmZw8F=|3V5XSNKy=Wd!EF7>)7ecU|(n5H(-H3?S*eeJgU@sBGDtmym7U}jB7O~kA zYzCF4lsIh8_b(Oqh!=f{KP714c}k oi(^4WLyrL?Cd|c&prWD2fDses;;W#dp~rv`6Xs$gsAv!W0lDZm3;+NC literal 0 HcmV?d00001 diff --git a/regress/loader/ReprojectPtsGeog-pre.sql b/regress/loader/ReprojectPtsGeog-pre.sql new file mode 100644 index 000000000..fe7040603 --- /dev/null +++ b/regress/loader/ReprojectPtsGeog-pre.sql @@ -0,0 +1,12 @@ +-- setup the spatial_ref_sys table with the two projections +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 '); + + diff --git a/regress/loader/ReprojectPtsGeog-w.select.expected b/regress/loader/ReprojectPtsGeog-w.select.expected new file mode 100644 index 000000000..23abda98a --- /dev/null +++ b/regress/loader/ReprojectPtsGeog-w.select.expected @@ -0,0 +1,66 @@ +SRID=4326;POINT(-74.1778249234186 41.0826336069621) +SRID=4326;POINT(-74.4488128587284 40.5013374405831) +SRID=4326;POINT(-74.0037635784151 40.2814968841599) +SRID=4326;POINT(-75.1286374176544 39.779738904917) +SRID=4326;POINT(-74.5762901403342 40.8559759516941) +SRID=4326;POINT(-74.4716040112965 40.5236906585587) +SRID=4326;POINT(-75.4689168308202 39.6968833405426) +SRID=4326;POINT(-75.1145861845468 39.7073923052707) +SRID=4326;POINT(-74.2264370070618 40.097265631898) +SRID=4326;POINT(-74.267669256308 40.835226153518) +SRID=4326;POINT(-74.4215203668629 40.7623218114584) +SRID=4326;POINT(-74.1866659762657 40.8998034100653) +SRID=4326;POINT(-74.2020187391779 40.9444882709976) +SRID=4326;POINT(-74.318666634379 40.668046504386) +SRID=4326;POINT(-74.8320596317968 40.8491289846163) +SRID=4326;POINT(-74.6440210088998 39.9663370779506) +SRID=4326;POINT(-74.2219402834666 40.0955914789689) +SRID=4326;POINT(-74.6037525547762 40.7550420759644) +SRID=4326;POINT(-74.0937601839482 40.8656933573937) +SRID=4326;POINT(-74.4430374038438 40.7779796708969) +SRID=4326;POINT(-74.7684170268845 40.2203845505147) +SRID=4326;POINT(-74.1907818170678 40.739145735004) +SRID=4326;POINT(-74.1962844392102 40.7959141570767) +SRID=4326;POINT(-74.1913030602141 40.7433025340713) +SRID=4326;POINT(-74.1763630799163 40.737831233597) +SRID=4326;POINT(-74.5314873084103 39.4902945583041) +SRID=4326;POINT(-74.1661805363706 40.7363486398654) +SRID=4326;POINT(-74.3573260684924 40.8007679302865) +SRID=4326;POINT(-74.1757381076133 40.7390141841291) +SRID=4326;POINT(-74.6649158055449 40.3457273489041) +SRID=4326;POINT(-74.3662532330192 40.5106137365586) +SRID=4326;POINT(-74.1763187562297 40.7432915904029) +SRID=4326;POINT(-74.4544664009791 40.5242723881508) +SRID=4326;POINT(-74.0283665597175 40.8975658415575) +SRID=4326;POINT(-75.0083397511198 39.8289502587993) +SRID=4326;POINT(-74.1313222061323 40.3316152829947) +SRID=4326;POINT(-74.6799952206859 39.4620385866365) +SRID=4326;POINT(-74.0890480643623 40.9515804026446) +SRID=4326;POINT(-75.1209106831221 39.9482691733624) +SRID=4326;POINT(-74.0862802471739 40.7092900894149) +SRID=4326;POINT(-74.7327024195045 40.2782515920205) +SRID=4326;POINT(-74.1662530255196 40.01000430686) +SRID=4326;POINT(-75.0183798167935 40.7447239779165) +SRID=4326;POINT(-74.6592065330533 40.3495109704879) +SRID=4326;POINT(-74.2475114317579 40.744341221767) +SRID=4326;POINT(-74.6512248373302 40.2515163382362) +SRID=4326;POINT(-74.4388020498744 40.4659008042768) +SRID=4326;POINT(-74.2355416979199 40.6823146575314) +SRID=4326;POINT(-74.4989293530256 40.8076383297076) +SRID=4326;POINT(-74.0625761975523 40.7308606221026) +SRID=4326;POINT(-75.0360016411834 39.7865925067772) +SRID=4326;POINT(-75.0559164322449 39.4408494224665) +SRID=4326;POINT(-74.3980433283985 40.5008690729179) +SRID=4326;POINT(-74.0713156694968 40.7272019085637) +SRID=4326;POINT(-74.1911791861301 40.7419629255487) +SRID=4326;POINT(-74.0249426200973 40.7467647928245) +SRID=4326;POINT(-74.688946675902 40.6094748964846) +SRID=4326;POINT(-74.4460022558058 40.49825883848) +SRID=4326;POINT(-74.198989906698 40.8577957099556) +SRID=4326;POINT(-74.7828046028596 40.2709499874624) +SRID=4326;POINT(-74.2501753633512 40.2174320022045) +SRID=4326;POINT(-74.169605505782 40.9184432569356) +SRID=4326;POINT(-74.7578885232984 41.0675476294558) +SRID=4326;POINT(-74.0336372902943 40.7268907140294) +SRID=4326;POINT(-74.5760699023108 40.537431636642) +SRID=4326;POINT(-74.4392566663626 40.7735918687511) diff --git a/regress/loader/ReprojectPtsGeog.dbf b/regress/loader/ReprojectPtsGeog.dbf new file mode 100644 index 0000000000000000000000000000000000000000..cfaee4bf1f5d8bff0e1f627fc791a19b59289c47 GIT binary patch literal 100 acmZS1XBKo~U|>*WU<8twfLDQHAO!$+fnG9{pfmZs)Wsh}YueZMw8XZ(!(_j&KW_L$$!E{~Iw!`Oq`L=JX%MQPB)SVKp8CzfT^`K3cldg~GA4(tkdFFKO96^uekH$_sgXFP> z`P+sS?9v`u+;T^3oH{FiE%@c4)0eEY`_S$Wr!Lb8w|H!v_?`U!{OYw2zxMByeHPop z_oB9Vybq@*lwaQF@^2?H(bcq4N;CNpZt>VSJ*j*{QStFzdxPk+*je}XW!VY0cx;@y zDDOS!=kysNt=!9E5Hcl?etFs&trZ4U}%tW}wW8)-8_u%~Y_8I&2?^z}q zd+^49_)HVw7LSdSoAQUVSc`NVZH7UU{ z)1OLa_wvo3ZYSL0u}M;X`-B~H_7++wF(PbQ?;Zh!TRb*SzRJg*tcjeFs?o8k^po+v zL4;d8HcnlYAN}^eiU~u5sCII+`|@OiaEr&r$)xa$eRgZ}(b*aEr&r$?u`R@Y$Wj`2qB2vX+usZ>2)m4?Hxs-IU)mK74BM zdW|Am{`fVihe5c-W8?I+^6L`&AKX~XpTCO>i_V=e2)B4_ocxvd%vkaJjZ%$LUOl`Z zs;@z~#be_XpnSgVa(=>ojY4uOukU=;Al%}yaSBx4eO29%l10H3U9aEl65~m@#be`S zQU3n9rbAQfHEQt;Z!8Ws2)B4_VwE3t^u5U=<7||1^B;3flR>z}W8)O8e81z}zb`+a z(Fz}b?n?pe10u4_oofw^T#b78z)Wq(6Rf^#?@M>PgKIhEk||2Egl;uUHLb^ z?ie$)L#J`I?|UC>wi9mg*yJIV?_0a|e8X5ja(N};o6zuXgj+l|PGQQ&E*n=??$BxF zz3peal-UTkcx;>u<=YQ54axXBkQyV}+FP1E2)B4_ob1Xsm-{Ts&eG}WNvT(x@*IR) zJT^`aVSMJV6p z-Gyzgra;4yYe9>=12m8^* zTa&Ys2O5N1JT^|xD!<7$FVFG1g^YQn>0g}U{~uwC$Hpm2`9CIu_I@cb~sEgl=Ep32{u?m5TL%Sw$e#jUp7GzhnNY@D7`zR+a8>e2%Tk6URpKLJGPd@u+9gg)Q+~ToudS3bFw1)I|=9(W~3*i=z zjZ=*BD=c;Ca}I{k;Ix@XB0kXxw|H!vUQqsxv>Dn({@!ly>2!X!w?VkYW8)O7{9OC0 z+i~kOGQX8xp3>VO+~Tou>aG0sH@|Ciato#0l7Xu?3^53|cx;^Fl)vQH(pvjVAYEH~ zCA*+HlyHm3#;K3;k&Rncn47IsG|qX^#w9x87LSe7i^_j|bU->@#x08OYDSO zJT^{!m5(|d+V+0$09sr#IdRIJ5W+1U8>fEC@0z|gx!Tak)BI6I(jhD17LScnf8`@u zU1q!1XtaJ#$Eg$14#F)S8>a!vSGvVlrBw#dd+UeK+;%dYuRk8$;<0gxSH9@9_nEBQ zI*re}Rov=j5N`3Y*q4rLjooS^( IxW!}p4-ScbBLDyZ literal 0 HcmV?d00001 diff --git a/regress/loader/ReprojectPtsGeog.shx b/regress/loader/ReprojectPtsGeog.shx new file mode 100644 index 0000000000000000000000000000000000000000..59f0cb91370a41d607691be2b879bfacf098c5cc GIT binary patch literal 628 zcmZw8F=|3V5XSNKy=Wd!EF7>)7ecU|(n5H(-H3?S*eeJgU@sBGDtmym7U}jB7O~kA zYzCF4lsIh8_b(Oqh!=f{KP714c}k oi(^4WLyrL?Cd|c&prWD2fDses;;W#dp~rv`6Xs$gsAv!W0lDZm3;+NC literal 0 HcmV?d00001 diff --git a/regress/loader/PolygonM-wkt.expected b/regress/loader/TSIPolygon-w.select.expected similarity index 100% rename from regress/loader/PolygonM-wkt.expected rename to regress/loader/TSIPolygon-w.select.expected diff --git a/regress/loader/TSIPolygon-wkb.sql b/regress/loader/TSIPolygon-wkb.sql deleted file mode 100644 index e68081804..000000000 --- a/regress/loader/TSIPolygon-wkb.sql +++ /dev/null @@ -1,2 +0,0 @@ -select ST_Asewkt(the_geom) from loadedshp; - diff --git a/regress/loader/TSIPolygon-wkt.sql b/regress/loader/TSIPolygon-wkt.sql deleted file mode 100644 index e68081804..000000000 --- a/regress/loader/TSIPolygon-wkt.sql +++ /dev/null @@ -1,2 +0,0 @@ -select ST_Asewkt(the_geom) from loadedshp; - diff --git a/regress/loader/TSIPolygon-wkb.expected b/regress/loader/TSIPolygon.select.expected similarity index 100% rename from regress/loader/TSIPolygon-wkb.expected rename to regress/loader/TSIPolygon.select.expected diff --git a/regress/loader/Polygon-wkt.sql b/regress/loader/TSIPolygon.select.sql similarity index 100% rename from regress/loader/Polygon-wkt.sql rename to regress/loader/TSIPolygon.select.sql diff --git a/regress/loader/TSIPolygon.shp.expected b/regress/loader/TSIPolygon.shp.expected new file mode 100644 index 0000000000000000000000000000000000000000..997b43fbeb2263ef74bd704aecc954b149c23f63 GIT binary patch literal 488 zcmZQzQ0HR64!*o#W?*22%c&fIFyXWVlnS25lsCpQ!fP;@q9Hvj? F000LyBU%6e literal 0 HcmV?d00001 diff --git a/regress/loader/TSIPolygon-wkt.expected b/regress/loader/TSTIPolygon-w.select.expected similarity index 100% rename from regress/loader/TSIPolygon-wkt.expected rename to regress/loader/TSTIPolygon-w.select.expected diff --git a/regress/loader/TSTIPolygon-wkb.sql b/regress/loader/TSTIPolygon-wkb.sql deleted file mode 100644 index e68081804..000000000 --- a/regress/loader/TSTIPolygon-wkb.sql +++ /dev/null @@ -1,2 +0,0 @@ -select ST_Asewkt(the_geom) from loadedshp; - diff --git a/regress/loader/TSTIPolygon-wkt.sql b/regress/loader/TSTIPolygon-wkt.sql deleted file mode 100644 index e68081804..000000000 --- a/regress/loader/TSTIPolygon-wkt.sql +++ /dev/null @@ -1,2 +0,0 @@ -select ST_Asewkt(the_geom) from loadedshp; - diff --git a/regress/loader/TSTIPolygon-wkb.expected b/regress/loader/TSTIPolygon.select.expected similarity index 100% rename from regress/loader/TSTIPolygon-wkb.expected rename to regress/loader/TSTIPolygon.select.expected diff --git a/regress/loader/PolygonM-wkb.sql b/regress/loader/TSTIPolygon.select.sql similarity index 100% rename from regress/loader/PolygonM-wkb.sql rename to regress/loader/TSTIPolygon.select.sql diff --git a/regress/loader/TSTIPolygon.shp.expected b/regress/loader/TSTIPolygon.shp.expected new file mode 100644 index 0000000000000000000000000000000000000000..997b43fbeb2263ef74bd704aecc954b149c23f63 GIT binary patch literal 488 zcmZQzQ0HR64!*o#W?*22%c&fIFyXWVlnS25lsCpQ!fP;@q9Hvj? F000LyBU%6e literal 0 HcmV?d00001 diff --git a/regress/loader/TSTIPolygon-wkt.expected b/regress/loader/TSTPolygon-w.select.expected similarity index 100% rename from regress/loader/TSTIPolygon-wkt.expected rename to regress/loader/TSTPolygon-w.select.expected diff --git a/regress/loader/TSTPolygon-wkb.sql b/regress/loader/TSTPolygon-wkb.sql deleted file mode 100644 index e68081804..000000000 --- a/regress/loader/TSTPolygon-wkb.sql +++ /dev/null @@ -1,2 +0,0 @@ -select ST_Asewkt(the_geom) from loadedshp; - diff --git a/regress/loader/TSTPolygon-wkt.expected b/regress/loader/TSTPolygon-wkt.expected deleted file mode 100644 index 1f4a60b57..000000000 --- a/regress/loader/TSTPolygon-wkt.expected +++ /dev/null @@ -1 +0,0 @@ -MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0),(5 5,8 5,8 8,5 8,5 5)),((-1 -1,-1 -10,-10 -10,-10 -1,-1 -1),(-5 -5,-8 -5,-8 -8,-5 -8,-5 -5))) diff --git a/regress/loader/TSTPolygon-wkt.sql b/regress/loader/TSTPolygon-wkt.sql deleted file mode 100644 index e68081804..000000000 --- a/regress/loader/TSTPolygon-wkt.sql +++ /dev/null @@ -1,2 +0,0 @@ -select ST_Asewkt(the_geom) from loadedshp; - diff --git a/regress/loader/TSTPolygon-wkb.expected b/regress/loader/TSTPolygon.select.expected similarity index 100% rename from regress/loader/TSTPolygon-wkb.expected rename to regress/loader/TSTPolygon.select.expected diff --git a/regress/loader/PolygonM-wkt.sql b/regress/loader/TSTPolygon.select.sql similarity index 100% rename from regress/loader/PolygonM-wkt.sql rename to regress/loader/TSTPolygon.select.sql diff --git a/regress/loader/TSTPolygon.shp.expected b/regress/loader/TSTPolygon.shp.expected new file mode 100644 index 0000000000000000000000000000000000000000..997b43fbeb2263ef74bd704aecc954b149c23f63 GIT binary patch literal 488 zcmZQzQ0HR64!*o#W?*22%c&fIFyXWVlnS25lsCpQ!fP;@q9Hvj? F000LyBU%6e literal 0 HcmV?d00001 diff --git a/regress/out_geometry.sql b/regress/out_geometry.sql index 059c7e173..ffca0f986 100644 --- a/regress/out_geometry.sql +++ b/regress/out_geometry.sql @@ -1,6 +1,7 @@ -- -- 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) diff --git a/regress/run_test b/regress/run_test index 3efe5d3ef..839979447 100755 --- a/regress/run_test +++ b/regress/run_test @@ -194,217 +194,181 @@ run_simple_test () } # -# run_loader_test +# This runs the loader once and checks the output of it. +# It will NOT run if neither the expected SQL nor the expected +# select results file exists, unless you pass true for the final +# parameter. # -# Load a shapefile with different methods, create a 'select *' SQL -# test and run simple test with provided expected output. -# -# SHP input is ${TEST}.shp, expected output is {$TEST}.expected +# $1 - Description of this run of the loader, used for error messages. +# $2 - Table name to load into. +# $3 - The name of the file containing what the +# SQL generated by shp2pgsql should look like. +# $4 - The name of the file containing the expected results of +# SELECT geom FROM _tblname should look like. +# $5 - Command line options for shp2pgsql. +# $6 - If you pass true, this will run the loader even if neither +# of the expected results files exists (though of course +# the results won't be compared with anything). # -run_loader_test () +run_loader_and_check_output() { - _tblname=loadedshp - + _description=$1 + _tblname=$2 + _expected_sql_file=$3 + _expected_select_results_file=$4 + _loader_options=$5 + _run_always=$6 # ON_ERROR_STOP is used by psql to return non-0 on an error _psql_opts="--no-psqlrc --variable ON_ERROR_STOP=true" - #echo "SELECT * from ${_tblname}" > ${TEST}.sql - - # See if there is a custom command-line options file - if [ -r ${TEST}.opts ]; then - _custom_opts=`grep -v -m1 ^\s*# ${TEST}.opts` - fi - - - # - # Run in HEXWKB insert mode - # - - show_progress - - ${SHP2PGSQL} $_custom_opts -g the_geom ${TEST}.shp $_tblname \ - > ${TMPDIR}/loader \ - 2> ${TMPDIR}/loader.err - - if [ $? -gt 0 ]; then - fail "running shp2pgsql" "${TMPDIR}/loader.err" - return 1 - - fi - - show_progress - - # MingW hack: use tr to strip off any trailing CR/LFs introduce by MingW which confuse expr - if [ `${PSQL} -t -A -c "SELECT count(*) FROM pg_tables WHERE tablename = '${_tblname}'" "${DB}" | tr -d '\r\n'` -gt 0 ]; then - ${PSQL} -c "DROP TABLE ${_tblname}" "${DB}" >> ${TMPDIR}/regress_log 2>&1 - fi - - ${PSQL} ${_psql_opts} -f ${TMPDIR}/loader "${DB}" > ${TMPDIR}/loader.err 2>&1 - if [ $? -gt 0 ]; then - fail "sourcing shp2pgsql output" "${TMPDIR}/loader.err" - return 1 - fi - - if [ -f "${TEST}-wkb.sql" ]; then - if run_simple_test ${TEST}-wkb.sql ${TEST}-wkb.expected "wkb insert"; then - : - else - return 1 - fi - fi - - - # - # Test in HEXWKB dump mode for all "normal" (no custom parameters) test cases. - # Some custom parameters can be incompatible with -D. - # - if [ -z "$_custom_opts" ]; then + if [ -n "$_run_always" -o -r "$_expected_sql_file" -o -r "$_expected_select_results_file" ]; then show_progress - - ${SHP2PGSQL} -g the_geom -D ${TEST}.shp $_tblname \ + # Produce the output SQL file. + ${SHP2PGSQL} $_loader_options -g the_geom ${TEST}.shp $_tblname \ > ${TMPDIR}/loader \ 2> ${TMPDIR}/loader.err if [ $? -gt 0 ]; then - fail "running shp2pgsql -D" "${TMPDIR}/loader.err" + fail " $_description: running shp2pgsql" "${TMPDIR}/loader.err" return 1 + fi + # Compare the output SQL file with the expected if there is one. + if [ -r $_expected_sql_file ]; then + show_progress + if diff "${TMPDIR}/loader" "$_expected_sql_file" > /dev/null; then + : + else + fail " $_description: actual SQL does not match expected.", \ + "${TMPDIR}/loader" + fi fi - show_progress + # Blow away the test table if it already exists. + # MingW hack: use tr to strip off any trailing CR/LFs introduce by MingW which confuse expr + if [ `${PSQL} -t -A -c "SELECT count(*) FROM pg_tables WHERE tablename = '${_tblname}'" "${DB}" \ + | tr -d '\r\n'` -gt 0 ]; then + show_progress + ${PSQL} -c "DROP TABLE ${_tblname}" "${DB}" >> ${TMPDIR}/regress_log 2>&1 + fi - ${PSQL} -c "DROP table ${_tblname}" "${DB}" >> ${TMPDIR}/regress_log 2>&1 + # Run the loader SQL script. + show_progress ${PSQL} ${_psql_opts} -f ${TMPDIR}/loader "${DB}" > ${TMPDIR}/loader.err 2>&1 if [ $? -gt 0 ]; then - fail "sourcing shp2pgsql -D output" "${TMPDIR}/loader.err" + fail " $_description: running shp2pgsql output" "${TMPDIR}/loader.err" return 1 fi - if [ -f "${TEST}-wkb.sql" ]; then - if run_simple_test ${TEST}-wkb.sql ${TEST}-wkb.expected "wkb dump"; then + # Run the select script (if there is one) + if [ -r "${TEST}.select.sql" ]; then + if run_simple_test "${TEST}.select.sql" "$_expected_select_results_file" "$_description"; then : else + # That will have already called fail, so just return an error. return 1 fi fi fi + return 0 +} - ########################################################### - # - # Dump and compare. - # Do this using WKB mode, as WKT is unable to reproduce - # M values - # +# +# This runs the dumper once and checks the output of it. +# It will NOT run if the expected shp file does not exist, unless +# you pass true for the final parameter. +# +# $1 - Description of this run of the dumper, used for error messages. +# $2 - Table name to dump from. +# $3 - If you pass true, this will run the loader even if neither +# of the expected results files exists (though of course +# the results won't be compared with anything). +# +run_dumper_and_check_output() +{ + _description=$1 + _tblname=$2 + _run_always=$3 + _expected_shp_file="${TEST}.shp.expected" - show_progress + if [ -n "$_run_always" -o -r "$_expected_shp_file" ]; then + show_progress + ${PGSQL2SHP} -f ${TMPDIR}/dumper ${DB} "${_tblname}" > "${TMPDIR}/dumper.err" 2>&1 + if [ $? -gt 0 ]; then + fail "$_description: dumping loaded table" "${TMPDIR}/dumper.err" + return 1 + fi - ${PGSQL2SHP} -f ${TMPDIR}/dumper ${DB} "${_tblname}" > "${TMPDIR}/dumper.err" 2>&1 - if [ $? -gt 0 ]; then - fail "dumping loaded table" "${TMPDIR}/dumper.err" - return 1 + # Compare with expected output if there is any. + if [ -r $_expected_shp_file ]; then + show_progress + if diff "${TMPDIR}"/dumper.shp "$_expected_shp_file" > /dev/null; then + : + else + ls -lL "${TMPDIR}"/dumper.shp "$_expected_shp_file" > "${TMPDIR}"/dumper.diff + fail "$_description: dumping loaded table" "${TMPDIR}/dumper.diff" + return 1 + fi + fi fi + return 0 +} - show_progress +# +# run_loader_test +# +# Load a shapefile with different methods, create a 'select *' SQL +# test and run simple test with provided expected output. +# +# SHP input is ${TEST}.shp, expected output is {$TEST}.expected +# +run_loader_test () +{ + # See if there is a custom command-line options file + _custom_opts="" + if [ -r ${TEST}.opts ]; then + _custom_opts=`grep -v -m1 ^\s*# ${TEST}.opts` + fi - if diff "${TMPDIR}"/dumper.shp "${TEST}".shp > /dev/null; then + # If we have some expected files to compare with, run in wkt mode. + if run_loader_and_check_output "wkt test" "loadedshp" "${TEST}-w.sql.expected" "${TEST}-w.select.expected" \ + "-w $_custom_opts"; then : else - ls -lL "${TMPDIR}"/dumper.shp "${TEST}".shp > "${TMPDIR}"/dumper.diff - fail "dumping loaded table" "${TMPDIR}/dumper.diff" return 1 fi - -# I'm not sure it's safe to compare indexes -# if diff "${TMPDIR}"/dumper.shx "${TEST}".shx; then -# : -# else -# ls -lL "${TMPDIR}"/dumper.shx "${TEST}".shx > "${TMPDIR}"/dumper.diff -# fail "dumping loaded table" "${TMPDIR}/dumper.diff" -# return 1 -# fi - -# Change in attribute sizes would make this fail -# if diff "${TMPDIR}"/dumper.dbf "${TEST}".dbf; then -# : -# else -# ls -lL "${TMPDIR}"/dumper.dbf "${TEST}".dbf > "${TMPDIR}"/dumper.diff -# fail "dumping loaded table" "${TMPDIR}/dumper.diff" -# return 1 -# fi - - - # - # End of dump and compare. - # - ################################################ - - show_progress - - ${SHP2PGSQL} $_custom_opts -g the_geom -w ${TEST}.shp $_tblname \ - > ${TMPDIR}/loader \ - 2> ${TMPDIR}/loader.err - - if [ $? -gt 0 ]; then - fail "running shp2pgsql -w" "${TMPDIR}/loader.err" - return 1 - fi - - show_progress - - ${PSQL} -c "DROP table ${_tblname}" "${DB}" >> ${TMPDIR}/regress_log 2>&1 - ${PSQL} ${_psql_opts} -f ${TMPDIR}/loader "${DB}" > ${TMPDIR}/loader.err 2>&1 - if [ $? -gt 0 ]; then - fail "sourcing shp2pgsql -w output" "${TMPDIR}/loader.err" + # Always run in wkb ("normal") mode, even if there are no expected files to compare with. + if run_loader_and_check_output "wkb test" "loadedshp" "${TEST}.sql.expected" "${TEST}.select.expected" \ + "$_custom_opts" "true"; then + : + else return 1 fi - - if [ -f "${TEST}-wkt.sql" ]; then - if run_simple_test ${TEST}-wkt.sql ${TEST}-wkt.expected "wkt insert"; then - : - else - return 1 - fi - fi - - # - # Test in WKT dump mode for all "normal" (no custom parameters) test cases. # Some custom parameters can be incompatible with -D. - # if [ -z "$_custom_opts" ]; then - - show_progress - - ${SHP2PGSQL} -g the_geom -D -w ${TEST}.shp $_tblname \ - > ${TMPDIR}/loader \ - 2> ${TMPDIR}/loader.err - - if [ $? -gt 0 ]; then - fail "running shp2pgsql -D -w" "${TMPDIR}/loader.err" + # If we have some expected files to compare with, run in wkt dump mode. + if run_loader_and_check_output "wkt dump test" "loadedshp" "${TEST}-wD.sql.expected" \ + "${TEST}-w.select.expected" "-w -D"; then + : + else return 1 - fi - - show_progress - - ${PSQL} -c "DROP table ${_tblname}" "${DB}" >> ${TMPDIR}/regress_log 2>&1 - ${PSQL} ${_psql_opts} -f ${TMPDIR}/loader "${DB}" > ${TMPDIR}/loader.err 2>&1 - if [ $? -gt 0 ]; then - fail "sourcing shp2pgsql -D -w output" "${TMPDIR}/loader.err" + # If we have some expected files to compare with, run in wkb dump mode. + if run_loader_and_check_output "wkb dump test" "loadedshp" "${TEST}-D.sql.expected" \ + "${TEST}.select.expected" "-D"; then + : + else return 1 fi - - if [ -f "${TEST}-wkt.sql" ]; then - if run_simple_test ${TEST}-wkt.sql ${TEST}-wkt.expected "wkt dump"; then - : - else - return 1 - fi - fi + fi + # If we have some expected files to compare with, run the dumper and compare shape files. + if run_dumper_and_check_output "dumper test" "loadedshp"; then + : + else + return 1 fi - #rm ${TEST}.sql - - return 0; + return 0 } ################################################### @@ -582,7 +546,7 @@ while [ -n "$1" ]; do fi fi - # Check .shp *before* .sql as loader test would + # Check .shp *before* .sql as loader test could # create the .sql if [ -r "${TEST}.shp" ]; then if run_loader_test; then -- 2.50.1