Merge branch 'master' into ignore-error

Conflicts:
	mbtiles.c
This commit is contained in:
Eric Fischer
2016-02-01 10:10:05 -08:00
27 changed files with 32258 additions and 12 deletions
+28 -1
View File
@@ -122,6 +122,18 @@ static void aprintf(char **buf, const char *format, ...) {
free(tmp);
}
static int pvcmp(const void *v1, const void *v2) {
const struct pool_val *const *pv1 = v1;
const struct pool_val *const *pv2 = v2;
int n = strcmp((*pv1)->s, (*pv2)->s);
if (n != 0) {
return n;
}
return (*pv1)->type - (*pv2)->type;
}
void mbtiles_write_metadata(sqlite3 *outdb, const char *fname, char **layername, int minzoom, int maxzoom, double minlat, double minlon, double maxlat, double maxlon, double midlat, double midlon, struct pool **file_keys, int nlayers, int forcetable) {
char *sql, *err;
@@ -219,8 +231,23 @@ void mbtiles_write_metadata(sqlite3 *outdb, const char *fname, char **layername,
quote(&buf, layername[i]);
aprintf(&buf, "\", \"description\": \"\", \"minzoom\": %d, \"maxzoom\": %d, \"fields\": {", minzoom, maxzoom);
int n = 0;
struct pool_val *pv;
for (pv = file_keys[i]->head; pv != NULL; pv = pv->next) {
n++;
}
struct pool_val *vals[n];
n = 0;
for (pv = file_keys[i]->head; pv != NULL; pv = pv->next) {
vals[n++] = pv;
}
qsort(vals, n, sizeof(struct pool_val *), pvcmp);
int j;
for (j = 0; j < n; j++) {
pv = vals[j];
aprintf(&buf, "\"");
quote(&buf, pv->s);
@@ -232,7 +259,7 @@ void mbtiles_write_metadata(sqlite3 *outdb, const char *fname, char **layername,
aprintf(&buf, "\": \"String\"");
}
if (pv->next != NULL) {
if (j + 1 < n) {
aprintf(&buf, ", ");
}
}