Skip to content

Commit

Permalink
Perform pruning of polygons only at zoom level 14
Browse files Browse the repository at this point in the history
  • Loading branch information
kleunen committed May 4, 2021
1 parent e13e9d5 commit 9dada2f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion include/output_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 7 additions & 1 deletion src/output_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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);
Expand Down
10 changes: 5 additions & 5 deletions src/tile_worker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void ReorderMultiLinestring(MultiLinestring &input, MultiLinestring &output) {

template <typename T>
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,
Expand All @@ -81,7 +81,7 @@ void CheckNextObjectAndMerge(OSMStore &osmStore, OutputObjectsConstIt &jt, Outpu
else ooNext.reset();

try {
T to_merge = boost::get<T>(buildWayGeometry(osmStore, *oo, bbox));
T to_merge = boost::get<T>(buildWayGeometry(osmStore, *oo, bbox, zoom));
T output;
geom::union_(g, to_merge, output);
g = move(output);
Expand Down Expand Up @@ -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;
Expand All @@ -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<MultiLinestring>(g));
CheckNextObjectAndMerge(osmStore, jt, ooSameLayerEnd, bbox, zoom, boost::get<MultiLinestring>(g));
MultiLinestring reordered;
ReorderMultiLinestring(boost::get<MultiLinestring>(g), reordered);
g = move(reordered);
oo = *jt;
} else if (oo->geomType == OutputGeometryType::POLYGON && combinePolygons) {
CheckNextObjectAndMerge(osmStore, jt, ooSameLayerEnd, bbox, boost::get<MultiPolygon>(g));
CheckNextObjectAndMerge(osmStore, jt, ooSameLayerEnd, bbox, zoom, boost::get<MultiPolygon>(g));
oo = *jt;
}

Expand Down

0 comments on commit 9dada2f

Please sign in to comment.