@@ -298,16 +298,32 @@ void ProcessObjects(
298298 // so that we can write a multipoint instead of many point features
299299
300300 std::vector<std::pair<int , int >> multipoint;
301+ const int tile_extent = bbox.hires ? 8192 : 4096 ;
302+ const int margin = 256 ; // Just in case something happens near the edges.
301303
302304 LatpLon pos = source->buildNodeGeometry (jt->oo .objectID , bbox);
303305 pair<int ,int > xy = bbox.scaleLatpLon (pos.latp /10000000.0 , pos.lon /10000000.0 );
304- multipoint.push_back (xy);
306+
307+ // Filter out points that are way beyond the reasonable tile extent
308+ if (xy.first >= -margin && xy.first <= tile_extent + margin &&
309+ xy.second >= -margin && xy.second <= tile_extent + margin) {
310+ multipoint.push_back (xy);
311+ }
305312
306313 while (jt<(ooSameLayerEnd-1 ) && oo.oo .compatible ((jt+1 )->oo ) && combinePoints) {
307314 jt++;
308315 LatpLon pos = source->buildNodeGeometry (jt->oo .objectID , bbox);
309316 pair<int ,int > xy = bbox.scaleLatpLon (pos.latp /10000000.0 , pos.lon /10000000.0 );
310- multipoint.push_back (xy);
317+
318+ if (xy.first >= -margin && xy.first <= tile_extent + margin &&
319+ xy.second >= -margin && xy.second <= tile_extent + margin) {
320+ multipoint.push_back (xy);
321+ }
322+ }
323+
324+ if (multipoint.empty ()) {
325+ oo = *jt;
326+ continue ;
311327 }
312328
313329 vtzero::point_feature_builder fbuilder{vtLayer};
0 commit comments