mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-02 08:25:40 +02:00
Merge files into one layer if a name is specified with -l
This commit is contained in:
@@ -54,7 +54,8 @@ Options
|
|||||||
|
|
||||||
### Naming
|
### Naming
|
||||||
|
|
||||||
* -l _name_: Layer name (default "file" if source is file.json or output is file.mbtiles). Only works if there is only one layer.
|
* -l _name_: Layer name (default "file" if source is file.json or output is file.mbtiles). If there are multiple input files
|
||||||
|
specified, the files are all merged into the single named layer.
|
||||||
* -n _name_: Human-readable name (default file.json)
|
* -n _name_: Human-readable name (default file.json)
|
||||||
|
|
||||||
### File control
|
### File control
|
||||||
|
|||||||
@@ -109,6 +109,20 @@ void handle(std::string message, int z, unsigned x, unsigned y, int describe) {
|
|||||||
mapnik::vector::tile_layer layer = tile.layers(l);
|
mapnik::vector::tile_layer layer = tile.layers(l);
|
||||||
int extent = layer.extent();
|
int extent = layer.extent();
|
||||||
|
|
||||||
|
if (describe) {
|
||||||
|
if (l != 0) {
|
||||||
|
printf(",\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("{ \"type\": \"FeatureCollection\"");
|
||||||
|
printf(", \"properties\": { \"name\": ");
|
||||||
|
printq(layer.name().c_str());
|
||||||
|
printf(" }");
|
||||||
|
printf(", \"features\": [\n");
|
||||||
|
|
||||||
|
within = 0;
|
||||||
|
}
|
||||||
|
|
||||||
for (int f = 0; f < layer.features_size(); f++) {
|
for (int f = 0; f < layer.features_size(); f++) {
|
||||||
mapnik::vector::tile_feature feat = layer.features(f);
|
mapnik::vector::tile_feature feat = layer.features(f);
|
||||||
int px = 0, py = 0;
|
int px = 0, py = 0;
|
||||||
@@ -275,6 +289,7 @@ void handle(std::string message, int z, unsigned x, unsigned y, int describe) {
|
|||||||
|
|
||||||
int state = 0;
|
int state = 0;
|
||||||
for (unsigned i = 0; i < rings.size(); i++) {
|
for (unsigned i = 0; i < rings.size(); i++) {
|
||||||
|
printf("AREA %f ", areas[i]);
|
||||||
if (areas[i] <= 0) {
|
if (areas[i] <= 0) {
|
||||||
if (state != 0) {
|
if (state != 0) {
|
||||||
// new multipolygon
|
// new multipolygon
|
||||||
@@ -316,6 +331,10 @@ void handle(std::string message, int z, unsigned x, unsigned y, int describe) {
|
|||||||
|
|
||||||
printf(" } }\n");
|
printf(" } }\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (describe) {
|
||||||
|
printf("] }\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("] }\n");
|
printf("] }\n");
|
||||||
|
|||||||
@@ -796,31 +796,48 @@ int read_json(int argc, char **argv, char *fname, const char *layername, int max
|
|||||||
unsigned midx = 0, midy = 0;
|
unsigned midx = 0, midy = 0;
|
||||||
long long seq = 0;
|
long long seq = 0;
|
||||||
|
|
||||||
int nlayers = argc;
|
int nlayers;
|
||||||
if (nlayers == 0) {
|
if (layername != NULL) {
|
||||||
nlayers = 1;
|
nlayers = 1;
|
||||||
|
} else {
|
||||||
|
nlayers = argc;
|
||||||
|
if (nlayers == 0) {
|
||||||
|
nlayers = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int layer;
|
int nsources = argc;
|
||||||
for (layer = 0; layer < nlayers; layer++) {
|
if (nsources == 0) {
|
||||||
|
nsources = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int source;
|
||||||
|
for (source = 0; source < nsources; source++) {
|
||||||
json_pull *jp;
|
json_pull *jp;
|
||||||
const char *reading;
|
const char *reading;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
|
||||||
if (layer >= argc) {
|
if (source >= argc) {
|
||||||
reading = "standard input";
|
reading = "standard input";
|
||||||
fp = stdin;
|
fp = stdin;
|
||||||
} else {
|
} else {
|
||||||
reading = argv[layer];
|
reading = argv[source];
|
||||||
fp = fopen(argv[layer], "r");
|
fp = fopen(argv[source], "r");
|
||||||
if (fp == NULL) {
|
if (fp == NULL) {
|
||||||
perror(argv[layer]);
|
perror(argv[source]);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
jp = json_begin_file(fp);
|
jp = json_begin_file(fp);
|
||||||
|
|
||||||
|
int layer;
|
||||||
|
if (nlayers == 1) {
|
||||||
|
layer = 0;
|
||||||
|
} else {
|
||||||
|
layer = source;
|
||||||
|
}
|
||||||
|
|
||||||
parse_json(jp, reading, &seq, &metapos, &geompos, &indexpos, exclude, include, exclude_all, metafile, geomfile, indexfile, poolfile, treefile, fname, maxzoom, layer, droprate, file_bbox);
|
parse_json(jp, reading, &seq, &metapos, &geompos, &indexpos, exclude, include, exclude_all, metafile, geomfile, indexfile, poolfile, treefile, fname, maxzoom, layer, droprate, file_bbox);
|
||||||
|
|
||||||
json_end(jp);
|
json_end(jp);
|
||||||
@@ -867,7 +884,7 @@ int read_json(int argc, char **argv, char *fname, const char *layername, int max
|
|||||||
|
|
||||||
char *layernames[nlayers];
|
char *layernames[nlayers];
|
||||||
for (i = 0; i < nlayers; i++) {
|
for (i = 0; i < nlayers; i++) {
|
||||||
if (argc <= 1 && layername != NULL) {
|
if (layername != NULL) {
|
||||||
layernames[i] = strdup(layername);
|
layernames[i] = strdup(layername);
|
||||||
} else {
|
} else {
|
||||||
char *src = argv[i];
|
char *src = argv[i];
|
||||||
@@ -892,7 +909,6 @@ int read_json(int argc, char **argv, char *fname, const char *layername, int max
|
|||||||
if (cp != NULL) {
|
if (cp != NULL) {
|
||||||
*cp = '\0';
|
*cp = '\0';
|
||||||
}
|
}
|
||||||
layername = trunc;
|
|
||||||
|
|
||||||
char *out = trunc;
|
char *out = trunc;
|
||||||
for (cp = trunc; *cp; cp++) {
|
for (cp = trunc; *cp; cp++) {
|
||||||
@@ -1137,7 +1153,7 @@ int read_json(int argc, char **argv, char *fname, const char *layername, int max
|
|||||||
midlon = maxlon;
|
midlon = maxlon;
|
||||||
}
|
}
|
||||||
|
|
||||||
mbtiles_write_metadata(outdb, fname, layernames, minzoom, maxzoom, minlat, minlon, maxlat, maxlon, midlat, midlon, file_keys, nlayers); // XXX layers
|
mbtiles_write_metadata(outdb, fname, layernames, minzoom, maxzoom, minlat, minlon, maxlat, maxlon, midlat, midlon, file_keys, nlayers);
|
||||||
|
|
||||||
for (i = 0; i < nlayers; i++) {
|
for (i = 0; i < nlayers; i++) {
|
||||||
pool_free_strings(&file_keys1[i]);
|
pool_free_strings(&file_keys1[i]);
|
||||||
|
|||||||
+2
-1
@@ -54,7 +54,8 @@ it encounters.
|
|||||||
.SS Naming
|
.SS Naming
|
||||||
.RS
|
.RS
|
||||||
.IP \(bu 2
|
.IP \(bu 2
|
||||||
\-l \fIname\fP: Layer name (default "file" if source is file.json or output is file.mbtiles). Only works if there is only one layer.
|
\-l \fIname\fP: Layer name (default "file" if source is file.json or output is file.mbtiles). If there are multiple input files
|
||||||
|
specified, the files are all merged into the single named layer.
|
||||||
.IP \(bu 2
|
.IP \(bu 2
|
||||||
\-n \fIname\fP: Human\-readable name (default file.json)
|
\-n \fIname\fP: Human\-readable name (default file.json)
|
||||||
.RE
|
.RE
|
||||||
|
|||||||
Reference in New Issue
Block a user