Skip to content

Commit

Permalink
Coastline tweaks (#611)
Browse files Browse the repository at this point in the history
  • Loading branch information
systemed authored Dec 11, 2023
1 parent b278569 commit 34c356a
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion include/geom.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ using uint = unsigned int;
#include <limits>

// boost::geometry
#define BOOST_GEOMETRY_INCLUDE_SELF_TURNS
#define BOOST_GEOMETRY_NO_ROBUSTNESS
#include <boost/geometry.hpp>
#include <boost/geometry/algorithms/intersection.hpp>
#include <boost/geometry/geometries/geometries.hpp>
Expand Down
4 changes: 2 additions & 2 deletions resources/config-coastline.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"layers": {
"water": { "minzoom": 6, "maxzoom": 14, "simplify_below": 12, "simplify_length": 1, "simplify_ratio": 2},
"ocean": { "minzoom": 0, "maxzoom": 14, "source": "coastline/water_polygons.shp", "simplify_below": 13, "simplify_level": 0.0001, "simplify_ratio": 2, "write_to": "water", "index": true, "source_columns": true }
"ocean": { "minzoom": 0, "maxzoom": 14, "source": "coastline/water_polygons.shp", "simplify_below": 13, "simplify_level": 0.0001, "simplify_ratio": 2, "filter_below": 12, "filter_area": 0.5, "write_to": "water", "index": true, "source_columns": true }
},
"settings": {
"minzoom": 0,
"maxzoom": 6,
"maxzoom": 14,
"basezoom": 14,
"include_ids": false,
"combine_below": 14,
Expand Down
2 changes: 1 addition & 1 deletion resources/config-openmaptiles.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"building": { "minzoom": 13, "maxzoom": 14 },

"water": { "minzoom": 6, "maxzoom": 14, "simplify_below": 12, "simplify_level": 0.0003, "simplify_ratio": 2},
"ocean": { "minzoom": 0, "maxzoom": 14, "source": "coastline/water_polygons.shp", "simplify_below": 13, "simplify_level": 0.0001, "simplify_ratio": 2, "write_to": "water", "index": true },
"ocean": { "minzoom": 0, "maxzoom": 14, "source": "coastline/water_polygons.shp", "filter_below": 12, "filter_area": 0.5, "simplify_below": 13, "simplify_level": 0.0001, "simplify_ratio": 2, "write_to": "water" },
"water_name": { "minzoom": 14, "maxzoom": 14 },
"water_name_detail": { "minzoom": 14, "maxzoom": 14, "write_to": "water_name" },

Expand Down
File renamed without changes.
5 changes: 2 additions & 3 deletions resources/process-openmaptiles.lua
Original file line number Diff line number Diff line change
Expand Up @@ -571,11 +571,10 @@ function way_function(way)
end

-- Set 'water'
if natural=="water" or natural=="bay" or leisure=="swimming_pool" or landuse=="reservoir" or landuse=="basin" or waterClasses[waterway] then
if natural=="water" or leisure=="swimming_pool" or landuse=="reservoir" or landuse=="basin" or waterClasses[waterway] then
if way:Find("covered")=="yes" or not isClosed then return end
local class="lake"; if natural=="bay" then class="ocean" elseif waterway~="" then class="river" end
local class="lake"; if waterway~="" then class="river" end
if class=="lake" and way:Find("wikidata")=="Q192770" then return end
if class=="ocean" and isClosed and (way:AreaIntersecting("ocean")/way:Area() > 0.98) then return end
way:Layer("water",true)
SetMinZoomByArea(way)
way:Attribute("class",class)
Expand Down
2 changes: 1 addition & 1 deletion src/geom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ MultiPolygon simplify(MultiPolygon const &mp, double max_distance)
for(auto const &p: mp) {
Polygon new_p = simplify(p, max_distance);
if(!new_p.outer().empty()) {
if (new_p.outer().size()>15) geom::correct(new_p);
geom::correct(new_p);
simplify_combine(result_mp, std::move(new_p));
}
}
Expand Down
13 changes: 10 additions & 3 deletions src/tile_worker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,14 @@ void CheckNextObjectAndMerge(
}
}

void RemoveInnersBelowSize(MultiPolygon &g, double filterArea) {
void RemovePartsBelowSize(MultiPolygon &g, double filterArea) {
g.erase(std::remove_if(
g.begin(),
g.end(),
[&](const Polygon &poly) -> bool {
return std::fabs(geom::area(poly)) < filterArea;
}),
g.end());
for (auto &outer : g) {
outer.inners().erase(std::remove_if(
outer.inners().begin(),
Expand Down Expand Up @@ -188,8 +195,8 @@ void ProcessObjects(
}

if (oo.oo.geomType == POLYGON_ && filterArea > 0.0) {
if (geom::area(g)<filterArea) continue;
RemoveInnersBelowSize(boost::get<MultiPolygon>(g), filterArea);
RemovePartsBelowSize(boost::get<MultiPolygon>(g), filterArea);
if (geom::is_empty(g)) continue;
}

//This may increment the jt iterator
Expand Down

0 comments on commit 34c356a

Please sign in to comment.