mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-02 08:25:40 +02:00
Externalizing polygon shard detection (#146)
* Start of externalizing polygon shard detection * Completely untested external quicksort * Add unit test for external quicksort * Remember to clean up temporary files * Sort and scan the vertices * Bring over more vertex logic * Make nodes from vertices * Checkpoint on switching over to global shared nodes * Do the thing * Revert unintended change to coalesced linestring behavior * Take shared nodes into account in early simplification * Let it do more sorting in memory * Fix overnoding of collinear linestrings * Remove duplicate nodes, since only duplicate vertices now matter * Remember to delete temporary files * Fix out of bounds memory access below, apparently * Fix the actual undefined behavior * Still running out of memory in one case. Find out where. * Forgot the conditional * Try again to make it not run out of memory * Update version and changelog
This commit is contained in:
+29
-1
@@ -485,7 +485,7 @@ drawvec impose_tile_boundaries(drawvec &geom, long long extent) {
|
||||
return out;
|
||||
}
|
||||
|
||||
drawvec simplify_lines(drawvec &geom, int z, int detail, bool mark_tile_bounds, double simplification, size_t retain, drawvec const &shared_nodes) {
|
||||
drawvec simplify_lines(drawvec &geom, int z, int tx, int ty, int detail, bool mark_tile_bounds, double simplification, size_t retain, drawvec const &shared_nodes, struct node *shared_nodes_map, size_t nodepos) {
|
||||
int res = 1 << (32 - detail - z);
|
||||
long long area = 1LL << (32 - z);
|
||||
|
||||
@@ -501,10 +501,35 @@ drawvec simplify_lines(drawvec &geom, int z, int detail, bool mark_tile_bounds,
|
||||
}
|
||||
|
||||
if (prevent[P_SIMPLIFY_SHARED_NODES]) {
|
||||
// This is kind of weird, because we have two lists of shared nodes to look through:
|
||||
// * the drawvec, which is nodes that were introduced during clipping to the tile edge,
|
||||
// and which are in local tile coordinates
|
||||
// * the shared_nodes_map, which was made globally before tiling began, and which
|
||||
// is in global quadkey coordinates.
|
||||
// To look through the latter, we need to offset and encode the coordinates
|
||||
// of the feature we are simplifying.
|
||||
|
||||
auto pt = std::lower_bound(shared_nodes.begin(), shared_nodes.end(), geom[i]);
|
||||
if (pt != shared_nodes.end() && *pt == geom[i]) {
|
||||
geom[i].necessary = true;
|
||||
}
|
||||
|
||||
if (nodepos > 0) {
|
||||
// offset to global
|
||||
draw d = geom[i];
|
||||
if (z != 0) {
|
||||
d.x += tx * (1LL << (32 - z));
|
||||
d.y += ty * (1LL << (32 - z));
|
||||
}
|
||||
|
||||
// to quadkey
|
||||
struct node n;
|
||||
n.index = encode_quadkey((unsigned) d.x, (unsigned) d.y);
|
||||
|
||||
if (bsearch(&n, shared_nodes_map, nodepos / sizeof(node), sizeof(node), nodecmp) != NULL) {
|
||||
geom[i].necessary = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -661,6 +686,9 @@ drawvec fix_polygon(drawvec &geom) {
|
||||
ring = tmp;
|
||||
}
|
||||
|
||||
// Now we are rotating the ring to make the first/last point
|
||||
// one that would be unlikely to be simplified away.
|
||||
|
||||
// calculate centroid
|
||||
// a + 1 < size() because point 0 is duplicated at the end
|
||||
long long xtotal = 0;
|
||||
|
||||
Reference in New Issue
Block a user