From ba9de6e6767006c8df83cea49875a8e74996ff31 Mon Sep 17 00:00:00 2001 From: Prgm767 Date: Wed, 21 Jan 2026 22:57:10 +0000 Subject: [PATCH] * src/tile_worker.cpp: ignore points too far out of the valid tile. This makes a pmtiles of the entire world around 10% smaller. Not sure if the 256 buffer is needed. --- src/tile_worker.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/tile_worker.cpp b/src/tile_worker.cpp index b61c1ea4..8766f91a 100644 --- a/src/tile_worker.cpp +++ b/src/tile_worker.cpp @@ -293,16 +293,32 @@ void ProcessObjects( // so that we can write a multipoint instead of many point features std::vector> multipoint; + const int tile_extent = bbox.hires ? 8192 : 4096; + const int margin = 256; // Just in case something happens near the edges. LatpLon pos = source->buildNodeGeometry(jt->oo.objectID, bbox); pair xy = bbox.scaleLatpLon(pos.latp/10000000.0, pos.lon/10000000.0); - multipoint.push_back(xy); + + // Filter out points that are way beyond the reasonable tile extent + if (xy.first >= -margin && xy.first <= tile_extent + margin && + xy.second >= -margin && xy.second <= tile_extent + margin) { + multipoint.push_back(xy); + } while (jt<(ooSameLayerEnd-1) && oo.oo.compatible((jt+1)->oo) && combinePoints) { jt++; LatpLon pos = source->buildNodeGeometry(jt->oo.objectID, bbox); pair xy = bbox.scaleLatpLon(pos.latp/10000000.0, pos.lon/10000000.0); - multipoint.push_back(xy); + + if (xy.first >= -margin && xy.first <= tile_extent + margin && + xy.second >= -margin && xy.second <= tile_extent + margin) { + multipoint.push_back(xy); + } + } + + if (multipoint.empty()) { + oo = *jt; + continue; } vtzero::point_feature_builder fbuilder{vtLayer};