From 1e4a4d7e8d37250ec04e1ebad672953e9d47a210 Mon Sep 17 00:00:00 2001 From: Oliver Wipfli Date: Sun, 5 Jan 2025 17:06:20 +0100 Subject: [PATCH] Fix Antarctica landcover (#342) * Fix Antarctica landcover by adding in glacier geometry from Natural Earth. [#337] --- .../com/protomaps/basemap/layers/Earth.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tiles/src/main/java/com/protomaps/basemap/layers/Earth.java b/tiles/src/main/java/com/protomaps/basemap/layers/Earth.java index 1c806ad8..6d3014fe 100644 --- a/tiles/src/main/java/com/protomaps/basemap/layers/Earth.java +++ b/tiles/src/main/java/com/protomaps/basemap/layers/Earth.java @@ -9,6 +9,7 @@ import com.protomaps.basemap.feature.FeatureId; import com.protomaps.basemap.names.OsmNames; import java.util.List; +import org.locationtech.jts.geom.Point; public class Earth implements ForwardingProfile.LayerPostProcesser { @Override @@ -29,6 +30,23 @@ public void processNe(SourceFeature sf, FeatureCollector features) { } else if (sourceLayer.equals("ne_10m_land")) { features.polygon(this.name()).setZoomRange(5, 5).setBufferPixels(8).setAttr("kind", "earth"); } + // Daylight landcover uses ESA WorldCover which only goes to a latitude of roughly 80 deg S. + // Parts of Antarctica therefore get no landcover = glacier from Daylight. + // To fix this, we add glaciated areas from Natural Earth in Antarctica. + if (sourceLayer.equals("ne_10m_glaciated_areas")) { + try { + Point centroid = (Point) sf.centroid(); + // Web Mercator Y = 0.7 is roughly 60 deg South, i.e., Antarctica. + if (centroid.getY() > 0.7) { + features.polygon("landcover") + .setAttr("kind", "glacier") + .setZoomRange(0, 7) + .setMinPixelSize(0.0); + } + } catch (GeometryException e) { + System.out.println("Error: " + e); + } + } } public void processOsm(SourceFeature sf, FeatureCollector features) {