-
-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* add daylight landcover to tileset [#154] * Use geopackage mirror of daylight dataset from https://daylightmap.org/2023/10/11/landcover.html * remap daylight classes to tilezen-like kinds * tiles 3.5.0, changelog
- Loading branch information
Showing
4 changed files
with
84 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
tiles/src/main/java/com/protomaps/basemap/layers/Landcover.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.protomaps.basemap.layers; | ||
|
||
import com.onthegomap.planetiler.FeatureCollector; | ||
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.feature.FeatureId; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public class Landcover implements ForwardingProfile.FeaturePostProcessor { | ||
|
||
static final Map<String, String> kindMapping = Map.of("urban", "urban_area", "crop", "farmland", "grass", "grassland", | ||
"trees", "forest", "snow", "glacier", "shrub", "scrub", "barren", "barren"); | ||
|
||
public void processLandcover(SourceFeature sf, FeatureCollector features) { | ||
String kind = kindMapping.getOrDefault(sf.getString("class"), "unknown"); | ||
|
||
features.polygon(this.name()) | ||
.setId(FeatureId.create(sf)) | ||
.setAttr("pmap:kind", kind) | ||
.setZoomRange(0, 7) | ||
.setMinPixelSize(0.0); | ||
} | ||
|
||
@Override | ||
public String name() { | ||
return "landcover"; | ||
} | ||
|
||
@Override | ||
public List<VectorTile.Feature> postProcess(int zoom, List<VectorTile.Feature> items) throws GeometryException { | ||
return items; | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
tiles/src/test/java/com/protomaps/basemap/layers/LandcoverTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
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.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.CsvSource; | ||
|
||
class LandcoverTest extends LayerTest { | ||
|
||
@ParameterizedTest | ||
@CsvSource(value = { | ||
"urban,urban_area", | ||
"crop,farmland", | ||
"grass,grassland", | ||
"trees,forest", | ||
"snow,glacier", | ||
"shrub,scrub", | ||
"barren,barren" | ||
}) | ||
void simple(String daylightClassString, String expectedString) { | ||
assertFeatures(7, | ||
List.of(Map.of("pmap:kind", expectedString)), | ||
process(SimpleFeature.create( | ||
newPolygon(0, 0, 0, 1, 1, 1, 0, 0), | ||
new HashMap<>(Map.of("class", daylightClassString)), | ||
"landcover", | ||
null, | ||
0 | ||
))); | ||
} | ||
} |