mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-05 18:05:42 +02:00
Fix my pointer confusion around the global keys per layer
This commit is contained in:
+29
-8
@@ -120,7 +120,16 @@ void handle(std::string message, int z, unsigned x, unsigned y, struct pool **fi
|
|||||||
*file_keys = (struct pool *) realloc(*file_keys, (ll + 1) * sizeof(struct pool));
|
*file_keys = (struct pool *) realloc(*file_keys, (ll + 1) * sizeof(struct pool));
|
||||||
*layernames = (char **) realloc(*layernames, (ll + 1) * sizeof(char *));
|
*layernames = (char **) realloc(*layernames, (ll + 1) * sizeof(char *));
|
||||||
|
|
||||||
pool_init(file_keys[ll], 0);
|
if (*file_keys == NULL) {
|
||||||
|
perror("realloc file_keys");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
if (*layernames == NULL) {
|
||||||
|
perror("realloc layernames");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
pool_init(&((*file_keys)[ll]), 0);
|
||||||
(*layernames)[ll] = strdup(ln);
|
(*layernames)[ll] = strdup(ln);
|
||||||
*nlayers = ll + 1;
|
*nlayers = ll + 1;
|
||||||
}
|
}
|
||||||
@@ -175,8 +184,8 @@ void handle(std::string message, int z, unsigned x, unsigned y, struct pool **fi
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_pooled(file_keys[ll], key, type)) {
|
if (!is_pooled(&((*file_keys)[ll]), key, type)) {
|
||||||
pool(file_keys[ll], strdup(key), type);
|
pool(&((*file_keys)[ll]), strdup(key), type);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct pool_val *k, *v;
|
struct pool_val *k, *v;
|
||||||
@@ -266,19 +275,20 @@ void decode(char *fname, char *map, struct pool **file_keys, char ***layernames,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void usage(char **argv) {
|
void usage(char **argv) {
|
||||||
fprintf(stderr, "Usage: %s [-f] -o new.mbtiles source.mbtiles map.csv\n", argv[0]);
|
fprintf(stderr, "Usage: %s [-f] [-c joins.csv] -o new.mbtiles source.mbtiles ...\n", argv[0]);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
char *outfile = NULL;
|
char *outfile = NULL;
|
||||||
|
char *csv = NULL;
|
||||||
int force = 0;
|
int force = 0;
|
||||||
|
|
||||||
extern int optind;
|
extern int optind;
|
||||||
extern char *optarg;
|
extern char *optarg;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
while ((i = getopt(argc, argv, "fo:")) != -1) {
|
while ((i = getopt(argc, argv, "fo:c:")) != -1) {
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case 'o':
|
case 'o':
|
||||||
outfile = optarg;
|
outfile = optarg;
|
||||||
@@ -288,12 +298,16 @@ int main(int argc, char **argv) {
|
|||||||
force = 1;
|
force = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'c':
|
||||||
|
csv = optarg;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
usage(argv);
|
usage(argv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc != optind + 2 || outfile == NULL) {
|
if (argc - optind < 1 || outfile == NULL) {
|
||||||
usage(argv);
|
usage(argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -307,13 +321,20 @@ int main(int argc, char **argv) {
|
|||||||
char **layernames = NULL;
|
char **layernames = NULL;
|
||||||
int nlayers = 0;
|
int nlayers = 0;
|
||||||
|
|
||||||
decode(argv[optind], argv[optind + 1], &file_keys, &layernames, &nlayers, outdb);
|
for (i = optind; i < argc; i++) {
|
||||||
|
decode(argv[i], csv, &file_keys, &layernames, &nlayers, outdb);
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < nlayers; i++) {
|
for (i = 0; i < nlayers; i++) {
|
||||||
printf("%s\n", layernames[i]);
|
printf("%s\n", layernames[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
mbtiles_write_metadata(outdb, outfile, layernames, 0, 0, 0, 0, 0, 0, 0, 0, &file_keys, nlayers);
|
struct pool *fk[nlayers];
|
||||||
|
for (i = 0; i < nlayers; i++) {
|
||||||
|
fk[i] = &(file_keys[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
mbtiles_write_metadata(outdb, outfile, layernames, 0, 0, 0, 0, 0, 0, 0, 0, fk, nlayers);
|
||||||
mbtiles_close(outdb, argv);
|
mbtiles_close(outdb, argv);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user