Skip to content

Commit

Permalink
Landcover 2 (#233)
Browse files Browse the repository at this point in the history
* bump pmtiles version

* tiles 3.5.1

* order landcover by kind consistently in tileset [#154]
  • Loading branch information
bdon authored Apr 6, 2024
1 parent 16777e4 commit f5bbf0d
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 17 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Tiles v3.5.1
------
- Order landcover by kind consistently [#154]

Tiles v3.5.0
------
- Add Daylight Landcover from zooms 0-7. [#154]
Expand Down
8 changes: 4 additions & 4 deletions app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"ol-mapbox-style": "^12.0.0",
"ol-pmtiles": "^0.2.0",
"pixelmatch": "^5.3.0",
"pmtiles": "^3.0.4",
"pmtiles": "^3.0.5",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-dropzone": "^14.2.3",
Expand Down
2 changes: 1 addition & 1 deletion tiles/src/main/java/com/protomaps/basemap/Basemap.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public String description() {

@Override
public String version() {
return "3.5.0";
return "3.5.1";
}

@Override
Expand Down
12 changes: 10 additions & 2 deletions tiles/src/main/java/com/protomaps/basemap/layers/Landcover.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,23 @@
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");
"trees", "forest", "snow", "glacier", "shrub", "scrub");

static final Map<String, Integer> sortKeyMapping =
Map.of("barren", 0, "snow", 1, "crop", 2, "shrub", 3, "grass", 4, "trees", 5);

public void processLandcover(SourceFeature sf, FeatureCollector features) {
String kind = kindMapping.getOrDefault(sf.getString("class"), "unknown");
String daylightClass = sf.getString("class");
String kind = kindMapping.getOrDefault(daylightClass, daylightClass);

// polygons are disjoint and non-overlapping, but order them in archive in consistent way
Integer sortKey = sortKeyMapping.getOrDefault(daylightClass, 6);

features.polygon(this.name())
.setId(FeatureId.create(sf))
.setAttr("pmap:kind", kind)
.setZoomRange(0, 7)
.setSortKey(sortKey)
.setMinPixelSize(0.0);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ class LandcoverTest extends LayerTest {

@ParameterizedTest
@CsvSource(value = {
"urban,urban_area",
"crop,farmland",
"grass,grassland",
"trees,forest",
"snow,glacier",
"shrub,scrub",
"barren,barren"
"urban,urban_area,6",
"crop,farmland,2",
"grass,grassland,4",
"trees,forest,5",
"snow,glacier,1",
"shrub,scrub,3",
"barren,barren,0"
})
void simple(String daylightClassString, String expectedString) {
void simple(String daylightClassString, String expectedString, Integer expectedSortKey) {
assertFeatures(7,
List.of(Map.of("pmap:kind", expectedString)),
List.of(Map.of("pmap:kind", expectedString, "_sortkey", expectedSortKey)),
process(SimpleFeature.create(
newPolygon(0, 0, 0, 1, 1, 1, 0, 0),
new HashMap<>(Map.of("class", daylightClassString)),
Expand Down

0 comments on commit f5bbf0d

Please sign in to comment.