@@ -276,14 +276,37 @@ void ProcessObjects(
276276 if (zoom < oo.oo .minZoom ) { continue ; }
277277
278278 if (oo.oo .geomType == POINT_) {
279+ // The very first point; below we check if there are more compatible points
280+ // so that we can write a multipoint instead of many point features
281+
282+ std::vector<std::pair<int , int >> multipoint;
283+
284+ LatpLon pos = source->buildNodeGeometry (jt->oo .objectID , bbox);
285+ pair<int ,int > xy = bbox.scaleLatpLon (pos.latp /10000000.0 , pos.lon /10000000.0 );
286+ multipoint.push_back (xy);
287+
288+ while (jt<(ooSameLayerEnd-1 ) && oo.oo .compatible ((jt+1 )->oo )) {
289+ jt++;
290+ LatpLon pos = source->buildNodeGeometry (jt->oo .objectID , bbox);
291+ pair<int ,int > xy = bbox.scaleLatpLon (pos.latp /10000000.0 , pos.lon /10000000.0 );
292+ multipoint.push_back (xy);
293+ }
294+
279295 vtzero::point_feature_builder fbuilder{vtLayer};
280296 if (sharedData.config .includeID && oo.id ) fbuilder.set_id (oo.id );
281297
282- LatpLon pos = source->buildNodeGeometry (oo.oo .objectID , bbox);
283- pair<int ,int > xy = bbox.scaleLatpLon (pos.latp /10000000.0 , pos.lon /10000000.0 );
284- fbuilder.add_point (xy.first , xy.second );
298+ fbuilder.add_points (multipoint.size ());
299+
300+ if (verbose && multipoint.size () > 1 )
301+ std::cout << " Merging " << multipoint.size () << " points into a multipoint" << std::endl;
302+
303+ for (const auto point : multipoint)
304+ fbuilder.set_point (point.first , point.second );
305+
285306 oo.oo .writeAttributes (attributeStore, fbuilder, zoom);
286307 fbuilder.commit ();
308+
309+ oo = *jt;
287310 } else {
288311 Geometry g;
289312 try {
0 commit comments