Skip to content

Commit f5bbf0d

Browse files
authored
Landcover 2 (#233)
* bump pmtiles version * tiles 3.5.1 * order landcover by kind consistently in tileset [#154]
1 parent 16777e4 commit f5bbf0d

File tree

6 files changed

+29
-17
lines changed

6 files changed

+29
-17
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
Tiles v3.5.1
2+
------
3+
- Order landcover by kind consistently [#154]
4+
15
Tiles v3.5.0
26
------
37
- Add Daylight Landcover from zooms 0-7. [#154]

app/package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"ol-mapbox-style": "^12.0.0",
1717
"ol-pmtiles": "^0.2.0",
1818
"pixelmatch": "^5.3.0",
19-
"pmtiles": "^3.0.4",
19+
"pmtiles": "^3.0.5",
2020
"react": "^18.2.0",
2121
"react-dom": "^18.2.0",
2222
"react-dropzone": "^14.2.3",

tiles/src/main/java/com/protomaps/basemap/Basemap.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public String description() {
9696

9797
@Override
9898
public String version() {
99-
return "3.5.0";
99+
return "3.5.1";
100100
}
101101

102102
@Override

tiles/src/main/java/com/protomaps/basemap/layers/Landcover.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,23 @@
1212
public class Landcover implements ForwardingProfile.FeaturePostProcessor {
1313

1414
static final Map<String, String> kindMapping = Map.of("urban", "urban_area", "crop", "farmland", "grass", "grassland",
15-
"trees", "forest", "snow", "glacier", "shrub", "scrub", "barren", "barren");
15+
"trees", "forest", "snow", "glacier", "shrub", "scrub");
16+
17+
static final Map<String, Integer> sortKeyMapping =
18+
Map.of("barren", 0, "snow", 1, "crop", 2, "shrub", 3, "grass", 4, "trees", 5);
1619

1720
public void processLandcover(SourceFeature sf, FeatureCollector features) {
18-
String kind = kindMapping.getOrDefault(sf.getString("class"), "unknown");
21+
String daylightClass = sf.getString("class");
22+
String kind = kindMapping.getOrDefault(daylightClass, daylightClass);
23+
24+
// polygons are disjoint and non-overlapping, but order them in archive in consistent way
25+
Integer sortKey = sortKeyMapping.getOrDefault(daylightClass, 6);
1926

2027
features.polygon(this.name())
2128
.setId(FeatureId.create(sf))
2229
.setAttr("pmap:kind", kind)
2330
.setZoomRange(0, 7)
31+
.setSortKey(sortKey)
2432
.setMinPixelSize(0.0);
2533
}
2634

tiles/src/test/java/com/protomaps/basemap/layers/LandcoverTest.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@ class LandcoverTest extends LayerTest {
1313

1414
@ParameterizedTest
1515
@CsvSource(value = {
16-
"urban,urban_area",
17-
"crop,farmland",
18-
"grass,grassland",
19-
"trees,forest",
20-
"snow,glacier",
21-
"shrub,scrub",
22-
"barren,barren"
16+
"urban,urban_area,6",
17+
"crop,farmland,2",
18+
"grass,grassland,4",
19+
"trees,forest,5",
20+
"snow,glacier,1",
21+
"shrub,scrub,3",
22+
"barren,barren,0"
2323
})
24-
void simple(String daylightClassString, String expectedString) {
24+
void simple(String daylightClassString, String expectedString, Integer expectedSortKey) {
2525
assertFeatures(7,
26-
List.of(Map.of("pmap:kind", expectedString)),
26+
List.of(Map.of("pmap:kind", expectedString, "_sortkey", expectedSortKey)),
2727
process(SimpleFeature.create(
2828
newPolygon(0, 0, 0, 1, 1, 1, 0, 0),
2929
new HashMap<>(Map.of("class", daylightClassString)),

0 commit comments

Comments
 (0)