mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-02 08:25:40 +02:00
Avoid more potentially slow calls to wagyu with large geometries
This commit is contained in:
@@ -2558,11 +2558,11 @@ drawvec coalesce_linestring(drawvec const &geom) {
|
||||
return out;
|
||||
}
|
||||
|
||||
drawvec coalesce_polygon(drawvec const &geom) {
|
||||
drawvec coalesce_polygon(drawvec const &geom, bool scale_up) {
|
||||
// wagyu should be able to straightforwardly handle
|
||||
// anything under a few hundred thousand vertices
|
||||
if (geom.size() < 100000) {
|
||||
return clean_or_clip_poly(geom, 0, 0, false, false);
|
||||
return clean_or_clip_poly(geom, 0, 0, false, scale_up);
|
||||
}
|
||||
|
||||
// These geometries were assembled in geometric order,
|
||||
@@ -2589,14 +2589,14 @@ drawvec coalesce_polygon(drawvec const &geom) {
|
||||
for (size_t k = 0; k < i; k++) {
|
||||
geom1[k] = geom[k];
|
||||
}
|
||||
geom1 = coalesce_polygon(geom1);
|
||||
geom1 = coalesce_polygon(geom1, scale_up);
|
||||
|
||||
std::vector<draw> geom2;
|
||||
geom2.resize(geom.size() - i);
|
||||
for (size_t k = i; k < geom.size(); k++) {
|
||||
geom2[k - i] = geom[k];
|
||||
}
|
||||
geom2 = coalesce_polygon(geom2);
|
||||
geom2 = coalesce_polygon(geom2, scale_up);
|
||||
|
||||
size_t brk = geom1.size();
|
||||
geom1.resize(brk + geom2.size());
|
||||
@@ -2604,6 +2604,7 @@ drawvec coalesce_polygon(drawvec const &geom) {
|
||||
geom1[brk + k] = geom2[k];
|
||||
}
|
||||
|
||||
geom2.clear();
|
||||
return clean_or_clip_poly(geom1, 0, 0, false, false);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -173,7 +173,7 @@ void get_quadkey_bounds(long long xmin, long long ymin, long long xmax, long lon
|
||||
|
||||
clipbbox parse_clip_poly(std::string arg);
|
||||
bool line_is_too_small(drawvec const &geometry, int z, int detail);
|
||||
drawvec coalesce_polygon(drawvec const &geom);
|
||||
drawvec coalesce_polygon(drawvec const &geom, bool scale_up);
|
||||
drawvec coalesce_linestring(drawvec const &geom);
|
||||
|
||||
#endif
|
||||
|
||||
File diff suppressed because one or more lines are too long
+1
-1
@@ -136,7 +136,7 @@
|
||||
,
|
||||
{ "type": "FeatureCollection", "properties": { "zoom": 11, "x": 331, "y": 793 }, "features": [
|
||||
{ "type": "FeatureCollection", "properties": { "layer": "merged", "version": 2, "extent": 4096 }, "features": [
|
||||
{ "type": "Feature", "properties": { "STATEFP10": "06", "COUNTYFP10": "001" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -121.731477, 37.582133 ], [ -121.637192, 37.582133 ], [ -121.637192, 37.482725 ], [ -121.640625, 37.482759 ], [ -121.655903, 37.482827 ], [ -121.661739, 37.482827 ], [ -121.670408, 37.482725 ], [ -121.690149, 37.482827 ], [ -121.714954, 37.483645 ], [ -121.741176, 37.483951 ], [ -121.765466, 37.484019 ], [ -121.786280, 37.484224 ], [ -121.786366, 37.484326 ], [ -121.795421, 37.483985 ], [ -121.800742, 37.483985 ], [ -121.816406, 37.484155 ], [ -121.819839, 37.484190 ], [ -121.819839, 37.582133 ], [ -121.731477, 37.582133 ] ], [ [ -121.671138, 37.483611 ], [ -121.670537, 37.482930 ], [ -121.670580, 37.483032 ], [ -121.671138, 37.483611 ] ] ] } }
|
||||
{ "type": "Feature", "properties": { "STATEFP10": "06", "COUNTYFP10": "001" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -121.731477, 37.582133 ], [ -121.637192, 37.582133 ], [ -121.637192, 37.482725 ], [ -121.640625, 37.482759 ], [ -121.655903, 37.482827 ], [ -121.661739, 37.482827 ], [ -121.670408, 37.482725 ], [ -121.690149, 37.482827 ], [ -121.714954, 37.483645 ], [ -121.741176, 37.483951 ], [ -121.765466, 37.484019 ], [ -121.786280, 37.484224 ], [ -121.786366, 37.484326 ], [ -121.795421, 37.483985 ], [ -121.800742, 37.483985 ], [ -121.816406, 37.484155 ], [ -121.819839, 37.484190 ], [ -121.819839, 37.582133 ], [ -121.731477, 37.582133 ] ], [ [ -121.671138, 37.483611 ], [ -121.670537, 37.482930 ], [ -121.670408, 37.482725 ], [ -121.670580, 37.483032 ], [ -121.671138, 37.483611 ] ] ] } }
|
||||
] }
|
||||
] }
|
||||
,
|
||||
|
||||
@@ -638,7 +638,8 @@ static double simplify_feature(serial_feature *p, drawvec const &shared_nodes, n
|
||||
// introducing shards between shapes that otherwise would have
|
||||
// unioned exactly.
|
||||
if (t == VT_POLYGON) {
|
||||
geom = coalesce_polygon(geom);
|
||||
// don't scale up since this is still world coordinates
|
||||
geom = coalesce_polygon(geom, false);
|
||||
} else if (t == VT_LINE) {
|
||||
geom = coalesce_linestring(geom);
|
||||
}
|
||||
@@ -700,8 +701,8 @@ static void *simplification_worker(void *v) {
|
||||
drawvec before = geom;
|
||||
|
||||
if (!a->trying_to_stop_early) {
|
||||
// we can try scaling up because this is now tile scale
|
||||
geom = clean_or_clip_poly(geom, 0, 0, false, true);
|
||||
// scale up since this is now tile coordinates
|
||||
geom = coalesce_polygon(geom, true);
|
||||
if (additional[A_DEBUG_POLYGON]) {
|
||||
check_polygon(geom);
|
||||
}
|
||||
@@ -2218,15 +2219,17 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
// may not be very effective for reducing memory usage.
|
||||
|
||||
for (; simplified_geometry_through < features.size(); simplified_geometry_through++) {
|
||||
simplify_feature(&*features[simplified_geometry_through], shared_nodes, shared_nodes_map, nodepos, shared_nodes_bloom);
|
||||
|
||||
if (features[simplified_geometry_through]->t == VT_POLYGON) {
|
||||
drawvec to_clean = features[simplified_geometry_through]->geometry;
|
||||
|
||||
// don't scale up because this is still world coordinates
|
||||
to_clean = clean_or_clip_poly(to_clean, 0, 0, false, false);
|
||||
features[simplified_geometry_through]->geometry = std::move(to_clean);
|
||||
if (features[simplified_geometry_through]->coalesced) {
|
||||
if (features[simplified_geometry_through]->t == VT_POLYGON) {
|
||||
// don't scale up since this is still world coordinates
|
||||
// hopefully wagyu won't break the shared nodes
|
||||
features[simplified_geometry_through]->geometry = coalesce_polygon(features[simplified_geometry_through]->geometry, false);
|
||||
} else if (features[simplified_geometry_through]->t == VT_LINE) {
|
||||
features[simplified_geometry_through]->geometry = coalesce_linestring(features[simplified_geometry_through]->geometry);
|
||||
}
|
||||
}
|
||||
|
||||
simplify_feature(&*features[simplified_geometry_through], shared_nodes, shared_nodes_map, nodepos, shared_nodes_bloom);
|
||||
}
|
||||
|
||||
unsimplified_geometry_size = 0;
|
||||
@@ -2492,7 +2495,8 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
|
||||
if (layer_features[x]->t == VT_POLYGON) {
|
||||
if (layer_features[x]->coalesced) {
|
||||
layer_features[x]->geometry = coalesce_polygon(layer_features[x]->geometry);
|
||||
// scale up since this is now tile coordinates
|
||||
layer_features[x]->geometry = coalesce_polygon(layer_features[x]->geometry, true);
|
||||
}
|
||||
|
||||
layer_features[x]->geometry = close_poly(layer_features[x]->geometry);
|
||||
|
||||
Reference in New Issue
Block a user