Skip to content

Commit ba9de6e

Browse files
Prgm767Prgm767
authored andcommitted
* 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.
1 parent d45afc3 commit ba9de6e

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

src/tile_worker.cpp

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,16 +293,32 @@ void ProcessObjects(
293293
// so that we can write a multipoint instead of many point features
294294

295295
std::vector<std::pair<int, int>> multipoint;
296+
const int tile_extent = bbox.hires ? 8192 : 4096;
297+
const int margin = 256; // Just in case something happens near the edges.
296298

297299
LatpLon pos = source->buildNodeGeometry(jt->oo.objectID, bbox);
298300
pair<int,int> xy = bbox.scaleLatpLon(pos.latp/10000000.0, pos.lon/10000000.0);
299-
multipoint.push_back(xy);
301+
302+
// Filter out points that are way beyond the reasonable tile extent
303+
if (xy.first >= -margin && xy.first <= tile_extent + margin &&
304+
xy.second >= -margin && xy.second <= tile_extent + margin) {
305+
multipoint.push_back(xy);
306+
}
300307

301308
while (jt<(ooSameLayerEnd-1) && oo.oo.compatible((jt+1)->oo) && combinePoints) {
302309
jt++;
303310
LatpLon pos = source->buildNodeGeometry(jt->oo.objectID, bbox);
304311
pair<int,int> xy = bbox.scaleLatpLon(pos.latp/10000000.0, pos.lon/10000000.0);
305-
multipoint.push_back(xy);
312+
313+
if (xy.first >= -margin && xy.first <= tile_extent + margin &&
314+
xy.second >= -margin && xy.second <= tile_extent + margin) {
315+
multipoint.push_back(xy);
316+
}
317+
}
318+
319+
if (multipoint.empty()) {
320+
oo = *jt;
321+
continue;
306322
}
307323

308324
vtzero::point_feature_builder fbuilder{vtLayer};

0 commit comments

Comments
 (0)