From 9dada2f598d748ad0392b60970d0e56636e71eb3 Mon Sep 17 00:00:00 2001 From: Wouter van Kleunen Date: Tue, 4 May 2021 15:46:06 +0000 Subject: [PATCH] Perform pruning of polygons only at zoom level 14 --- include/output_object.h | 2 +- src/output_object.cpp | 8 +++++++- src/tile_worker.cpp | 10 +++++----- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/include/output_object.h b/include/output_object.h index e61e1c3b..f3d74e1a 100644 --- a/include/output_object.h +++ b/include/output_object.h @@ -120,7 +120,7 @@ static inline void intrusive_ptr_release(OutputObject *oo) { * Returns a boost::variant - * POLYGON->MultiPolygon, CENTROID->Point, LINESTRING->MultiLinestring */ -Geometry buildWayGeometry(OSMStore &osmStore, OutputObject const &oo, const TileBbox &bbox); +Geometry buildWayGeometry(OSMStore &osmStore, OutputObject const &oo, const TileBbox &bbox, unsigned int zoom_level); //\brief Build a node geometry LatpLon buildNodeGeometry(OSMStore &osmStore, OutputObject const &oo, const TileBbox &bbox); diff --git a/src/output_object.cpp b/src/output_object.cpp index 2c97748a..ef31ec0c 100644 --- a/src/output_object.cpp +++ b/src/output_object.cpp @@ -111,7 +111,7 @@ Ring ReduceRing(Ring const &input, Box const &clippingBox, CheckLine checkline) return result; } -Geometry buildWayGeometry(OSMStore &osmStore, OutputObject const &oo, const TileBbox &bbox) +Geometry buildWayGeometry(OSMStore &osmStore, OutputObject const &oo, const TileBbox &bbox, unsigned int zoom) { switch(oo.geomType) { case OutputGeometryType::POINT: @@ -159,6 +159,12 @@ Geometry buildWayGeometry(OSMStore &osmStore, OutputObject const &oo, const Tile geom::convert(bbox.clippingBox, clippingPolygon); if (!geom::intersects(input, clippingPolygon)) { return MultiPolygon(); } + if(zoom < 14) { + MultiPolygon mp; + geom::intersection(input, clippingPolygon, mp); + return mp; + } + MultiPolygon mp; Polygon extendPolygon; geom::convert(bbox.getExtendBox(), extendPolygon); diff --git a/src/tile_worker.cpp b/src/tile_worker.cpp index c968fb94..0fdd8fc5 100644 --- a/src/tile_worker.cpp +++ b/src/tile_worker.cpp @@ -62,7 +62,7 @@ void ReorderMultiLinestring(MultiLinestring &input, MultiLinestring &output) { template void CheckNextObjectAndMerge(OSMStore &osmStore, OutputObjectsConstIt &jt, OutputObjectsConstIt ooSameLayerEnd, - const TileBbox &bbox, T &g) { + const TileBbox &bbox, unsigned int zoom, T &g) { // If a object is a linestring/polygon that is followed by // other linestrings/polygons with the same attributes, @@ -81,7 +81,7 @@ void CheckNextObjectAndMerge(OSMStore &osmStore, OutputObjectsConstIt &jt, Outpu else ooNext.reset(); try { - T to_merge = boost::get(buildWayGeometry(osmStore, *oo, bbox)); + T to_merge = boost::get(buildWayGeometry(osmStore, *oo, bbox, zoom)); T output; geom::union_(g, to_merge, output); g = move(output); @@ -114,7 +114,7 @@ void ProcessObjects(OSMStore &osmStore, OutputObjectsConstIt ooSameLayerBegin, O } else { Geometry g; try { - g = buildWayGeometry(osmStore, *oo, bbox); + g = buildWayGeometry(osmStore, *oo, bbox, zoom); } catch (std::out_of_range &err) { if (verbose) cerr << "Error while processing geometry " << oo->geomType << "," << oo->objectID <<"," << err.what() << endl; continue; @@ -126,13 +126,13 @@ void ProcessObjects(OSMStore &osmStore, OutputObjectsConstIt ooSameLayerBegin, O //This may increment the jt iterator if (oo->geomType == OutputGeometryType::LINESTRING && zoom < sharedData.config.combineBelow) { - CheckNextObjectAndMerge(osmStore, jt, ooSameLayerEnd, bbox, boost::get(g)); + CheckNextObjectAndMerge(osmStore, jt, ooSameLayerEnd, bbox, zoom, boost::get(g)); MultiLinestring reordered; ReorderMultiLinestring(boost::get(g), reordered); g = move(reordered); oo = *jt; } else if (oo->geomType == OutputGeometryType::POLYGON && combinePolygons) { - CheckNextObjectAndMerge(osmStore, jt, ooSameLayerEnd, bbox, boost::get(g)); + CheckNextObjectAndMerge(osmStore, jt, ooSameLayerEnd, bbox, zoom, boost::get(g)); oo = *jt; }