867{
868
869
870
871
872
873
874
875
876
877
878
879
880
882 char *query;
883 int tmpint;
884
885
887 {
888
890 {
892 "SELECT count(1), max(ST_zmflag(\"%s\"::geometry)), geometrytype(\"%s\"::geometry) FROM \"%s\".\"%s\" GROUP BY 3",
894 }
895 else
896 {
898 "SELECT count(1), max(ST_zmflag(\"%s\"::geometry)), geometrytype(\"%s\"::geometry) FROM \"%s\" GROUP BY 3",
900 }
901 }
902 else
903 {
904
906 {
908 "SELECT count(1) FROM \"%s\".\"%s\"",
910 }
911 else
912 {
914 "SELECT count(1) FROM \"%s\"",
916 }
917 }
918
919 LWDEBUGF(3,
"Table metadata query: %s\n", query);
920
921 res = PQexec(state->
conn, query);
923
924 if (PQresultStatus(res) != PGRES_TUPLES_OK)
925 {
926 snprintf(state->
message,
SHPDUMPERMSGLEN,
_(
"ERROR: Could not execute table metadata query: %s"), PQresultErrorMessage(res));
927 PQclear(res);
929 }
930
931
932 if (PQntuples(res) == 0)
933 {
935 PQclear(res);
937 }
938
939
941 {
942
943
944
945
946
947
948
949
950
951 int dummy, i;
953 int typefound = 0, typemismatch = 0;
954
956
957 for (i = 0; i < PQntuples(res); i++)
958 {
959
960 if (PQgetisnull(res, i, 2))
961 {
962 state->
rowcount += atoi(PQgetvalue(res, i, 0));
963 continue;
964 }
965
967
968
969 if (!typefound)
971
972 switch (type)
973 {
976 typemismatch = 1;
977 else
979 break;
980
983 typemismatch = 1;
984 else
986 break;
987
990 typemismatch = 1;
991 else
993 break;
994
997 typemismatch = 1;
1000 break;
1001
1004 typemismatch = 1;
1007 break;
1008
1011 typemismatch = 1;
1014 break;
1015 }
1016
1017
1018 state->
rowcount += atoi(PQgetvalue(res, i, 0));
1019
1020
1021
1022
1023 tmpint = atoi(PQgetvalue(res, i, 1));
1024 switch (tmpint)
1025 {
1026 case 0:
1028 break;
1029 case 1:
1031 break;
1032 default:
1034 break;
1035 }
1036
1037 }
1038
1039
1040 if (typemismatch)
1041 {
1043 PQclear(res);
1045 }
1046
1047
1048 switch (typefound)
1049 {
1052 {
1053 case 'z':
1055 break;
1056
1057 case 'm':
1059 break;
1060
1061 default:
1063 }
1064 break;
1065
1068 {
1069 case 'z':
1071 break;
1072
1073 case 'm':
1075 break;
1076
1077 default:
1079 }
1080 break;
1081
1085 {
1086 case 'z':
1088 break;
1089
1090 case 'm':
1092 break;
1093
1094 default:
1096 }
1097 break;
1098
1102 {
1103 case 'z':
1105 break;
1106
1107 case 'm':
1109 break;
1110
1111 default:
1113 }
1114 break;
1115 }
1116 }
1117 else
1118 {
1119
1120 state->
rowcount = atoi(PQgetvalue(res, 0, 0));
1121 }
1122
1123
1124 PQclear(res);
1125
1127}
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.
#define LWDEBUGF(level, msg,...)
static char * core_asprintf(const char *format,...) __attribute__((format(printf
char message[SHPDUMPERMSGLEN]