diff --git a/styles/src/base_layers.ts b/styles/src/base_layers.ts index 8ca8ed19..6829f776 100644 --- a/styles/src/base_layers.ts +++ b/styles/src/base_layers.ts @@ -136,10 +136,10 @@ export function nolabels_layers( }, }, { - id: "natural_wood", + id: "landuse_wood", type: "fill", source: source, - "source-layer": "natural", + "source-layer": "landuse", filter: ["any", ["in", "kind", "wood", "nature_reserve", "forest"]], paint: { "fill-color": [ @@ -154,10 +154,10 @@ export function nolabels_layers( }, }, { - id: "natural_scrub", + id: "landuse_scrub", type: "fill", source: source, - "source-layer": "natural", + "source-layer": "landuse", filter: ["in", "kind", "scrub", "grassland", "grass"], paint: { "fill-color": [ @@ -172,20 +172,20 @@ export function nolabels_layers( }, }, { - id: "natural_glacier", + id: "landuse_glacier", type: "fill", source: source, - "source-layer": "natural", + "source-layer": "landuse", filter: ["==", "kind", "glacier"], paint: { "fill-color": t.glacier, }, }, { - id: "natural_sand", + id: "landuse_sand", type: "fill", source: source, - "source-layer": "natural", + "source-layer": "landuse", filter: ["==", "kind", "sand"], paint: { "fill-color": t.sand, diff --git a/tiles/src/main/java/com/protomaps/basemap/Basemap.java b/tiles/src/main/java/com/protomaps/basemap/Basemap.java index b4017cd0..ae8314e1 100644 --- a/tiles/src/main/java/com/protomaps/basemap/Basemap.java +++ b/tiles/src/main/java/com/protomaps/basemap/Basemap.java @@ -11,7 +11,6 @@ import com.protomaps.basemap.layers.Earth; import com.protomaps.basemap.layers.Landcover; import com.protomaps.basemap.layers.Landuse; -import com.protomaps.basemap.layers.Natural; import com.protomaps.basemap.layers.PhysicalLine; import com.protomaps.basemap.layers.PhysicalPoint; import com.protomaps.basemap.layers.Places; @@ -47,10 +46,6 @@ public Basemap(NaturalEarthDb naturalEarthDb, QrankDb qrankDb) { registerHandler(landcover); registerSourceHandler("landcover", landcover::processLandcover); - var natural = new Natural(); - registerHandler(natural); - registerSourceHandler("osm", natural::processOsm); - var physicalLine = new PhysicalLine(); registerHandler(physicalLine); registerSourceHandler("osm", physicalLine::processOsm); @@ -171,7 +166,7 @@ static void run(Arguments args) { fontRegistry.loadFontBundle("NotoSansDevanagari-Regular", "1", "Devanagari"); - planetiler.setProfile(new Basemap(naturalEarthDb, qrankDb)).setOutput(Path.of(area + ".pmtiles")) + planetiler.setProfile(new Basemap(naturalEarthDb, qrankDb)).setOutput(Path.of(area + ".mbtiles")) .run(); } } diff --git a/tiles/src/main/java/com/protomaps/basemap/layers/Landuse.java b/tiles/src/main/java/com/protomaps/basemap/layers/Landuse.java index 6031f67d..8c0b7f72 100644 --- a/tiles/src/main/java/com/protomaps/basemap/layers/Landuse.java +++ b/tiles/src/main/java/com/protomaps/basemap/layers/Landuse.java @@ -18,10 +18,10 @@ public void processOsm(SourceFeature sf, FeatureCollector features) { sf.hasTag("amenity", "hospital", "school", "kindergarten", "university", "college") || sf.hasTag("boundary", "national_park", "protected_area") || sf.hasTag("landuse", "recreation_ground", "industrial", "brownfield", "railway", "cemetery", "commercial", - "grass", "orchard", "farmland", "farmyard", "residential", "military", "village_green", "allotments") || + "grass", "orchard", "farmland", "farmyard", "residential", "military", "village_green", "allotments", "forest", "meadow", "grass") || sf.hasTag("leisure", "park", "garden", "golf_course", "dog_park", "playground", "pitch", "nature_reserve") || sf.hasTag("man_made", "pier", "bridge") || - sf.hasTag("natural", "beach") || + sf.hasTag("natural", "beach", "wood", "glacier", "grass", "scrub", "sand", "wetland", "bare_rock") || // TODO: (nvkelso 20230622) This use of the place tag here is dubious, though paired with "residential" sf.hasTag("place", "neighbourhood") || sf.hasTag("railway", "platform") || diff --git a/tiles/src/main/java/com/protomaps/basemap/layers/Natural.java b/tiles/src/main/java/com/protomaps/basemap/layers/Natural.java deleted file mode 100644 index 24af4682..00000000 --- a/tiles/src/main/java/com/protomaps/basemap/layers/Natural.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.protomaps.basemap.layers; - -import com.onthegomap.planetiler.FeatureCollector; -import com.onthegomap.planetiler.FeatureMerge; -import com.onthegomap.planetiler.ForwardingProfile; -import com.onthegomap.planetiler.VectorTile; -import com.onthegomap.planetiler.geo.GeometryException; -import com.onthegomap.planetiler.reader.SourceFeature; -import com.protomaps.basemap.postprocess.Area; -import java.util.List; - -public class Natural implements ForwardingProfile.FeaturePostProcessor { - - @Override - public String name() { - return "natural"; - } - - public void processOsm(SourceFeature sf, FeatureCollector features) { - if (sf.canBePolygon() && - (sf.hasTag("natural", "wood", "glacier", "grass", "scrub", "sand", "wetland", "bare_rock") || - sf.hasTag("landuse", "forest", "meadow", "grass"))) { - String kind = "other"; - if (sf.hasTag("natural")) { - kind = sf.getString("natural"); - } else if (sf.hasTag("landuse")) { - kind = sf.getString("landuse"); - } - - features.polygon(this.name()) - //.setId(FeatureId.create(sf)) - // Core Tilezen schema properties - .setAttr("kind", kind) - // NOTE: (nvkelso 20230622) Consider zoom 5 instead... - // But to match Protomaps v2 we do earlier - .setZoomRange(2, 15) - .setMinPixelSize(2.0); - } - } - - @Override - public List postProcess(int zoom, List items) throws GeometryException { - if (zoom == 15) - return items; - - int minArea = 400 / (4096 * 4096) * (256 * 256); - if (zoom == 6) - minArea = 600 / (4096 * 4096) * (256 * 256); - else if (zoom <= 5) - minArea = 800 / (4096 * 4096) * (256 * 256); - items = Area.filterArea(items, minArea); - - return FeatureMerge.mergeNearbyPolygons(items, 3.125, 3.125, 0.5, 0.5); - } -} diff --git a/tiles/src/test/java/com/protomaps/basemap/layers/LanduseTest.java b/tiles/src/test/java/com/protomaps/basemap/layers/LanduseTest.java index 858e242d..2f953a90 100644 --- a/tiles/src/test/java/com/protomaps/basemap/layers/LanduseTest.java +++ b/tiles/src/test/java/com/protomaps/basemap/layers/LanduseTest.java @@ -47,4 +47,17 @@ void landuseAllotments() { 0 ))); } + + @Test + void landuseGlacier() { + assertFeatures(15, + List.of(Map.of("kind", "glacier")), + process(SimpleFeature.create( + newPolygon(0, 0, 0, 1, 1, 1, 0, 0), + new HashMap<>(Map.of("natural", "glacier")), + "osm", + null, + 0 + ))); + } } diff --git a/tiles/src/test/java/com/protomaps/basemap/layers/NaturalTest.java b/tiles/src/test/java/com/protomaps/basemap/layers/NaturalTest.java deleted file mode 100644 index a09e145f..00000000 --- a/tiles/src/test/java/com/protomaps/basemap/layers/NaturalTest.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.protomaps.basemap.layers; - -import static com.onthegomap.planetiler.TestUtils.newPolygon; - -import com.onthegomap.planetiler.reader.SimpleFeature; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.junit.jupiter.api.Test; - -class NaturalTest extends LayerTest { - @Test - void simple() { - assertFeatures(15, - List.of(Map.of("kind", "glacier")), - process(SimpleFeature.create( - newPolygon(0, 0, 0, 1, 1, 1, 0, 0), - new HashMap<>(Map.of("natural", "glacier")), - "osm", - null, - 0 - ))); - } -}