22 #include "../postgis_config.h"
35 #include <sys/param.h>
38 #include "../liblwgeom/liblwgeom.h"
39 #include "../liblwgeom/lwgeom_log.h"
42 #define MAX_DBF_FIELD_SIZE 254
46 static int reverse_points(
int num_points,
double *
x,
double *
y,
double *z,
double *m);
47 static int is_clockwise(
int num_points,
double *
x,
double *
y,
double *z);
73 const uint8_t ndr_nan[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x7f};
76 memcpy(&double_nan, ndr_nan, 8);
87 double *xpts, *ypts, *zpts, *mpts;
90 xpts =
malloc(
sizeof(
double));
91 ypts =
malloc(
sizeof(
double));
92 zpts =
malloc(
sizeof(
double));
93 mpts =
malloc(
sizeof(
double));
104 LWDEBUGF(4,
"Point: %g %g %g %g", xpts[0], ypts[0], zpts[0], mpts[0]);
123 double *xpts, *ypts, *zpts, *mpts;
133 for (i = 0; i < lwmultipoint->
ngeoms; i++)
142 LWDEBUGF(4,
"MultiPoint %d - Point: %g %g %g %g", i, xpts[i], ypts[i], zpts[i], mpts[i]);
162 double *xpts, *ypts, *zpts, *mpts;
164 int *shpparts, shppointtotal = 0, shppoint = 0;
170 for (i = 0; i < lwpolygon->
nrings; i++)
174 xpts =
malloc(
sizeof(
double) * shppointtotal);
175 ypts =
malloc(
sizeof(
double) * shppointtotal);
176 zpts =
malloc(
sizeof(
double) * shppointtotal);
177 mpts =
malloc(
sizeof(
double) * shppointtotal);
179 LWDEBUGF(4,
"Total number of points: %d", shppointtotal);
182 for (i = 0; i < lwpolygon->
nrings; i++)
185 shpparts[i] = shppoint;
191 xpts[shppoint] = p4d.
x;
192 ypts[shppoint] = p4d.
y;
193 zpts[shppoint] = p4d.
z;
194 mpts[shppoint] = p4d.
m;
196 LWDEBUGF(4,
"Polygon Ring %d - Point: %g %g %g %g", i, xpts[shppoint], ypts[shppoint], zpts[shppoint], mpts[shppoint]);
209 &xpts[shpparts[i]], &ypts[shpparts[i]], NULL) )
211 LWDEBUG(4,
"Outer ring not clockwise, forcing clockwise\n");
214 &xpts[shpparts[i]], &ypts[shpparts[i]],
215 &zpts[shpparts[i]], &mpts[shpparts[i]]);
221 &xpts[shpparts[i]], &ypts[shpparts[i]], NULL) )
223 LWDEBUGF(4,
"Inner ring %d not counter-clockwise, forcing counter-clockwise\n", i);
226 &xpts[shpparts[i]], &ypts[shpparts[i]],
227 &zpts[shpparts[i]], &mpts[shpparts[i]]);
250 double *xpts, *ypts, *zpts, *mpts;
252 int *shpparts, shppointtotal = 0, shppoint = 0, shpringtotal = 0, shpring = 0;
257 for (i = 0; i < lwmultipolygon->
ngeoms; i++)
259 for (j = 0; j < lwmultipolygon->
geoms[i]->
nrings; j++)
267 shpparts =
malloc(
sizeof(
int) * shpringtotal);
270 xpts =
malloc(
sizeof(
double) * shppointtotal);
271 ypts =
malloc(
sizeof(
double) * shppointtotal);
272 zpts =
malloc(
sizeof(
double) * shppointtotal);
273 mpts =
malloc(
sizeof(
double) * shppointtotal);
275 LWDEBUGF(4,
"Total number of rings: %d Total number of points: %d", shpringtotal, shppointtotal);
278 for (i = 0; i < lwmultipolygon->
ngeoms; i++)
280 for (j = 0; j < lwmultipolygon->
geoms[i]->
nrings; j++)
283 shpparts[shpring] = shppoint;
285 LWDEBUGF(4,
"Ring offset: %d", shpring);
291 xpts[shppoint] = p4d.
x;
292 ypts[shppoint] = p4d.
y;
293 zpts[shppoint] = p4d.
z;
294 mpts[shppoint] = p4d.
m;
296 LWDEBUGF(4,
"MultiPolygon %d Polygon Ring %d - Point: %g %g %g %g", i, j, xpts[shppoint], ypts[shppoint], zpts[shppoint], mpts[shppoint]);
309 &xpts[shpparts[shpring]], &ypts[shpparts[shpring]], NULL) )
311 LWDEBUG(4,
"Outer ring not clockwise, forcing clockwise\n");
314 &xpts[shpparts[shpring]], &ypts[shpparts[shpring]],
315 &zpts[shpparts[shpring]], &mpts[shpparts[shpring]]);
321 &xpts[shpparts[shpring]], &ypts[shpparts[shpring]], NULL) )
323 LWDEBUGF(4,
"Inner ring %d not counter-clockwise, forcing counter-clockwise\n", i);
326 &xpts[shpparts[shpring]], &ypts[shpparts[shpring]],
327 &zpts[shpparts[shpring]], &mpts[shpparts[shpring]]);
354 double *xpts, *ypts, *zpts, *mpts;
373 LWDEBUGF(4,
"Linestring - Point: %g %g %g %g", i, xpts[i], ypts[i], zpts[i], mpts[i]);
393 double *xpts, *ypts, *zpts, *mpts;
395 int *shpparts, shppointtotal = 0, shppoint = 0;
398 shpparts =
malloc(
sizeof(
int) * lwmultilinestring->
ngeoms);
401 for (i = 0; i < lwmultilinestring->
ngeoms; i++)
404 LWDEBUGF(3,
"Total number of points: %d", shppointtotal);
407 xpts =
malloc(
sizeof(
double) * shppointtotal);
408 ypts =
malloc(
sizeof(
double) * shppointtotal);
409 zpts =
malloc(
sizeof(
double) * shppointtotal);
410 mpts =
malloc(
sizeof(
double) * shppointtotal);
413 for (i = 0; i < lwmultilinestring->
ngeoms; i++)
416 shpparts[i] = shppoint;
422 xpts[shppoint] = p4d.
x;
423 ypts[shppoint] = p4d.
y;
424 zpts[shppoint] = p4d.
z;
425 mpts[shppoint] = p4d.
m;
427 LWDEBUGF(4,
"Linestring %d - Point: %g %g %g %g", i, xpts[shppoint], ypts[shppoint], zpts[shppoint], mpts[shppoint]);
454 for (i=0; i <num_points; i++)
492 double x_change,y_change,area;
493 double *x_new, *y_new;
496 x_new = (
double *)
malloc(
sizeof(
double) * num_points);
497 y_new = (
double *)
malloc(
sizeof(
double) * num_points);
502 for (i=0; i < num_points ; i++)
504 x_new[i] =
x[i] - x_change;
505 y_new[i] =
y[i] - y_change;
508 for (i=0; i < num_points - 1; i++)
511 area += (
x[i] *
y[i+1]) - (
y[i] *
x[i+1]);
544 query = (
char *)
malloc(strlen(fname)+strlen(table)+
547 "select max(octet_length(\"%s\"::text)) from \"%s\".\"%s\"",
548 fname, schema, table);
552 query = (
char *)
malloc(strlen(fname)+strlen(table)+46);
554 "select max(octet_length(\"%s\"::text)) from \"%s\"",
558 LWDEBUGF(4,
"maxFieldLenQuery: %s\n", query);
562 if ( !
res || PQresultStatus(
res) != PGRES_TUPLES_OK )
564 printf(
_(
"Querying for maximum field length: %s"),
565 PQerrorMessage(
conn));
569 if (PQntuples(
res) <= 0 )
574 size = atoi(PQgetvalue(
res, 0, 0));
601 return "MultiPointZ";
609 return "MultiPointM";
627 return "****************";
662 buf[0] = toupper(in[0]);
687 hexewkb =
malloc(size * 2 + 1);
688 for (i=0; i<size; ++i)
deparse_hex(ewkb[i], &hexewkb[i * 2]);
689 hexewkb[size * 2] =
'\0';
704 char *pszFullname, *pszBasename;
707 char *pszFilename = state->
shp_file;
708 char *schema = state->
schema;
709 char *table = state->
table;
716 char *esc_geo_col_name;
728 size += 3 * strlen(schema);
731 esc_table = (
char *)
malloc(3 * strlen(table) + 1);
732 esc_geo_col_name = (
char *)
malloc(3 * strlen(geo_col_name) + 1);
733 PQescapeStringConn(state->
conn, esc_table, table, strlen(table), &error);
734 PQescapeStringConn(state->
conn, esc_geo_col_name, geo_col_name, strlen(geo_col_name), &error);
737 query = (
char *)
malloc(size);
738 if ( ! query )
return 0;
749 esc_schema = (
char *)
malloc(2 * strlen(schema) + 1);
750 PQescapeStringConn(state->
conn, esc_schema, schema, strlen(schema), &error);
751 sprintf(query,
"SELECT COALESCE((SELECT sr.srtext "
752 " FROM geometry_columns As gc INNER JOIN spatial_ref_sys sr ON sr.srid = gc.srid "
753 " WHERE gc.f_table_schema = '%s' AND gc.f_table_name = '%s' AND gc.f_geometry_column = '%s' LIMIT 1), "
754 " (SELECT CASE WHEN COUNT(DISTINCT sr.srid) > 1 THEN 'm' ELSE MAX(sr.srtext) END As srtext "
755 " FROM \"%s\".\"%s\" As g INNER JOIN spatial_ref_sys sr ON sr.srid = ST_SRID((g.\"%s\")::geometry)) , ' ') As srtext ",
756 esc_schema, esc_table,esc_geo_col_name, schema, table, geo_col_name);
761 sprintf(query,
"SELECT COALESCE((SELECT sr.srtext "
762 " FROM geometry_columns As gc INNER JOIN spatial_ref_sys sr ON sr.srid = gc.srid "
763 " WHERE gc.f_table_name = '%s' AND gc.f_geometry_column = '%s' AND pg_table_is_visible((gc.f_table_schema || '.' || gc.f_table_name)::regclass) LIMIT 1), "
764 " (SELECT CASE WHEN COUNT(DISTINCT sr.srid) > 1 THEN 'm' ELSE MAX(sr.srtext) END as srtext "
765 " FROM \"%s\" As g INNER JOIN spatial_ref_sys sr ON sr.srid = ST_SRID((g.\"%s\")::geometry)), ' ') As srtext ",
766 esc_table, esc_geo_col_name, table, geo_col_name);
771 free(esc_geo_col_name);
773 res = PQexec(state->
conn, query);
775 if ( !
res || PQresultStatus(
res) != PGRES_TUPLES_OK )
783 for (i=0; i < PQntuples(
res); i++)
785 srtext = PQgetvalue(
res, i, 0);
786 if (strcmp(srtext,
"m") == 0)
788 snprintf(state->
message,
SHPDUMPERMSGLEN,
_(
"WARNING: Mixed set of spatial references. No prj file will be generated"));
795 if (srtext[0] ==
' ')
797 snprintf(state->
message,
SHPDUMPERMSGLEN,
_(
"WARNING: Cannot determine spatial reference (empty table or unknown spatial ref). No prj file will be generated."));
808 pszBasename = (
char *)
malloc(strlen(pszFilename)+5);
809 strcpy( pszBasename, pszFilename );
810 for ( i = strlen(pszBasename)-1;
811 i > 0 && pszBasename[i] !=
'.' && pszBasename[i] !=
'/'
812 && pszBasename[i] !=
'\\';
815 if ( pszBasename[i] ==
'.' )
816 pszBasename[i] =
'\0';
818 pszFullname = (
char *)
malloc(strlen(pszBasename) + 5);
819 sprintf( pszFullname,
"%s.prj", pszBasename );
826 fp = fopen( pszFullname,
"wb" );
835 result = fputs (srtext,fp);
836 LWDEBUGF(3,
"\n result %d proj SRText is %s .\n", result, srtext);
885 sprintf(query,
"SELECT count(1), max(ST_zmflag(\"%s\"::geometry)), geometrytype(\"%s\"::geometry) FROM \"%s\".\"%s\" GROUP BY 3",
892 sprintf(query,
"SELECT count(1), max(ST_zmflag(\"%s\"::geometry)), geometrytype(\"%s\"::geometry) FROM \"%s\" GROUP BY 3",
903 sprintf(query,
"SELECT count(1) FROM \"%s\".\"%s\"", state->
schema, state->
table);
909 sprintf(query,
"SELECT count(1) FROM \"%s\"", state->
table);
913 LWDEBUGF(3,
"Table metadata query: %s\n", query);
915 res = PQexec(state->
conn, query);
918 if (PQresultStatus(
res) != PGRES_TUPLES_OK)
926 if (PQntuples(
res) == 0)
947 int typefound = 0, typemismatch = 0;
951 for (i = 0; i < PQntuples(
res); i++)
954 if (PQgetisnull(
res, i, 2))
1017 tmpint = atoi(PQgetvalue(
res, i, 1));
1135 config->
table = NULL;
1166 state->
table = NULL;
1191 connstring =
malloc(connlen);
1192 memset(connstring, 0, connlen);
1196 strcat(connstring,
" host=");
1202 strcat(connstring,
" port=");
1208 strcat(connstring,
" user=");
1214 strcat(connstring,
" password='");
1216 strcat(connstring,
"'");
1221 strcat(connstring,
" dbname=");
1225 if ( ! getenv(
"PGCLIENTENCODING") )
1227 strcat(connstring,
" client_encoding=UTF8");
1240 char *connstring, *tmpvalue;
1246 state->
conn = PQconnectdb(connstring);
1247 if (PQstatus(state->
conn) == CONNECTION_BAD)
1255 res = PQexec(state->
conn,
"SET DATESTYLE='ISO'");
1256 if (PQresultStatus(
res) != PGRES_COMMAND_OK)
1267 res = PQexec(state->
conn,
"SELECT postgis_version()");
1268 if (PQresultStatus(
res) != PGRES_TUPLES_OK)
1276 tmpvalue = PQgetvalue(
res, 0, 0);
1282 res = PQexec(state->
conn,
"SELECT oid FROM pg_type WHERE typname = 'geometry'");
1283 if (PQresultStatus(
res) != PGRES_TUPLES_OK)
1291 if (PQntuples(
res) > 0)
1293 tmpvalue = PQgetvalue(
res, 0, 0);
1307 res = PQexec(state->
conn,
"SELECT oid FROM pg_type WHERE typname = 'geography'");
1308 if (PQresultStatus(
res) != PGRES_TUPLES_OK)
1316 if (PQntuples(
res) > 0)
1319 tmpvalue = PQgetvalue(
res, 0, 0);
1339 int gidfound = 0, i, j, ret, status;
1354 sprintf(state->
table,
"__pgsql2shp%lu_tmp_table", (
long)getpid());
1359 res = PQexec(state->
conn, query);
1363 if (PQresultStatus(
res) != PGRES_COMMAND_OK)
1384 sprintf(query,
"SELECT a.attname, a.atttypid, "
1385 "a.atttypmod, a.attlen FROM "
1386 "pg_attribute a, pg_class c, pg_namespace n WHERE "
1387 "n.nspname = '%s' AND a.attrelid = c.oid AND "
1388 "n.oid = c.relnamespace AND "
1389 "a.atttypid != 0 AND "
1390 "a.attnum > 0 AND c.relname = '%s'", state->
schema, state->
table);
1396 sprintf(query,
"SELECT a.attname, a.atttypid, "
1397 "a.atttypmod, a.attlen FROM "
1398 "pg_attribute a, pg_class c WHERE "
1399 "a.attrelid = c.oid and a.attnum > 0 AND "
1400 "a.atttypid != 0 AND "
1401 "c.relname = '%s' AND "
1402 "pg_catalog.pg_table_is_visible(c.oid)", state->
table);
1405 LWDEBUGF(3,
"query is: %s\n", query);
1407 res = PQexec(state->
conn, query);
1410 if (PQresultStatus(
res) != PGRES_TUPLES_OK)
1417 if (!PQntuples(
res))
1433 if ( getenv(
"PGCLIENTENCODING") )
1461 for (i = 0; i < PQntuples(
res); i++)
1465 int pgfieldtype, pgtypmod, pgfieldlen;
1468 int dbffieldtype, dbffieldsize, dbffielddecs;
1471 pgfieldname = PQgetvalue(
res, i, 0);
1472 pgfieldtype = atoi(PQgetvalue(
res, i, 1));
1473 pgtypmod = atoi(PQgetvalue(
res, i, 2));
1474 pgfieldlen = atoi(PQgetvalue(
res, i, 3));
1505 if (!strcmp(pgfieldname,
"gid") )
1527 dbffieldname =
malloc(11);
1528 strncpy(dbffieldname, ptr, 10);
1529 dbffieldname[10] =
'\0';
1538 strncpy(dbffieldname, mapped, 10);
1539 dbffieldname[10] =
'\0';
1549 if (!strncasecmp(dbffieldname, state->
dbffieldnames[j], 10))
1551 sprintf(dbffieldname,
"%.7s_%.2d", ptr, abs(tmpint) % 100);
1561 for (nameit = 0; nameit < strlen(dbffieldname); nameit++)
1562 dbffieldname[nameit] = toupper(dbffieldname[nameit]);
1566 if (strcasecmp(dbffieldname, pgfieldname))
1568 if ( snprintf(buf, 256,
_(
"Warning, field %s renamed to %s\n"),
1569 pgfieldname, dbffieldname) >= 256 )
1585 if (pgfieldtype == 21)
1592 dbffieldtype = FTInteger;
1598 else if (pgfieldtype == 23)
1605 dbffieldtype = FTInteger;
1611 else if (pgfieldtype == 20)
1618 dbffieldtype = FTInteger;
1632 else if (pgfieldtype == 700 || pgfieldtype == 701 || pgfieldtype == 1700)
1634 dbffieldtype = FTDouble;
1642 else if (pgfieldtype == 16)
1644 dbffieldtype = FTLogical;
1652 else if (pgfieldtype == 1082)
1654 dbffieldtype = FTDate;
1662 else if (pgfieldtype == 1083 || pgfieldtype == 1266 || pgfieldtype == 1114 || pgfieldtype == 1184)
1675 secondsize = pgtypmod + 1;
1687 if (pgfieldtype == 1083)
1689 dbffieldsize = 8 + secondsize;
1692 else if (pgfieldtype == 1266)
1694 dbffieldsize = 8 + secondsize + 9;
1697 else if (pgfieldtype == 1114)
1699 dbffieldsize = 13 + 1 + 8 + secondsize;
1702 else if (pgfieldtype == 1184)
1704 dbffieldsize = 13 + 1 + 8 + secondsize + 9;
1707 dbffieldtype = FTString;
1714 else if (pgfieldtype == 2950)
1716 dbffieldtype = FTString;
1726 else if ((pgfieldtype == 1042 || pgfieldtype == 1043) && pgtypmod != -1)
1732 dbffieldtype = FTString;
1733 dbffieldsize = pgtypmod - 4;
1738 else if (dbffieldtype == -1)
1746 if (dbffieldsize == -1)
1757 dbffieldtype = FTString;
1764 snprintf(buf, 256,
_(
"Warning: values of field '%s' exceeding maximum dbf field width (%d) "
1773 LWDEBUGF(3,
"DBF FIELD_NAME: %s, SIZE: %d\n", dbffieldname, dbffieldsize);
1775 if (dbffieldtype != 9)
1778 if (
DBFAddField(state->
dbf, dbffieldname, dbffieldtype, dbffieldsize, dbffielddecs) == -1)
1780 snprintf(state->
message,
SHPDUMPERMSGLEN,
_(
"Error: field %s of type %d could not be created."), dbffieldname, dbffieldtype);
1819 snprintf(buf, 256,
_(
"No geometry column found.\nThe DBF file will be created but not the shx or shp files.\n"));
1876 #ifdef WORDS_BIGENDIAN
1883 sprintf(buf,
"asbinary(%s::geometry, 'XDR') AS _geoX",
1893 sprintf(buf,
"asbinary(%s::geometry, 'NDR') AS _geoX",
1903 sprintf(buf,
" FROM \"%s\".\"%s\"", state->
schema, state->
table);
1907 sprintf(buf,
" FROM \"%s\"", state->
table);
1915 sprintf(buf,
" ORDER BY \"gid\"");
1928 res = PQexec(state->
conn,
"BEGIN");
1929 if (!
res || PQresultStatus(
res) != PGRES_COMMAND_OK)
1940 if (!
res || PQresultStatus(
res) != PGRES_COMMAND_OK)
1966 char *hexewkb = NULL;
1967 unsigned char *hexewkb_binary = NULL;
1973 int i, geocolnum = 0;
1991 if (PQresultStatus(state->
fetchres) != PGRES_TUPLES_OK)
2004 geocolnum = PQfnumber(state->
fetchres,
"_geoX");
2061 LWDEBUG(4,
"PostGIS >= 1.0, non-binary cursor");
2065 hexewkb_binary = PQunescapeBytea((
unsigned char *)val, &hexewkb_len);
2070 LWDEBUG(4,
"PostGIS < 1.0, non-binary cursor");
2075 hexewkb =
malloc(hexewkb_len + 1);
2076 strncpy(hexewkb, val, hexewkb_len + 1);
2081 LWDEBUG(4,
"PostGIS (any version) using binary cursor");
2088 LWDEBUGF(4,
"HexEWKB - length: %d value: %s", strlen(hexewkb), hexewkb);
2103 switch (lwgeom->
type)
2158 if (hexewkb)
free(hexewkb);
2159 if (hexewkb_binary) PQfreemem(hexewkb_binary);
2212 PQfinish(state->
conn);
2258 char *result =
malloc(strlen(
s) * 2 + 3);
int SHPAPI_CALL DBFAddField(DBFHandle psDBF, const char *pszFieldName, DBFFieldType eType, int nWidth, int nDecimals)
DBFHandle SHPAPI_CALL DBFCreateEx(const char *pszFilename, const char *pszCodePage)
void SHPAPI_CALL DBFClose(DBFHandle psDBF)
int SHPAPI_CALL DBFWriteAttributeDirectly(DBFHandle psDBF, int hEntity, int iField, void *pValue)
void deparse_hex(uint8_t str, char *result)
Convert a char into a human readable hex digit.
LWLINE * lwgeom_as_lwline(const LWGEOM *lwgeom)
POINT4D getPoint4d(const POINTARRAY *pa, uint32_t n)
LWGEOM * lwgeom_from_hexwkb(const char *hexwkb, const char check)
LWMPOINT * lwgeom_as_lwmpoint(const LWGEOM *lwgeom)
void lwgeom_free(LWGEOM *geom)
#define LW_PARSER_CHECK_NONE
LWMPOLY * lwgeom_as_lwmpoly(const LWGEOM *lwgeom)
int lwtype_is_collection(uint8_t type)
Determine whether a type number is a collection or not.
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
int geometry_type_from_string(const char *str, uint8_t *type, int *z, int *m)
Utility function to get type number from string.
LWMLINE * lwgeom_as_lwmline(const LWGEOM *lwgeom)
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
LWPOLY * lwgeom_as_lwpoly(const LWGEOM *lwgeom)
#define LWDEBUG(level, msg)
#define LWDEBUGF(level, msg,...)
static int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members)
static LWPOINT * lwgeom_as_lwpoint(const LWGEOM *lwgeom)
void set_dumper_config_defaults(SHPDUMPERCONFIG *config)
static int getMaxFieldSize(PGconn *conn, char *schema, char *table, char *fname)
static SHPObject * create_polygon(SHPDUMPERSTATE *state, LWPOLY *lwpolygon)
int ShpDumperGetRecordCount(SHPDUMPERSTATE *state)
static SHPObject * create_multipolygon(SHPDUMPERSTATE *state, LWMPOLY *lwmultipolygon)
void ShpDumperDestroy(SHPDUMPERSTATE *state)
char * convert_bytes_to_hex(uint8_t *ewkb, size_t size)
Binary to hexewkb conversion function.
char * shapetypename(int num)
SHPDUMPERSTATE * ShpDumperCreate(SHPDUMPERCONFIG *config)
static SHPObject * create_linestring(SHPDUMPERSTATE *state, LWLINE *lwlinestring)
static int getTableInfo(SHPDUMPERSTATE *state)
int ShpDumperConnectDatabase(SHPDUMPERSTATE *state)
static int projFileCreate(SHPDUMPERSTATE *state)
Creates ESRI .prj file for this shp output It looks in the spatial_ref_sys table and outputs the srte...
int ShpLoaderGenerateShapeRow(SHPDUMPERSTATE *state)
static int reverse_points(int num_points, double *x, double *y, double *z, double *m)
static char * goodDBFValue(char *in, char fieldType)
Make appropriate formatting of a DBF value based on type.
static SHPObject * create_point(SHPDUMPERSTATE *state, LWPOINT *lwpoint)
int ShpDumperCloseTable(SHPDUMPERSTATE *state)
static int is_clockwise(int num_points, double *x, double *y, double *z)
char * quote_identifier(const char *s)
int ShpDumperOpenTable(SHPDUMPERSTATE *state)
static SHPObject * create_point_empty(SHPDUMPERSTATE *state, LWPOINT *lwpoint)
static char * nullDBFValue(char fieldType)
char * ShpDumperGetConnectionStringFromConn(SHPCONNECTIONCONFIG *conn)
#define MAX_DBF_FIELD_SIZE
static SHPObject * create_multipoint(SHPDUMPERSTATE *state, LWMPOINT *lwmultipoint)
static SHPObject * create_multilinestring(SHPDUMPERSTATE *state, LWMLINE *lwmultilinestring)
SHPHandle SHPAPI_CALL SHPCreate(const char *pszShapeFile, int nShapeType)
void SHPAPI_CALL SHPClose(SHPHandle hSHP)
void SHPAPI_CALL SHPDestroyObject(SHPObject *psObject)
SHPObject SHPAPI_CALL1 * SHPCreateObject(int nSHPType, int nShapeId, int nParts, const int *panPartStart, const int *panPartType, int nVertices, const double *padfX, const double *padfY, const double *padfZ, const double *padfM);SHPObject SHPAPI_CALL1(*) SHPCreateSimpleObject(int nSHPType, int nVertices, const double *padfX, const double *padfY, const double *padfZ
static SHPCONNECTIONCONFIG * conn
char * encoding2codepage(const char *encoding)
int colmap_read(const char *filename, colmap *map, char *errbuf, size_t errbuflen)
Read the content of filename into a symbol map.
void colmap_init(colmap *map)
const char * colmap_dbf_by_pg(colmap *map, const char *pgname)
void colmap_clean(colmap *map)
SHPObject SHPAPI_CALL1 * SHPCreateSimpleObject(int nSHPType, int nVertices, const double *padfX, const double *padfY, const double *padfZ){ return(SHPCreateObject(nSHPType, -1, 0, NULL, NULL, nVertices, padfX, padfY, padfZ, NULL)
int SHPAPI_CALL SHPWriteObject(SHPHandle psSHP, int nShapeId, SHPObject *psObject)
char * column_map_filename
SHPCONNECTIONCONFIG * conn
char message[SHPDUMPERMSGLEN]