Compare commits

...
Author SHA1 Message Date
Erica Fischer 20ca3140ac Test attribute joining in overzoom 2024-04-08 14:34:00 -07:00
Erica Fischer 1d48570e26 Most of the rest of joining JSON attributes onto features in overzoom 2024-04-08 14:01:17 -07:00
Erica Fischer 8876015bf7 Merge remote-tracking branch 'origin/main' into overzoom-join-attributes 2024-04-08 13:27:28 -07:00
Erica Fischer bb4f220678 Reduce tiling memory (#227)
* Trying to reduce memory in tiling

* Let the simplification workers go out of scope earlier

* Bail out quickly once the maximum feature count is reached

* Update changelog and version
2024-04-03 07:12:26 -07:00
Erica Fischer 2e0f099b7c Figuring out a little more 2024-03-26 16:59:02 -07:00
Erica Fischer 19b79d0d5c Scaffolding 2024-03-26 16:26:52 -07:00
Dane Springmeyer 266ef3c286 Add tippecanoe-overzoom to .gitignore (#224)
add tippecanoe-overzoom to .gitignore
2024-03-25 11:00:18 -07:00
Dane Springmeyer 1519b50791 Upgrade catch from v1.5.7 to v2.13.10 (#223)
upgrade catch from v1.5.7 to v2.13.10
2024-03-25 10:39:11 -07:00
21 changed files with 17039 additions and 9342 deletions
+1
View File
@@ -35,6 +35,7 @@ tile-join
tippecanoe-decode
tippecanoe-enumerate
tippecanoe-json-tool
tippecanoe-overzoom
unit
# Tests
+4
View File
@@ -1,3 +1,7 @@
# 2.53.0
* Stop trying to add features to the tile after the feature limit is reached
# 2.52.0
* Fix accidental loss (at all zooms) of features that specify an explicit minzoom
+8 -3
View File
@@ -67,7 +67,7 @@ tippecanoe-enumerate: enumerate.o
tippecanoe-decode: decode.o projection.o mvt.o write_json.o text.o jsonpull/jsonpull.o dirtiles.o pmtiles_file.o
$(CXX) $(PG) $(LIBS) $(FINAL_FLAGS) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) -lm -lz -lsqlite3
tile-join: tile-join.o projection.o mbtiles.o mvt.o memfile.o dirtiles.o jsonpull/jsonpull.o text.o evaluator.o csv.o write_json.o pmtiles_file.o clip.o attribute.o thread.o
tile-join: tile-join.o projection.o mbtiles.o mvt.o memfile.o dirtiles.o jsonpull/jsonpull.o text.o evaluator.o csv.o write_json.o pmtiles_file.o clip.o attribute.o thread.o read_json.o projection.o
$(CXX) $(PG) $(LIBS) $(FINAL_FLAGS) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) -lm -lz -lsqlite3 -lpthread
tippecanoe-json-tool: jsontool.o jsonpull/jsonpull.o csv.o text.o geojson-loop.o
@@ -76,8 +76,8 @@ tippecanoe-json-tool: jsontool.o jsonpull/jsonpull.o csv.o text.o geojson-loop.o
unit: unit.o text.o sort.o mvt.o
$(CXX) $(PG) $(LIBS) $(FINAL_FLAGS) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) -lm -lz -lsqlite3 -lpthread
tippecanoe-overzoom: overzoom.o mvt.o clip.o evaluator.o jsonpull/jsonpull.o text.o attribute.o
$(CXX) $(PG) $(LIBS) $(FINAL_FLAGS) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) -lm -lz -lsqlite3 -lpthread
tippecanoe-overzoom: overzoom.o mvt.o clip.o evaluator.o jsonpull/jsonpull.o text.o attribute.o read_json.o
$(CXX) $(PG) $(LIBS) $(FINAL_FLAGS) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) -lm -lz -lsqlite3 -lpthread projection.o
-include $(wildcard *.d)
@@ -345,6 +345,11 @@ overzoom-test: tippecanoe-overzoom
./tippecanoe-decode tests/pbf/12-2145-1391-filter2.pbf 12 2145 1391 > tests/pbf/12-2145-1391-filter2.pbf.json.check
cmp tests/pbf/12-2145-1391-filter2.pbf.json.check tests/pbf/12-2145-1391-filter2.pbf.json
rm tests/pbf/12-2145-1391-filter2.pbf.json.check tests/pbf/12-2145-1391-filter2.pbf
# Test joining attributes from JSON
./tippecanoe-overzoom -o tests/pbf/ne-110m-z3-0-0-0-joined.pbf --join-attributes-json tests/pbf/name-fr.json tests/pbf/ne-110m-z3-0-0-0.pbf 0/0/0 0/0/0
./tippecanoe-decode tests/pbf/ne-110m-z3-0-0-0-joined.pbf 0 0 0 > tests/pbf/ne-110m-z3-0-0-0-joined.pbf.json.check
cmp tests/pbf/ne-110m-z3-0-0-0-joined.pbf.json.check tests/pbf/ne-110m-z3-0-0-0-joined.pbf.json
rm tests/pbf/ne-110m-z3-0-0-0-joined.pbf.json.check tests/pbf/ne-110m-z3-0-0-0-joined.pbf
join-test: tippecanoe tippecanoe-decode tile-join
./tippecanoe -q -f -z12 -o tests/join-population/tabblock_06001420.mbtiles -YALAND10:'Land area' -L'{"file": "tests/join-population/tabblock_06001420.json", "description": "population"}'
+16245 -8793
View File
File diff suppressed because it is too large Load Diff
+72 -6
View File
@@ -10,6 +10,7 @@
#include "evaluator.hpp"
#include "serial.hpp"
#include "attribute.hpp"
#include "read_json.hpp"
static std::vector<std::pair<double, double>> clip_poly1(std::vector<std::pair<double, double>> &geom,
long long minx, long long miny, long long maxx, long long maxy,
@@ -758,7 +759,7 @@ static std::vector<std::pair<double, double>> clip_poly1(std::vector<std::pair<d
std::string overzoom(const std::string &s, int oz, int ox, int oy, int nz, int nx, int ny,
int detail, int buffer, std::set<std::string> const &keep, bool do_compress,
std::vector<std::pair<unsigned, unsigned>> *next_overzoomed_tiles,
bool demultiply, json_object *filter, bool preserve_input_order, std::unordered_map<std::string, attribute_op> const &attribute_accum, std::vector<std::string> const &unidecode_data) {
bool demultiply, json_object *filter, bool preserve_input_order, std::unordered_map<std::string, attribute_op> const &attribute_accum, std::vector<std::string> const &unidecode_data, json_object *join_attributes_json) {
mvt_tile tile;
try {
@@ -772,7 +773,7 @@ std::string overzoom(const std::string &s, int oz, int ox, int oy, int nz, int n
exit(EXIT_PROTOBUF);
}
return overzoom(tile, oz, ox, oy, nz, nx, ny, detail, buffer, keep, do_compress, next_overzoomed_tiles, demultiply, filter, preserve_input_order, attribute_accum, unidecode_data);
return overzoom(tile, oz, ox, oy, nz, nx, ny, detail, buffer, keep, do_compress, next_overzoomed_tiles, demultiply, filter, preserve_input_order, attribute_accum, unidecode_data, join_attributes_json);
}
struct tile_feature {
@@ -870,14 +871,75 @@ static struct preservecmp {
}
} preservecmp;
std::string overzoom(const mvt_tile &tile, int oz, int ox, int oy, int nz, int nx, int ny,
/* Format looks like:
{
"id": {
"1234": { "name": "Rome", "population", 567890 },
"15": { "name": "New York", "population": 32, "fictional": false }
}
}
IDs are really unsigned ints, not strings, but it feels like the keys
and values should be written as keys instead of in some other way.
Joined values win over original values, at least for the moment.
*/
void join_by_id(mvt_layer &layer, mvt_feature &feature, const json_object *j, std::shared_ptr<std::string> tile_stringpool) {
if (!feature.has_id) {
return;
}
if (j->type != JSON_HASH) {
fprintf(stderr, "list of attributes to be joined to features is not a json object\n");
exit(EXIT_JSON);
}
for (size_t i = 0; i < j->value.object.length; i++) {
const json_object *key = j->value.object.keys[i];
if (key->type == JSON_STRING) {
unsigned long long feature_id = atoll(j->value.object.keys[i]->value.string.string);
if (feature_id == feature.id) {
const json_object *value = j->value.object.values[i];
if (value->type == JSON_HASH) {
for (size_t a = 0; a < value->value.object.length; a++) {
json_object *k = value->value.object.keys[a];
json_object *v = value->value.object.values[a];
if (k->type != JSON_STRING) {
fprintf(stderr, "Expected string for key in json join, not %s\n", json_stringify(k));
exit(EXIT_JSON);
}
serial_val sv = stringify_value(v, "joined json", 1, value);
mvt_value mv = stringified_to_mvt_value(sv.type, sv.s.c_str(), tile_stringpool);
layer.tag(feature, k->value.string.string, mv);
}
} else {
fprintf(stderr, "Expected attribute object for value in json join, not %s\n", json_stringify(value));
exit(EXIT_JSON);
}
break;
}
} else {
fprintf(stderr, "Expected string for key in json join, not %s\n", json_stringify(key));
exit(EXIT_JSON);
}
}
}
std::string overzoom(mvt_tile tile, int oz, int ox, int oy, int nz, int nx, int ny,
int detail, int buffer, std::set<std::string> const &keep, bool do_compress,
std::vector<std::pair<unsigned, unsigned>> *next_overzoomed_tiles,
bool demultiply, json_object *filter, bool preserve_input_order, std::unordered_map<std::string, attribute_op> const &attribute_accum, std::vector<std::string> const &unidecode_data) {
bool demultiply, json_object *filter, bool preserve_input_order, std::unordered_map<std::string, attribute_op> const &attribute_accum, std::vector<std::string> const &unidecode_data, json_object *join_attributes_json) {
mvt_tile outtile;
std::shared_ptr<std::string> tile_stringpool = std::make_shared<std::string>();
for (auto const &layer : tile.layers) {
for (auto &layer : tile.layers) {
mvt_layer outlayer = mvt_layer();
int det = detail;
@@ -895,6 +957,10 @@ std::string overzoom(const mvt_tile &tile, int oz, int ox, int oy, int nz, int n
static const std::string retain_points_multiplier_sequence = "tippecanoe:retain_points_multiplier_sequence";
for (auto feature : layer.features) {
if (join_attributes_json != NULL) {
join_by_id(layer, feature, join_attributes_json, tile_stringpool);
}
bool flush_multiplier_cluster = false;
if (demultiply) {
for (ssize_t i = feature.tags.size() - 2; i >= 0; i -= 2) {
@@ -1046,7 +1112,7 @@ std::string overzoom(const mvt_tile &tile, int oz, int ox, int oy, int nz, int n
std::string child = overzoom(outtile, nz, nx, ny,
nz + 1, nx * 2 + x, ny * 2 + y,
detail, buffer, keep, false, NULL,
demultiply, filter, preserve_input_order, attribute_accum, unidecode_data);
demultiply, filter, preserve_input_order, attribute_accum, unidecode_data, join_attributes_json);
if (child.size() > 0) {
next_overzoomed_tiles->emplace_back(nx * 2 + x, ny * 2 + y);
}
+5 -3
View File
@@ -100,18 +100,20 @@ void visvalingam(drawvec &ls, size_t start, size_t end, double threshold, size_t
int pnpoly(const drawvec &vert, size_t start, size_t nvert, long long testx, long long testy);
double distance_from_line(long long point_x, long long point_y, long long segA_x, long long segA_y, long long segB_x, long long segB_y);
std::string overzoom(const mvt_tile &tile, int oz, int ox, int oy, int nz, int nx, int ny,
std::string overzoom(mvt_tile tile, int oz, int ox, int oy, int nz, int nx, int ny,
int detail, int buffer, std::set<std::string> const &keep, bool do_compress,
std::vector<std::pair<unsigned, unsigned>> *next_overzoomed_tiles,
bool demultiply, json_object *filter, bool preserve_input_order,
std::unordered_map<std::string, attribute_op> const &attribute_accum,
std::vector<std::string> const &unidecode_data);
std::vector<std::string> const &unidecode_data,
json_object *join_attributes_json);
std::string overzoom(const std::string &s, int oz, int ox, int oy, int nz, int nx, int ny,
int detail, int buffer, std::set<std::string> const &keep, bool do_compress,
std::vector<std::pair<unsigned, unsigned>> *next_overzoomed_tiles,
bool demultiply, json_object *filter, bool preserve_input_order,
std::unordered_map<std::string, attribute_op> const &attribute_accum,
std::vector<std::string> const &unidecode_data);
std::vector<std::string> const &unidecode_data,
json_object *join_attributes_json);
#endif
+3 -3
View File
@@ -905,7 +905,7 @@ void json_disconnect(json_object *o) {
o->parent = NULL;
}
static void json_print_one(struct string *val, json_object *o) {
static void json_print_one(struct string *val, const json_object *o) {
if (o == NULL) {
string_append_string(val, "...");
} else if (o->type == JSON_STRING) {
@@ -955,7 +955,7 @@ static void json_print_one(struct string *val, json_object *o) {
}
}
static void json_print(struct string *val, json_object *o) {
static void json_print(struct string *val, const json_object *o) {
if (o == NULL) {
// Hash value in incompletely read hash
string_append_string(val, "...");
@@ -987,7 +987,7 @@ static void json_print(struct string *val, json_object *o) {
}
}
char *json_stringify(json_object *o) {
char *json_stringify(const json_object *o) {
struct string val;
string_init(&val);
json_print(&val, o);
+1 -1
View File
@@ -89,7 +89,7 @@ void json_disconnect(json_object *j);
json_object *json_hash_get(json_object *o, const char *s);
char *json_stringify(json_object *o);
char *json_stringify(const json_object *o);
#ifdef __cplusplus
}
+7 -1
View File
@@ -20,6 +20,7 @@ std::string filter;
bool preserve_input_order = false;
std::unordered_map<std::string, attribute_op> attribute_accum;
std::vector<std::string> unidecode_data;
json_object *join_attributes_json = NULL;
std::set<std::string> keep;
@@ -43,6 +44,7 @@ int main(int argc, char **argv) {
{"preserve-input-order", no_argument, 0, 'o' & 0x1F},
{"accumulate-attribute", required_argument, 0, 'E'},
{"unidecode-data", required_argument, 0, 'u' & 0x1F},
{"join-attributes-json", required_argument, 0, 'c' & 0x1F},
{0, 0, 0, 0},
};
@@ -97,6 +99,10 @@ int main(int argc, char **argv) {
unidecode_data = read_unidecode(optarg);
break;
case 'c' & 0x1F:
join_attributes_json = read_filter(optarg);
break;
default:
fprintf(stderr, "Unrecognized flag -%c\n", i);
usage(argv);
@@ -151,7 +157,7 @@ int main(int argc, char **argv) {
json_filter = parse_filter(filter.c_str());
}
std::string out = overzoom(tile, oz, ox, oy, nz, nx, ny, detail, buffer, keep, true, NULL, demultiply, json_filter, preserve_input_order, attribute_accum, unidecode_data);
std::string out = overzoom(tile, oz, ox, oy, nz, nx, ny, detail, buffer, keep, true, NULL, demultiply, json_filter, preserve_input_order, attribute_accum, unidecode_data, join_attributes_json);
fwrite(out.c_str(), sizeof(char), out.size(), f);
fclose(f);
+2 -2
View File
@@ -42,7 +42,7 @@ int mb_geometry[GEOM_TYPES] = {
VT_POLYGON,
};
void json_context(json_object *j) {
void json_context(const json_object *j) {
char *s = json_stringify(j);
if (strlen(s) >= 500) {
@@ -121,7 +121,7 @@ void parse_geometry(int t, json_object *j, drawvec &out, int op, const char *fna
// type and stringified value. All numeric values, even if they are integers,
// even integers that are too large to fit in a double but will still be
// stringified with their original precision, are recorded here as mvt_double.
serial_val stringify_value(json_object *value, const char *reading, int line, json_object *feature) {
serial_val stringify_value(json_object const *value, char const *reading, int line, json_object const *feature) {
serial_val sv;
if (value != NULL) {
+2 -3
View File
@@ -10,7 +10,6 @@ extern const char *geometry_names[GEOM_TYPES];
extern int geometry_within[GEOM_TYPES];
extern int mb_geometry[GEOM_TYPES];
void json_context(json_object *j);
void json_context(const json_object *j);
void parse_geometry(int t, json_object *j, drawvec &out, int op, const char *fname, int line, json_object *feature);
serial_val stringify_value(json_object *value, const char *reading, int line, json_object *feature);
serial_val stringify_value(json_object const *, char const *, int, json_object const *);
@@ -9,7 +9,7 @@
"maxzoom": "0",
"minzoom": "0",
"name": "tests/loop/out/-z0_-O200_--cluster-densest-as-needed.json.check.mbtiles",
"strategies": "[{\"coalesced_as_needed\":999,\"feature_count_desired\":1000}]",
"strategies": "[{\"coalesced_as_needed\":999,\"feature_count_desired\":201}]",
"type": "overlay",
"version": "2"
}, "features": [
@@ -9,7 +9,7 @@
"maxzoom": "0",
"minzoom": "0",
"name": "tests/loop/out/-z0_-O200_--drop-densest-as-needed.json.check.mbtiles",
"strategies": "[{\"dropped_as_needed\":999,\"feature_count_desired\":1000}]",
"strategies": "[{\"dropped_as_needed\":999,\"feature_count_desired\":201}]",
"type": "overlay",
"version": "2"
}, "features": [
@@ -9,7 +9,7 @@
"maxzoom": "0",
"minzoom": "0",
"name": "tests/loop/out/-z0_-O200_--drop-fraction-as-needed.json.check.mbtiles",
"strategies": "[{\"dropped_as_needed\":999,\"feature_count_desired\":1000}]",
"strategies": "[{\"dropped_as_needed\":999,\"feature_count_desired\":201}]",
"type": "overlay",
"version": "2"
}, "features": [
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,35 @@
{ "type": "FeatureCollection", "properties": { "zoom": 0, "x": 0, "y": 0 }, "features": [
{ "type": "FeatureCollection", "properties": { "layer": "11", "version": 2, "extent": 4096 }, "features": [
{ "type": "Feature", "id": 6173331, "properties": { "NAME": "Vancouver", "NAME_FR": "Vancouver", "SCALERANK": 1, "NAME_RU": "Ванкувер" }, "geometry": { "type": "Point", "coordinates": [ -123.134766, 49.267805 ] } }
,
{ "type": "Feature", "id": 1690681, "properties": { "NAME": "San Salvador", "NAME_FR": "San Salvador", "SCALERANK": 3, "NAME_RU": "Сан-Сальвадор" }, "geometry": { "type": "Point", "coordinates": [ -89.208984, 13.667338 ] } }
,
{ "type": "Feature", "id": 3579925, "properties": { "NAME": "Saint George's", "NAME_FR": "Saint-Georges", "SCALERANK": 4, "NAME_RU": "Сент-Джорджес" }, "geometry": { "type": "Point", "coordinates": [ -61.699219, 12.039321 ] } }
,
{ "type": "Feature", "id": 2422465, "properties": { "NAME": "Conakry", "NAME_FR": "Conakry", "SCALERANK": 3, "NAME_RU": "Конакри" }, "geometry": { "type": "Point", "coordinates": [ -13.710938, 9.535749 ] } }
,
{ "type": "Feature", "id": 3652462, "properties": { "NAME": "Quito", "NAME_FR": "Quito", "SCALERANK": 3, "NAME_RU": "Кито" }, "geometry": { "type": "Point", "coordinates": [ -78.486328, -0.175781 ] } }
,
{ "type": "Feature", "id": 2660646, "properties": { "NAME": "Geneva", "NAME_FR": "Genève", "SCALERANK": 1, "NAME_RU": "Женева" }, "geometry": { "type": "Point", "coordinates": [ 6.152344, 46.195042 ] } }
,
{ "type": "Feature", "id": 6691831, "properties": { "NAME": "Vatican City", "NAME_FR": "Cité du Vatican", "SCALERANK": 8, "NAME_RU": "Ватикан" }, "geometry": { "type": "Point", "coordinates": [ 12.480469, 41.902277 ] } }
,
{ "type": "Feature", "id": 618426, "properties": { "NAME": "Chișinău", "NAME_FR": "Chișinău", "SCALERANK": 3, "NAME_RU": "Кишинёв" }, "geometry": { "type": "Point", "coordinates": [ 28.828125, 46.980252 ] } }
,
{ "type": "Feature", "id": 2309527, "properties": { "NAME": "Malabo", "NAME_FR": "Malabo", "SCALERANK": 3, "NAME_RU": "Малабо" }, "geometry": { "type": "Point", "coordinates": [ 8.789062, 3.776559 ] } }
,
{ "type": "Feature", "id": 373303, "properties": { "NAME": "Juba", "NAME_FR": "Djouba", "SCALERANK": 4, "NAME_RU": "Джуба" }, "geometry": { "type": "Point", "coordinates": [ 31.552734, 4.828260 ] } }
,
{ "type": "Feature", "id": 285787, "properties": { "NAME": "Kuwait City", "NAME_FR": "Koweït", "SCALERANK": 2, "NAME_RU": "Эль-Кувейт" }, "geometry": { "type": "Point", "coordinates": [ 47.988281, 29.382175 ] } }
,
{ "type": "Feature", "id": 1238992, "properties": { "NAME": "Sri Jayawardenepura Kotte", "NAME_FR": "Sri Jayawardenapura", "SCALERANK": 4, "NAME_RU": "Шри-Джаяварденепура-Котте" }, "geometry": { "type": "Point", "coordinates": [ 79.980469, 6.926427 ] } }
,
{ "type": "Feature", "id": 1735161, "properties": { "NAME": "Kuala Lumpur", "NAME_FR": "Kuala Lumpur", "SCALERANK": 2, "NAME_RU": "Куала-Лумпур" }, "geometry": { "type": "Point", "coordinates": [ 101.689453, 3.162456 ] } }
,
{ "type": "Feature", "id": 2314302, "properties": { "NAME": "Kinshasa", "NAME_FR": "Kinshasa", "SCALERANK": 1, "NAME_RU": "Киншаса" }, "geometry": { "type": "Point", "coordinates": [ 15.292969, -4.302591 ] } }
,
{ "type": "Feature", "id": 921772, "properties": { "NAME": "Moroni", "NAME_FR": "Moroni", "SCALERANK": 6, "NAME_RU": "Морони" }, "geometry": { "type": "Point", "coordinates": [ 43.242188, -11.695273 ] } }
,
{ "type": "Feature", "id": 2108502, "properties": { "NAME": "Honiara", "NAME_FR": "Honiara", "SCALERANK": 3, "NAME_RU": "Хониара" }, "geometry": { "type": "Point", "coordinates": [ 159.960938, -9.449062 ] } }
] }
] }
Binary file not shown.
+1 -1
View File
@@ -704,7 +704,7 @@ struct tileset_reader {
}
if (source.layers.size() != 0) {
std::string ret = overzoom(source, parent_tile.z, parent_tile.x, parent_tile.y, tile.z, tile.x, tile.y, -1, buffer, std::set<std::string>(), false, &next_overzoomed_tiles, false, NULL, false, std::unordered_map<std::string, attribute_op>(), unidecode_data);
std::string ret = overzoom(source, parent_tile.z, parent_tile.x, parent_tile.y, tile.z, tile.x, tile.y, -1, buffer, std::set<std::string>(), false, &next_overzoomed_tiles, false, NULL, false, std::unordered_map<std::string, attribute_op>(), unidecode_data, NULL /* XXX join_attributes_json */);
return ret;
}
+29 -25
View File
@@ -1875,7 +1875,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
unsigned long long sfindex = sf.index;
if (sf.geometry.size() > 0) {
if (lead_features_count > max_tile_size) {
if (lead_features_count > max_tile_size || (lead_features_count + other_multiplier_cluster_features_count > max_tile_features && !prevent[P_FEATURE_LIMIT])) {
// Even being maximally conservative, each feature is still going to be
// at least one byte in the output tile, so this can't possibly work.
skipped++;
@@ -2110,33 +2110,35 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
tasks = 1;
}
pthread_t pthreads[tasks];
std::vector<simplification_worker_arg> args;
args.resize(tasks);
for (int i = 0; i < tasks; i++) {
args[i].task = i;
args[i].tasks = tasks;
args[i].features = &features;
args[i].shared_nodes = &shared_nodes;
args[i].shared_nodes_map = shared_nodes_map;
args[i].nodepos = nodepos;
{
pthread_t pthreads[tasks];
std::vector<simplification_worker_arg> args;
args.resize(tasks);
for (int i = 0; i < tasks; i++) {
args[i].task = i;
args[i].tasks = tasks;
args[i].features = &features;
args[i].shared_nodes = &shared_nodes;
args[i].shared_nodes_map = shared_nodes_map;
args[i].nodepos = nodepos;
if (tasks > 1) {
if (thread_create(&pthreads[i], NULL, simplification_worker, &args[i]) != 0) {
perror("pthread_create");
exit(EXIT_PTHREAD);
}
} else {
simplification_worker(&args[i]);
}
}
if (tasks > 1) {
if (thread_create(&pthreads[i], NULL, simplification_worker, &args[i]) != 0) {
perror("pthread_create");
exit(EXIT_PTHREAD);
}
} else {
simplification_worker(&args[i]);
}
}
for (int i = 0; i < tasks; i++) {
void *retval;
if (tasks > 1) {
for (int i = 0; i < tasks; i++) {
void *retval;
if (pthread_join(pthreads[i], &retval) != 0) {
perror("pthread_join");
if (pthread_join(pthreads[i], &retval) != 0) {
perror("pthread_join");
}
}
}
}
@@ -2261,6 +2263,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
}
if (layer_features[x].geometry.size() == 0) {
layer_features[x] = serial_feature();
continue;
}
@@ -2301,6 +2304,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
}
layer.features.push_back(std::move(feature));
layer_features[x] = serial_feature();
}
if (layer.features.size() > 0) {
+1 -1
View File
@@ -1,6 +1,6 @@
#ifndef VERSION_HPP
#define VERSION_HPP
#define VERSION "v2.52.0"
#define VERSION "v2.53.0"
#endif