diff --git a/doc/man/shp2pgsql.1 b/doc/man/shp2pgsql.1 index ca293f5ddfb..12dee56bcb3 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 63b44d3b9b2..12ce0093c60 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 e98deada0bf..64db3ffa4eb 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 0d627d09126..9f016dfd4fc 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 060a1d9ef45..d44325d75d6 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 67e2f59445f..ef41cf88c40 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 a11e2249b21..7762955cd4e 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 00000000000..db615cf1d7c Binary files /dev/null and b/regress/loader/Arc.shp.expected differ 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 b894f93a98e..00000000000 --- 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 4ac611ce538..00000000000 --- 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 00000000000..284c668008a --- /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 a7700903de6..c11025de205 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 00000000000..673dc421b36 Binary files /dev/null and b/regress/loader/ArcM.shp.expected differ diff --git a/regress/loader/ArcZ-w.select.expected b/regress/loader/ArcZ-w.select.expected new file mode 100644 index 00000000000..0f5dde7b8c7 --- /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 e4381fc7306..00000000000 --- 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 22619e3b3c2..00000000000 --- 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 00000000000..0f5dde7b8c7 --- /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 a7700903de6..c11025de205 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 00000000000..ed061a29afa Binary files /dev/null and b/regress/loader/ArcZ.shp.expected differ diff --git a/regress/loader/MultiPoint-wkb.expected b/regress/loader/MultiPoint-w.select.expected similarity index 100% rename from regress/loader/MultiPoint-wkb.expected rename to regress/loader/MultiPoint-w.select.expected diff --git a/regress/loader/MultiPoint-wkt.expected b/regress/loader/MultiPoint.select.expected similarity index 100% rename from regress/loader/MultiPoint-wkt.expected rename to regress/loader/MultiPoint.select.expected diff --git a/regress/loader/MultiPoint-wkb.sql b/regress/loader/MultiPoint.select.sql similarity index 100% rename from regress/loader/MultiPoint-wkb.sql rename to regress/loader/MultiPoint.select.sql diff --git a/regress/loader/MultiPoint.shp.expected b/regress/loader/MultiPoint.shp.expected new file mode 100644 index 00000000000..b8b586771d9 Binary files /dev/null and b/regress/loader/MultiPoint.shp.expected differ 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 791f6f1ed29..00000000000 --- 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 00000000000..f0a0a857d11 --- /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 00000000000..4d7d5e3ec13 Binary files /dev/null and b/regress/loader/MultiPointM.shp.expected differ diff --git a/regress/loader/MultiPointZ-wkb.expected b/regress/loader/MultiPointZ-w.select.expected similarity index 100% rename from regress/loader/MultiPointZ-wkb.expected rename to regress/loader/MultiPointZ-w.select.expected diff --git a/regress/loader/MultiPointZ-wkt.expected b/regress/loader/MultiPointZ-wkt.expected deleted file mode 100644 index 596ad575dbb..00000000000 --- a/regress/loader/MultiPointZ-wkt.expected +++ /dev/null @@ -1 +0,0 @@ -MULTIPOINT(0 1 2,9 -1 -2,9 -1 -20) diff --git a/regress/loader/MultiPointZ.select.expected b/regress/loader/MultiPointZ.select.expected new file mode 100644 index 00000000000..cd255cf2b1b --- /dev/null +++ b/regress/loader/MultiPointZ.select.expected @@ -0,0 +1 @@ +MULTIPOINT(0 1 2 3,9 -1 -2 -3,9 -1 -20 -123) diff --git a/regress/loader/MultiPointM-wkb.sql b/regress/loader/MultiPointZ.select.sql similarity index 100% rename from regress/loader/MultiPointM-wkb.sql rename to regress/loader/MultiPointZ.select.sql diff --git a/regress/loader/MultiPointZ.shp.expected b/regress/loader/MultiPointZ.shp.expected new file mode 100644 index 00000000000..6ba2d7fdbf5 Binary files /dev/null and b/regress/loader/MultiPointZ.shp.expected differ diff --git a/regress/loader/MultiToSinglePoint-w.select.expected b/regress/loader/MultiToSinglePoint-w.select.expected new file mode 100644 index 00000000000..38fcb40352a --- /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 00000000000..cfaee4bf1f5 Binary files /dev/null and b/regress/loader/MultiToSinglePoint.dbf differ diff --git a/regress/loader/MultiToSinglePoint.opts b/regress/loader/MultiToSinglePoint.opts new file mode 100644 index 00000000000..6eec8d41c39 --- /dev/null +++ b/regress/loader/MultiToSinglePoint.opts @@ -0,0 +1,4 @@ +# These points are in a multipoint shapefile even though they're all single points. +# That used to break, so you sould be able to use the -S parameter to force them to +# load into a POINT table rather than a MULTIPOINT. +-S diff --git a/regress/loader/MultiToSinglePoint.select.expected b/regress/loader/MultiToSinglePoint.select.expected new file mode 100644 index 00000000000..b80e20e6964 --- /dev/null +++ b/regress/loader/MultiToSinglePoint.select.expected @@ -0,0 +1,66 @@ +POINT(580936.142822989 819465.261818573) +POINT(506358.893822162 607539.257299624) +POINT(630565.963576575 527840.458930382) +POINT(315456.492217951 345306.814088522) +POINT(471022.700765905 736736.493043649) +POINT(500018.609208153 615679.275075901) +POINT(219498.722491731 315980.375130241) +POINT(319224.669258993 318928.062445705) +POINT(568650.774421983 460462.130343988) +POINT(556409.113539159 729253.30990305) +POINT(513863.467629622 702618.742174883) +POINT(578737.93900689 752848.936014613) +POINT(574438.608452132 769113.196326717) +POINT(542424.351008234 668316.880130952) +POINT(400265.835331173 734407.03359561) +POINT(451759.863004144 412686.100723883) +POINT(569910.583609289 459856.209410486) +POINT(463382.922608931 699974.019885147) +POINT(604477.021809125 740527.999129056) +POINT(507899.651882106 708318.275562585) +POINT(417174.241778919 505305.090947582) +POINT(577806.69952663 694316.933395063) +POINT(576210.383288164 714992.288047029) +POINT(577656.942500652 695830.735895674) +POINT(581803.77911474 693852.464252684) +POINT(483239.070139275 239264.868230516) +POINT(584627.388419181 693322.924133717) +POINT(531622.192358354 716647.04090078) +POINT(581975.365599073 694284.048851616) +POINT(446160.135881017 550892.865025523) +POINT(529311.59036645 610942.506187195) +POINT(581808.72698778 695841.703111349) +POINT(504782.468510898 615893.18621198) +POINT(622500.156247537 752230.030256728) +POINT(349366.222335089 363016.921231509) +POINT(594903.330738372 545923.436927693) +POINT(441308.570185706 229022.749014213) +POINT(605633.269658534 771823.459750208) +POINT(318054.396825439 406677.968765208) +POINT(606814.490943 683559.837390652) +POINT(427202.24558416 526355.921118875) +POINT(585605.654583162 428734.299958661) +POINT(348498.220290712 696622.254661199) +POINT(447753.888233448 552268.218021069) +POINT(562081.950510856 696159.347584696) +POINT(449917.461533751 516567.922516446) +POINT(509151.60703826 594632.163260898) +POINT(565466.43527563 673573.123642044) +POINT(492421.362355858 719117.799265052) +POINT(613346.499961959 691449.747538779) +POINT(341505.39322594 347633.860111487) +POINT(335130.109224021 221738.458568427) +POINT(520476.859199935 607380.893420555) +POINT(610931.065287928 690104.943360865) +POINT(577692.981621935 695342.840693476) +POINT(623744.425211874 697297.79933633) +POINT(439667.99409899 646984.255696235) +POINT(507141.140300172 606418.246119218) +POINT(575383.927230225 737533.321867288) +POINT(413215.495253968 523736.836314417) +POINT(561887.180888466 504214.422382654) +POINT(583428.220763956 759656.927730192) +POINT(421018.925048973 813910.215413168) +POINT(621373.929808485 690044.79287378) +POINT(470983.159331542 620692.733330001) +POINT(508947.758356538 706720.507141173) diff --git a/regress/loader/MultiPointM-wkt.sql b/regress/loader/MultiToSinglePoint.select.sql similarity index 100% rename from regress/loader/MultiPointM-wkt.sql rename to regress/loader/MultiToSinglePoint.select.sql diff --git a/regress/loader/MultiToSinglePoint.shp b/regress/loader/MultiToSinglePoint.shp new file mode 100644 index 00000000000..805fbb0b886 Binary files /dev/null and b/regress/loader/MultiToSinglePoint.shp differ diff --git a/regress/loader/MultiToSinglePoint.shp.expected b/regress/loader/MultiToSinglePoint.shp.expected new file mode 100644 index 00000000000..6c33d96caa3 Binary files /dev/null and b/regress/loader/MultiToSinglePoint.shp.expected differ diff --git a/regress/loader/MultiToSinglePoint.shx b/regress/loader/MultiToSinglePoint.shx new file mode 100644 index 00000000000..59f0cb91370 Binary files /dev/null and b/regress/loader/MultiToSinglePoint.shx differ 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 00000000000..51d38e75d0d Binary files /dev/null and b/regress/loader/NoTransPoint.shp.expected differ diff --git a/regress/loader/NotReallyMultiPoint-w.select.expected b/regress/loader/NotReallyMultiPoint-w.select.expected new file mode 100644 index 00000000000..e145e31505f --- /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 00000000000..cfaee4bf1f5 Binary files /dev/null and b/regress/loader/NotReallyMultiPoint.dbf differ diff --git a/regress/loader/NotReallyMultiPoint.select.expected b/regress/loader/NotReallyMultiPoint.select.expected new file mode 100644 index 00000000000..ea55702061c --- /dev/null +++ b/regress/loader/NotReallyMultiPoint.select.expected @@ -0,0 +1,66 @@ +MULTIPOINT(580936.142822989 819465.261818573) +MULTIPOINT(506358.893822162 607539.257299624) +MULTIPOINT(630565.963576575 527840.458930382) +MULTIPOINT(315456.492217951 345306.814088522) +MULTIPOINT(471022.700765905 736736.493043649) +MULTIPOINT(500018.609208153 615679.275075901) +MULTIPOINT(219498.722491731 315980.375130241) +MULTIPOINT(319224.669258993 318928.062445705) +MULTIPOINT(568650.774421983 460462.130343988) +MULTIPOINT(556409.113539159 729253.30990305) +MULTIPOINT(513863.467629622 702618.742174883) +MULTIPOINT(578737.93900689 752848.936014613) +MULTIPOINT(574438.608452132 769113.196326717) +MULTIPOINT(542424.351008234 668316.880130952) +MULTIPOINT(400265.835331173 734407.03359561) +MULTIPOINT(451759.863004144 412686.100723883) +MULTIPOINT(569910.583609289 459856.209410486) +MULTIPOINT(463382.922608931 699974.019885147) +MULTIPOINT(604477.021809125 740527.999129056) +MULTIPOINT(507899.651882106 708318.275562585) +MULTIPOINT(417174.241778919 505305.090947582) +MULTIPOINT(577806.69952663 694316.933395063) +MULTIPOINT(576210.383288164 714992.288047029) +MULTIPOINT(577656.942500652 695830.735895674) +MULTIPOINT(581803.77911474 693852.464252684) +MULTIPOINT(483239.070139275 239264.868230516) +MULTIPOINT(584627.388419181 693322.924133717) +MULTIPOINT(531622.192358354 716647.04090078) +MULTIPOINT(581975.365599073 694284.048851616) +MULTIPOINT(446160.135881017 550892.865025523) +MULTIPOINT(529311.59036645 610942.506187195) +MULTIPOINT(581808.72698778 695841.703111349) +MULTIPOINT(504782.468510898 615893.18621198) +MULTIPOINT(622500.156247537 752230.030256728) +MULTIPOINT(349366.222335089 363016.921231509) +MULTIPOINT(594903.330738372 545923.436927693) +MULTIPOINT(441308.570185706 229022.749014213) +MULTIPOINT(605633.269658534 771823.459750208) +MULTIPOINT(318054.396825439 406677.968765208) +MULTIPOINT(606814.490943 683559.837390652) +MULTIPOINT(427202.24558416 526355.921118875) +MULTIPOINT(585605.654583162 428734.299958661) +MULTIPOINT(348498.220290712 696622.254661199) +MULTIPOINT(447753.888233448 552268.218021069) +MULTIPOINT(562081.950510856 696159.347584696) +MULTIPOINT(449917.461533751 516567.922516446) +MULTIPOINT(509151.60703826 594632.163260898) +MULTIPOINT(565466.43527563 673573.123642044) +MULTIPOINT(492421.362355858 719117.799265052) +MULTIPOINT(613346.499961959 691449.747538779) +MULTIPOINT(341505.39322594 347633.860111487) +MULTIPOINT(335130.109224021 221738.458568427) +MULTIPOINT(520476.859199935 607380.893420555) +MULTIPOINT(610931.065287928 690104.943360865) +MULTIPOINT(577692.981621935 695342.840693476) +MULTIPOINT(623744.425211874 697297.79933633) +MULTIPOINT(439667.99409899 646984.255696235) +MULTIPOINT(507141.140300172 606418.246119218) +MULTIPOINT(575383.927230225 737533.321867288) +MULTIPOINT(413215.495253968 523736.836314417) +MULTIPOINT(561887.180888466 504214.422382654) +MULTIPOINT(583428.220763956 759656.927730192) +MULTIPOINT(421018.925048973 813910.215413168) +MULTIPOINT(621373.929808485 690044.79287378) +MULTIPOINT(470983.159331542 620692.733330001) +MULTIPOINT(508947.758356538 706720.507141173) diff --git a/regress/loader/MultiPointZ-wkt.sql b/regress/loader/NotReallyMultiPoint.select.sql similarity index 100% rename from regress/loader/MultiPointZ-wkt.sql rename to regress/loader/NotReallyMultiPoint.select.sql diff --git a/regress/loader/NotReallyMultiPoint.shp b/regress/loader/NotReallyMultiPoint.shp new file mode 100644 index 00000000000..805fbb0b886 Binary files /dev/null and b/regress/loader/NotReallyMultiPoint.shp differ diff --git a/regress/loader/NotReallyMultiPoint.shp.expected b/regress/loader/NotReallyMultiPoint.shp.expected new file mode 100644 index 00000000000..805fbb0b886 Binary files /dev/null and b/regress/loader/NotReallyMultiPoint.shp.expected differ diff --git a/regress/loader/NotReallyMultiPoint.shx b/regress/loader/NotReallyMultiPoint.shx new file mode 100644 index 00000000000..59f0cb91370 Binary files /dev/null and b/regress/loader/NotReallyMultiPoint.shx differ 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 00000000000..51d38e75d0d Binary files /dev/null and b/regress/loader/Point.shp.expected differ 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 680e99b43d4..00000000000 --- 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 00000000000..4004ce78975 --- /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 00000000000..03da6b4863d Binary files /dev/null and b/regress/loader/PointM.shp.expected differ 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 031c1196e4c..00000000000 --- 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 6cadbea2ca8..00000000000 --- 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 031c1196e4c..00000000000 --- 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 00000000000..ecb35160b91 --- /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 00000000000..9b9ab796b51 Binary files /dev/null and b/regress/loader/PointZ.shp.expected differ 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 00000000000..997b43fbeb2 Binary files /dev/null and b/regress/loader/Polygon.shp.expected differ 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 00000000000..194ac8c19e2 --- /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 00000000000..4513ab79948 Binary files /dev/null and b/regress/loader/PolygonM.shp.expected differ 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 e68081804e1..00000000000 --- 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 40d5bf34579..00000000000 --- 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 e68081804e1..00000000000 --- 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 00000000000..7370e634634 --- /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 00000000000..be7e41faa3d Binary files /dev/null and b/regress/loader/PolygonZ.shp.expected differ diff --git a/regress/loader/README b/regress/loader/README index e9d20604131..4b9ae6de06b 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 00000000000..fe7040603b3 --- /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 00000000000..23abda98ad8 --- /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 00000000000..cfaee4bf1f5 Binary files /dev/null and b/regress/loader/ReprojectPts.dbf differ diff --git a/regress/loader/ReprojectPts.opts b/regress/loader/ReprojectPts.opts new file mode 100644 index 00000000000..e267f8557e2 --- /dev/null +++ b/regress/loader/ReprojectPts.opts @@ -0,0 +1,3 @@ +# This happens to be a multipoint shapefile that has only single points, so use -S. +# It is in NJ State Plane NAD83, so reproject to 4326. +-S -r 2260 -s 4326 diff --git a/regress/loader/ReprojectPts.select.expected b/regress/loader/ReprojectPts.select.expected new file mode 100644 index 00000000000..9b662bccc64 --- /dev/null +++ b/regress/loader/ReprojectPts.select.expected @@ -0,0 +1,66 @@ +SRID=4326;POINT(-74.1778249234186 41.0826336069609) +SRID=4326;POINT(-74.4488128587278 40.5013374405821) +SRID=4326;POINT(-74.0037635784167 40.281496884161) +SRID=4326;POINT(-75.1286374176545 39.7797389049157) +SRID=4326;POINT(-74.5762901403345 40.8559759516931) +SRID=4326;POINT(-74.471604011296 40.5236906585584) +SRID=4326;POINT(-75.4689168308211 39.6968833405432) +SRID=4326;POINT(-75.1145861845469 39.7073923052699) +SRID=4326;POINT(-74.2264370070619 40.097265631898) +SRID=4326;POINT(-74.2676692563074 40.8352261535181) +SRID=4326;POINT(-74.4215203668643 40.7623218114581) +SRID=4326;POINT(-74.1866659762661 40.8998034100642) +SRID=4326;POINT(-74.2020187391775 40.9444882709968) +SRID=4326;POINT(-74.3186666343781 40.6680465043858) +SRID=4326;POINT(-74.8320596317961 40.8491289846152) +SRID=4326;POINT(-74.6440210088993 39.9663370779502) +SRID=4326;POINT(-74.2219402834656 40.0955914789703) +SRID=4326;POINT(-74.6037525547765 40.7550420759648) +SRID=4326;POINT(-74.0937601839477 40.8656933573938) +SRID=4326;POINT(-74.4430374038435 40.7779796708957) +SRID=4326;POINT(-74.7684170268848 40.2203845505135) +SRID=4326;POINT(-74.1907818170692 40.7391457350042) +SRID=4326;POINT(-74.1962844392096 40.7959141570767) +SRID=4326;POINT(-74.1913030602153 40.7433025340704) +SRID=4326;POINT(-74.1763630799173 40.7378312335961) +SRID=4326;POINT(-74.5314873084093 39.4902945583028) +SRID=4326;POINT(-74.1661805363699 40.7363486398646) +SRID=4326;POINT(-74.3573260684911 40.8007679302858) +SRID=4326;POINT(-74.175738107613 40.739014184128) +SRID=4326;POINT(-74.6649158055448 40.3457273489028) +SRID=4326;POINT(-74.3662532330176 40.5106137365591) +SRID=4326;POINT(-74.1763187562305 40.7432915904039) +SRID=4326;POINT(-74.4544664009795 40.5242723881507) +SRID=4326;POINT(-74.0283665597192 40.8975658415568) +SRID=4326;POINT(-75.0083397511195 39.828950258798) +SRID=4326;POINT(-74.131322206131 40.3316152829939) +SRID=4326;POINT(-74.6799952206869 39.4620385866371) +SRID=4326;POINT(-74.089048064364 40.9515804026451) +SRID=4326;POINT(-75.1209106831206 39.948269173363) +SRID=4326;POINT(-74.086280247174 40.7092900894139) +SRID=4326;POINT(-74.7327024195039 40.2782515920201) +SRID=4326;POINT(-74.166253025519 40.0100043068591) +SRID=4326;POINT(-75.0183798167945 40.7447239779171) +SRID=4326;POINT(-74.6592065330517 40.3495109704881) +SRID=4326;POINT(-74.2475114317585 40.7443412217661) +SRID=4326;POINT(-74.6512248373311 40.2515163382374) +SRID=4326;POINT(-74.4388020498734 40.4659008042765) +SRID=4326;POINT(-74.2355416979212 40.6823146575315) +SRID=4326;POINT(-74.4989293530261 40.8076383297078) +SRID=4326;POINT(-74.0625761975525 40.730860622102) +SRID=4326;POINT(-75.0360016411836 39.7865925067785) +SRID=4326;POINT(-75.0559164322449 39.4408494224676) +SRID=4326;POINT(-74.3980433283988 40.5008690729166) +SRID=4326;POINT(-74.0713156694971 40.7272019085633) +SRID=4326;POINT(-74.1911791861303 40.74196292555) +SRID=4326;POINT(-74.0249426200977 40.7467647928254) +SRID=4326;POINT(-74.6889466759021 40.6094748964853) +SRID=4326;POINT(-74.4460022558052 40.4982588384806) +SRID=4326;POINT(-74.1989899066972 40.8577957099564) +SRID=4326;POINT(-74.7828046028598 40.2709499874636) +SRID=4326;POINT(-74.2501753633496 40.2174320022036) +SRID=4326;POINT(-74.1696055057822 40.9184432569361) +SRID=4326;POINT(-74.7578885232985 41.0675476294562) +SRID=4326;POINT(-74.0336372902925 40.7268907140288) +SRID=4326;POINT(-74.5760699023125 40.537431636642) +SRID=4326;POINT(-74.4392566663643 40.7735918687515) diff --git a/regress/loader/Polygon-wkb.sql b/regress/loader/ReprojectPts.select.sql similarity index 100% rename from regress/loader/Polygon-wkb.sql rename to regress/loader/ReprojectPts.select.sql diff --git a/regress/loader/ReprojectPts.shp b/regress/loader/ReprojectPts.shp new file mode 100644 index 00000000000..805fbb0b886 Binary files /dev/null and b/regress/loader/ReprojectPts.shp differ diff --git a/regress/loader/ReprojectPts.shx b/regress/loader/ReprojectPts.shx new file mode 100644 index 00000000000..59f0cb91370 Binary files /dev/null and b/regress/loader/ReprojectPts.shx differ diff --git a/regress/loader/ReprojectPtsGeog-pre.sql b/regress/loader/ReprojectPtsGeog-pre.sql new file mode 100644 index 00000000000..fe7040603b3 --- /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 00000000000..23abda98ad8 --- /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 00000000000..cfaee4bf1f5 Binary files /dev/null and b/regress/loader/ReprojectPtsGeog.dbf differ diff --git a/regress/loader/ReprojectPtsGeog.opts b/regress/loader/ReprojectPtsGeog.opts new file mode 100644 index 00000000000..bfb00d83793 --- /dev/null +++ b/regress/loader/ReprojectPtsGeog.opts @@ -0,0 +1,3 @@ +# This happens to be a multipoint shapefile that has only single points, so use -S. +# It is in NJ State Plane NAD83, using the -G flag will reproject to 4326. +-S -r 2260 -G diff --git a/regress/loader/ReprojectPtsGeog.select.expected b/regress/loader/ReprojectPtsGeog.select.expected new file mode 100644 index 00000000000..9b662bccc64 --- /dev/null +++ b/regress/loader/ReprojectPtsGeog.select.expected @@ -0,0 +1,66 @@ +SRID=4326;POINT(-74.1778249234186 41.0826336069609) +SRID=4326;POINT(-74.4488128587278 40.5013374405821) +SRID=4326;POINT(-74.0037635784167 40.281496884161) +SRID=4326;POINT(-75.1286374176545 39.7797389049157) +SRID=4326;POINT(-74.5762901403345 40.8559759516931) +SRID=4326;POINT(-74.471604011296 40.5236906585584) +SRID=4326;POINT(-75.4689168308211 39.6968833405432) +SRID=4326;POINT(-75.1145861845469 39.7073923052699) +SRID=4326;POINT(-74.2264370070619 40.097265631898) +SRID=4326;POINT(-74.2676692563074 40.8352261535181) +SRID=4326;POINT(-74.4215203668643 40.7623218114581) +SRID=4326;POINT(-74.1866659762661 40.8998034100642) +SRID=4326;POINT(-74.2020187391775 40.9444882709968) +SRID=4326;POINT(-74.3186666343781 40.6680465043858) +SRID=4326;POINT(-74.8320596317961 40.8491289846152) +SRID=4326;POINT(-74.6440210088993 39.9663370779502) +SRID=4326;POINT(-74.2219402834656 40.0955914789703) +SRID=4326;POINT(-74.6037525547765 40.7550420759648) +SRID=4326;POINT(-74.0937601839477 40.8656933573938) +SRID=4326;POINT(-74.4430374038435 40.7779796708957) +SRID=4326;POINT(-74.7684170268848 40.2203845505135) +SRID=4326;POINT(-74.1907818170692 40.7391457350042) +SRID=4326;POINT(-74.1962844392096 40.7959141570767) +SRID=4326;POINT(-74.1913030602153 40.7433025340704) +SRID=4326;POINT(-74.1763630799173 40.7378312335961) +SRID=4326;POINT(-74.5314873084093 39.4902945583028) +SRID=4326;POINT(-74.1661805363699 40.7363486398646) +SRID=4326;POINT(-74.3573260684911 40.8007679302858) +SRID=4326;POINT(-74.175738107613 40.739014184128) +SRID=4326;POINT(-74.6649158055448 40.3457273489028) +SRID=4326;POINT(-74.3662532330176 40.5106137365591) +SRID=4326;POINT(-74.1763187562305 40.7432915904039) +SRID=4326;POINT(-74.4544664009795 40.5242723881507) +SRID=4326;POINT(-74.0283665597192 40.8975658415568) +SRID=4326;POINT(-75.0083397511195 39.828950258798) +SRID=4326;POINT(-74.131322206131 40.3316152829939) +SRID=4326;POINT(-74.6799952206869 39.4620385866371) +SRID=4326;POINT(-74.089048064364 40.9515804026451) +SRID=4326;POINT(-75.1209106831206 39.948269173363) +SRID=4326;POINT(-74.086280247174 40.7092900894139) +SRID=4326;POINT(-74.7327024195039 40.2782515920201) +SRID=4326;POINT(-74.166253025519 40.0100043068591) +SRID=4326;POINT(-75.0183798167945 40.7447239779171) +SRID=4326;POINT(-74.6592065330517 40.3495109704881) +SRID=4326;POINT(-74.2475114317585 40.7443412217661) +SRID=4326;POINT(-74.6512248373311 40.2515163382374) +SRID=4326;POINT(-74.4388020498734 40.4659008042765) +SRID=4326;POINT(-74.2355416979212 40.6823146575315) +SRID=4326;POINT(-74.4989293530261 40.8076383297078) +SRID=4326;POINT(-74.0625761975525 40.730860622102) +SRID=4326;POINT(-75.0360016411836 39.7865925067785) +SRID=4326;POINT(-75.0559164322449 39.4408494224676) +SRID=4326;POINT(-74.3980433283988 40.5008690729166) +SRID=4326;POINT(-74.0713156694971 40.7272019085633) +SRID=4326;POINT(-74.1911791861303 40.74196292555) +SRID=4326;POINT(-74.0249426200977 40.7467647928254) +SRID=4326;POINT(-74.6889466759021 40.6094748964853) +SRID=4326;POINT(-74.4460022558052 40.4982588384806) +SRID=4326;POINT(-74.1989899066972 40.8577957099564) +SRID=4326;POINT(-74.7828046028598 40.2709499874636) +SRID=4326;POINT(-74.2501753633496 40.2174320022036) +SRID=4326;POINT(-74.1696055057822 40.9184432569361) +SRID=4326;POINT(-74.7578885232985 41.0675476294562) +SRID=4326;POINT(-74.0336372902925 40.7268907140288) +SRID=4326;POINT(-74.5760699023125 40.537431636642) +SRID=4326;POINT(-74.4392566663643 40.7735918687515) diff --git a/regress/loader/ReprojectPtsGeog.select.sql b/regress/loader/ReprojectPtsGeog.select.sql new file mode 100644 index 00000000000..06ce9606f27 --- /dev/null +++ b/regress/loader/ReprojectPtsGeog.select.sql @@ -0,0 +1,2 @@ +select ST_Asewkt(the_geom::geometry) from loadedshp; + diff --git a/regress/loader/ReprojectPtsGeog.shp b/regress/loader/ReprojectPtsGeog.shp new file mode 100644 index 00000000000..805fbb0b886 Binary files /dev/null and b/regress/loader/ReprojectPtsGeog.shp differ diff --git a/regress/loader/ReprojectPtsGeog.shx b/regress/loader/ReprojectPtsGeog.shx new file mode 100644 index 00000000000..59f0cb91370 Binary files /dev/null and b/regress/loader/ReprojectPtsGeog.shx differ 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 e68081804e1..00000000000 --- 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 e68081804e1..00000000000 --- 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 00000000000..997b43fbeb2 Binary files /dev/null and b/regress/loader/TSIPolygon.shp.expected differ 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 e68081804e1..00000000000 --- 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 e68081804e1..00000000000 --- 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 00000000000..997b43fbeb2 Binary files /dev/null and b/regress/loader/TSTIPolygon.shp.expected differ 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 e68081804e1..00000000000 --- 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 1f4a60b5730..00000000000 --- 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 e68081804e1..00000000000 --- 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 00000000000..997b43fbeb2 Binary files /dev/null and b/regress/loader/TSTPolygon.shp.expected differ diff --git a/regress/out_geometry.sql b/regress/out_geometry.sql index 059c7e1736c..ffca0f9869d 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 3efe5d3ef8e..8399794470d 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