Definition at line 839 of file shp2pgsql-core.c.
840{
842 int j, z;
844
845 int field_precision, field_width;
848 DBFFieldType
type = FTInvalid;
849 char *utf8str;
850
851
853 {
855
857 {
860
862 }
863 }
864
865
868 {
870
872 }
873
874
875
877 {
881 }
882
883
885 {
886
888 {
889
890 char *newencoding = NULL;
892 {
895 }
896 }
897 }
898
899
901 {
903
904
906 {
907
909 {
911
912 if (!obj)
913 {
916 }
917
919 {
922 }
923
925 }
926 }
927
928
929 int geomtype = 0;
931 {
933
937 break;
938
940
941 state->
pgtype =
"MULTILINESTRING";
944 break;
945
947
948 state->
pgtype =
"MULTIPOLYGON";
951 break;
952
954
955 state->
pgtype =
"MULTIPOINT";
958 break;
959
961
966 break;
967
969
972 state->
pgtype =
"MULTILINESTRINGM";
974 break;
975
977
980 state->
pgtype =
"MULTIPOLYGONM";
982 break;
983
985
988 state->
pgtype =
"MULTIPOINTM";
990 break;
991
993
999 break;
1000
1002
1003 state->
pgtype =
"MULTILINESTRING";
1008 break;
1009
1011
1012 state->
pgtype =
"MULTIPOLYGON";
1017 break;
1018
1020
1021 state->
pgtype =
"MULTIPOINT";
1026 break;
1027
1028 default:
1029 state->
pgtype =
"GEOMETRY";
1034
1037
1038 break;
1039 }
1040
1041
1043 {
1048 break;
1049
1054 break;
1055
1060 break;
1061
1066 break;
1067 default:
1068
1069 break;
1070 }
1071
1072
1074 {
1076 {
1077
1079 }
1080 }
1081
1082 }
1083 else
1084 {
1085
1087 }
1088
1089
1090
1092
1094
1095
1102
1104
1105
1106
1108 {
1110
1112 state->
widths[j] = field_width;
1114
1115
1117 {
1118 char *encoding_msg =
_(
"Try \"LATIN1\" (Western European), or one of the values described at http://www.gnu.org/software/libiconv/.");
1119
1121
1123 {
1125 snprintf(state->
message,
SHPLOADERMSGLEN,
_(
"Unable to convert field name \"%s\" to UTF-8 (iconv reports \"%s\"). Current encoding is \"%s\". %s"), utf8str, strerror(errno), state->
config->
encoding, encoding_msg);
1127 snprintf(state->
message,
SHPLOADERMSGLEN,
_(
"Unable to convert field name to UTF-8 (iconv reports \"%s\"). Current encoding is \"%s\". %s"), strerror(errno), state->
config->
encoding, encoding_msg);
1128 else
1130
1133
1135 }
1136
1140 }
1141
1142
1143
1144 {
1146 if (mapped)
1147 {
1150 }
1151 }
1152
1153
1154
1155
1156
1159
1160
1161
1162
1163
1164
1165 if (name[0] == '_' ||
1166 ! strcmp(name, "gid") || ! strcmp(name, "tableoid") ||
1167 ! strcmp(name, "cmin") ||
1168 ! strcmp(name, "cmax") ||
1169 ! strcmp(name, "xmin") ||
1170 ! strcmp(name, "xmax") ||
1171 ! strcmp(name, "primary") ||
1172 ! strcmp(name, "oid") || ! strcmp(name, "ctid"))
1173 {
1174 size_t len = strlen(name);
1177 strncpy(name2 + 2, name, len);
1179 name2[len + 2] = '\0';
1180 name2[0] = '_';
1181 name2[1] = '_';
1182 strcpy(name, name2);
1183 }
1184
1185
1186 for (z = 0; z < j ; z++)
1187 {
1189 {
1191 snprintf(name + strlen(name),
1193 "%i",
1194 j);
1195 break;
1196 }
1197 }
1198
1200
1201
1202 switch (state->
types[j])
1203 {
1204 case FTString:
1206 break;
1207
1208 case FTDate:
1210 break;
1211
1212 case FTInteger:
1213
1215 {
1217 }
1218 else if (state->
widths[j] >=10 && state->
widths[j] < 19)
1219 {
1221 }
1222 else if (state->
widths[j] < 5)
1223 {
1225 }
1226 else
1227 {
1229 }
1230 break;
1231
1232 case FTDouble:
1233
1234 fprintf(stderr, "Field %s is an FTDouble with width %d and precision %d\n",
1236 if (state->
widths[j] > 18)
1237 {
1239 }
1240 else
1241 {
1243 }
1244 break;
1245
1246 case FTLogical:
1248 break;
1249
1250 default:
1253 }
1254
1257
1259 {
1260
1262 }
1263 else
1264 {
1266 }
1267 }
1268
1269
1272
1273
1274 return ret;
1275}
int SHPAPI_CALL DBFGetFieldCount(DBFHandle psDBF)
DBFHandle SHPAPI_CALL DBFOpen(const char *pszFilename, const char *pszAccess)
int SHPAPI_CALL DBFGetRecordCount(DBFHandle psDBF)
DBFFieldType SHPAPI_CALL DBFGetFieldInfo(DBFHandle psDBF, int iField, char *pszFieldName, int *pnWidth, int *pnDecimals)
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
void SHPAPI_CALL SHPDestroyObject(SHPObject *psObject)
SHPHandle SHPAPI_CALL SHPOpen(const char *pszShapeFile, const char *pszAccess)
void SHPAPI_CALL SHPGetInfo(SHPHandle hSHP, int *pnEntities, int *pnShapeType, double *padfMinBound, double *padfMaxBound)
SHPObject SHPAPI_CALL1 * SHPReadObject(SHPHandle hSHP, int iShape);int SHPAPI_CALL SHPWriteObject(SHPHandle hSHP, int iShape, SHPObject *psObject
static int utf8(const char *fromcode, char *inputbuf, char **outputbuf)
#define POLICY_NULL_ABORT
int colmap_read(const char *filename, colmap *map, char *errbuf, size_t errbuflen)
Read the content of filename into a symbol map.
char * codepage2encoding(const char *cpg)
const char * colmap_pg_by_dbf(colmap *map, const char *dbfname)
char * column_map_filename
char message[SHPLOADERMSGLEN]
References _, codepage2encoding(), shp_loader_state::col_names, COLLECTIONTYPE, colmap_pg_by_dbf(), colmap_read(), shp_loader_state::column_map, shp_loader_config::column_map_filename, shp_loader_state::config, DBFGetFieldCount(), DBFGetFieldInfo(), DBFGetRecordCount(), DBFOpen(), shp_loader_config::encoding, ENCODING_DEFAULT, shp_loader_state::field_names, shp_loader_config::force_output, FORCE_OUTPUT_2D, FORCE_OUTPUT_3DM, FORCE_OUTPUT_3DZ, FORCE_OUTPUT_4D, shp_loader_config::forceint4, free(), shp_loader_state::geo_col, shp_loader_state::has_m, shp_loader_state::has_z, shp_loader_state::hDBFHandle, shp_loader_state::hSHPHandle, lwfree(), malloc(), MAXFIELDNAMELEN, shp_loader_state::message, MULTILINETYPE, MULTIPOINTTYPE, MULTIPOLYGONTYPE, shp_loader_config::null_policy, shp_loader_state::num_entities, shp_loader_state::num_fields, shp_loader_state::num_records, SHPObject::nVertices, shp_loader_state::pgdims, shp_loader_state::pgfieldtypes, shp_loader_state::pgtype, POINTTYPE, POLICY_NULL_ABORT, shp_loader_state::precisions, shp_loader_config::quoteidentifiers, shp_loader_config::readshape, shp_loader_config::shp_file, SHPDestroyObject(), shp_loader_state::shpfiletype, SHPGetInfo(), SHPLOADERERR, SHPLOADERMSGLEN, SHPLOADEROK, SHPLOADERWARN, SHPOpen(), SHPReadObject(), SHPT_ARC, SHPT_ARCM, SHPT_ARCZ, SHPT_MULTIPOINT, SHPT_MULTIPOINTM, SHPT_MULTIPOINTZ, SHPT_POINT, SHPT_POINTM, SHPT_POINTZ, SHPT_POLYGON, SHPT_POLYGONM, SHPT_POLYGONZ, shp_loader_config::simple_geometries, strtolower(), shp_loader_state::types, utf8(), UTF8_BAD_RESULT, UTF8_GOOD_RESULT, UTF8_NO_RESULT, and shp_loader_state::widths.
Referenced by main(), pgui_action_import(), and validate_remote_loader_columns().