mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-02 16:35:40 +02:00
Merge remote-tracking branch 'origin/main' into clean-polygons
This commit is contained in:
+32
-41
@@ -26,6 +26,7 @@
|
||||
#include "serial.hpp"
|
||||
#include "errors.hpp"
|
||||
#include "polygon.hpp"
|
||||
#include "thread.hpp"
|
||||
|
||||
extern "C" {
|
||||
#include "jsonpull/jsonpull.h"
|
||||
@@ -88,6 +89,7 @@ static std::vector<mvt_geometry> to_feature(drawvec &geom) {
|
||||
// Reads from the postfilter
|
||||
std::vector<mvt_layer> parse_layers(int fd, int z, unsigned x, unsigned y, std::vector<std::map<std::string, layermap_entry>> *layermaps, size_t tiling_seg, std::vector<std::vector<std::string>> *layer_unmaps, int extent) {
|
||||
std::map<std::string, mvt_layer> ret;
|
||||
std::shared_ptr<std::string> tile_stringpool = std::make_shared<std::string>();
|
||||
|
||||
FILE *f = fdopen(fd, "r");
|
||||
if (f == NULL) {
|
||||
@@ -248,44 +250,37 @@ std::vector<mvt_layer> parse_layers(int fd, int z, unsigned x, unsigned y, std::
|
||||
}
|
||||
}
|
||||
|
||||
auto fk = layermap.find(layername);
|
||||
if (fk == layermap.end()) {
|
||||
auto ts = layermap.find(layername);
|
||||
if (ts == layermap.end()) {
|
||||
fprintf(stderr, "Internal error: layer %s not found\n", layername.c_str());
|
||||
exit(EXIT_IMPOSSIBLE);
|
||||
}
|
||||
if (z < fk->second.minzoom) {
|
||||
fk->second.minzoom = z;
|
||||
if (z < ts->second.minzoom) {
|
||||
ts->second.minzoom = z;
|
||||
}
|
||||
if (z > fk->second.maxzoom) {
|
||||
fk->second.maxzoom = z;
|
||||
if (z > ts->second.maxzoom) {
|
||||
ts->second.maxzoom = z;
|
||||
}
|
||||
|
||||
if (feature.type == mvt_point) {
|
||||
fk->second.points++;
|
||||
ts->second.points++;
|
||||
} else if (feature.type == mvt_linestring) {
|
||||
fk->second.lines++;
|
||||
ts->second.lines++;
|
||||
} else if (feature.type == mvt_polygon) {
|
||||
fk->second.polygons++;
|
||||
ts->second.polygons++;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < properties->value.object.length; i++) {
|
||||
int tp = -1;
|
||||
std::string s;
|
||||
|
||||
stringify_value(properties->value.object.values[i], tp, s, "Filter output", jp->line, j);
|
||||
serial_val sv = stringify_value(properties->value.object.values[i], "Filter output", jp->line, j);
|
||||
|
||||
// Nulls can be excluded here because this is the postfilter
|
||||
// and it is nearly time to create the vector representation
|
||||
|
||||
if (tp >= 0 && tp != mvt_null) {
|
||||
mvt_value v = stringified_to_mvt_value(tp, s.c_str());
|
||||
if (sv.type != mvt_null) {
|
||||
mvt_value v = stringified_to_mvt_value(sv.type, sv.s.c_str(), tile_stringpool);
|
||||
l->second.tag(feature, std::string(properties->value.object.keys[i]->value.string.string), v);
|
||||
|
||||
type_and_string attrib;
|
||||
attrib.type = tp;
|
||||
attrib.string = s;
|
||||
|
||||
add_to_file_keys(fk->second.file_keys, std::string(properties->value.object.keys[i]->value.string.string), attrib);
|
||||
add_to_tilestats(ts->second.tilestats, std::string(properties->value.object.keys[i]->value.string.string), sv);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -440,7 +435,9 @@ serial_feature parse_feature(json_pull *jp, int z, unsigned x, unsigned y, std::
|
||||
|
||||
json_object *dropped = json_hash_get(tippecanoe, "dropped");
|
||||
if (dropped != NULL && dropped->type == JSON_TRUE) {
|
||||
sf.dropped = true;
|
||||
sf.dropped = FEATURE_DROPPED; // dropped
|
||||
} else {
|
||||
sf.dropped = FEATURE_KEPT; // kept
|
||||
}
|
||||
}
|
||||
|
||||
@@ -485,49 +482,42 @@ serial_feature parse_feature(json_pull *jp, int z, unsigned x, unsigned y, std::
|
||||
}
|
||||
}
|
||||
|
||||
auto fk = layermap.find(layername);
|
||||
if (fk == layermap.end()) {
|
||||
auto ts = layermap.find(layername);
|
||||
if (ts == layermap.end()) {
|
||||
fprintf(stderr, "Internal error: layer %s not found\n", layername.c_str());
|
||||
exit(EXIT_IMPOSSIBLE);
|
||||
}
|
||||
sf.layer = fk->second.id;
|
||||
sf.layer = ts->second.id;
|
||||
|
||||
if (z < fk->second.minzoom) {
|
||||
fk->second.minzoom = z;
|
||||
if (z < ts->second.minzoom) {
|
||||
ts->second.minzoom = z;
|
||||
}
|
||||
if (z > fk->second.maxzoom) {
|
||||
fk->second.maxzoom = z;
|
||||
if (z > ts->second.maxzoom) {
|
||||
ts->second.maxzoom = z;
|
||||
}
|
||||
|
||||
if (!postfilter) {
|
||||
if (sf.t == mvt_point) {
|
||||
fk->second.points++;
|
||||
ts->second.points++;
|
||||
} else if (sf.t == mvt_linestring) {
|
||||
fk->second.lines++;
|
||||
ts->second.lines++;
|
||||
} else if (sf.t == mvt_polygon) {
|
||||
fk->second.polygons++;
|
||||
ts->second.polygons++;
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < properties->value.object.length; i++) {
|
||||
serial_val v;
|
||||
v.type = -1;
|
||||
|
||||
stringify_value(properties->value.object.values[i], v.type, v.s, "Filter output", jp->line, j);
|
||||
serial_val v = stringify_value(properties->value.object.values[i], "Filter output", jp->line, j);
|
||||
|
||||
// Nulls can be excluded here because the expression evaluation filter
|
||||
// would have already run before prefiltering
|
||||
|
||||
if (v.type >= 0 && v.type != mvt_null) {
|
||||
if (v.type != mvt_null) {
|
||||
sf.full_keys.push_back(std::string(properties->value.object.keys[i]->value.string.string));
|
||||
sf.full_values.push_back(v);
|
||||
|
||||
type_and_string attrib;
|
||||
attrib.string = v.s;
|
||||
attrib.type = v.type;
|
||||
|
||||
if (!postfilter) {
|
||||
add_to_file_keys(fk->second.file_keys, std::string(properties->value.object.keys[i]->value.string.string), attrib);
|
||||
add_to_tilestats(ts->second.tilestats, std::string(properties->value.object.keys[i]->value.string.string), v);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -650,6 +640,7 @@ std::vector<mvt_layer> filter_layers(const char *filter, std::vector<mvt_layer>
|
||||
wa.extent = extent;
|
||||
|
||||
pthread_t writer;
|
||||
// this does need to be a real thread, so we can pipe both to and from it
|
||||
if (pthread_create(&writer, NULL, run_writer, &wa) != 0) {
|
||||
perror("pthread_create (filter writer)");
|
||||
exit(EXIT_PTHREAD);
|
||||
|
||||
Reference in New Issue
Block a user