Update to OMT 3.14 (#50)

* initial update step: 3.13.1 bumped to 3.14

* automated update steps: regenerate-openmaptiles.sh v3.14 + mvn spotless:apply

* riverbank was removed from waterway -> replaced with dock un the unit test

* riverbank was removed from waterway -> testRiverbank() changed into testDock()

* riverbank was removed in OpenMapTiles v3.14

* parcel_locker (with brand, operator and/or ref) was added in OpenMapTiles v3.14

* bus_guideway was added in OpenMapTiles v3.14

* support for county seats (capital=6) was added in OpenMapTiles v3.14

* spotless:apply

* gn_ascii replaced with name_en

gn_ascii was removed from NE5 - see commit b14da2ea in OMT for more
details

* merging of buildings at Z13 replicated also for landuse from Z9 (or for some from Z6) to Z13 to match updates in OpenMapTiles v3.14

* landuse_merge_z9_to_z13 argument removed since it has negligible perf. overhead hence no need to have it

* cover a corner case for parcel_locker: no brand, no operator, just ref

* corrected landuse polygon merging to better match OpenMapTiles 3.14 (1)

* corrected landuse polygon merging to better match OpenMapTiles 3.14 (1): merge only landuse=residential

* clean-up: since evaluation in Landuse is simpler than in Landcover, streaming and Collectors.partitioningBy() used

* clean-up of naming: splitList -> splitLists

* land-use merging unit test adjusted and extended to match recent changes

* other unit tests adjusted to match recent changes

* spotless:apply

* clean-up: added comment, to match Landover

* 3.13.1 bumped to 3.14 (follow-up/fix for e26e13a6f)

* adjusted WOOD_OR_FOREST handling for Z8 to match change in OMT (osm_landcover_gen_z8)

* updated unit test to match adjusted WOOD_OR_FOREST handling for Z8

* clean-up: if-else replaced with switch

* clean-up: conditional grouped to make it more readable
This commit is contained in:
Peter Hanecak
2022-12-28 13:36:12 +01:00
committed by GitHub
parent d378521372
commit c662ef2d30
18 changed files with 400 additions and 146 deletions

View File

@@ -158,14 +158,14 @@ public class Landcover implements
} else { // don't merge
result.add(item);
}
} else if (zoom == 9) {
} else if (zoom >= 8 && zoom <= 9) {
if (WOOD_OR_FOREST.contains(subclass)) {
attrs.put(tempGroupKey, numPoints < 300 ? "<300" : ">300");
toMerge.add(item);
} else { // don't merge
result.add(item);
}
} else { // zoom between 7 and 8
} else { // zoom 7
toMerge.add(item);
}
} else {

View File

@@ -39,14 +39,19 @@ import static org.openmaptiles.util.Utils.coalesce;
import static org.openmaptiles.util.Utils.nullIfEmpty;
import com.onthegomap.planetiler.FeatureCollector;
import com.onthegomap.planetiler.FeatureMerge;
import com.onthegomap.planetiler.VectorTile;
import com.onthegomap.planetiler.config.PlanetilerConfig;
import com.onthegomap.planetiler.geo.GeometryException;
import com.onthegomap.planetiler.reader.SourceFeature;
import com.onthegomap.planetiler.stats.Stats;
import com.onthegomap.planetiler.util.Parse;
import com.onthegomap.planetiler.util.Translations;
import com.onthegomap.planetiler.util.ZoomFunction;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import org.openmaptiles.OpenMapTilesProfile;
import org.openmaptiles.generated.OpenMapTilesSchema;
import org.openmaptiles.generated.Tables;
@@ -61,6 +66,7 @@ import org.openmaptiles.generated.Tables;
public class Landuse implements
OpenMapTilesSchema.Landuse,
OpenMapTilesProfile.NaturalEarthProcessor,
OpenMapTilesProfile.FeaturePostProcessor,
Tables.OsmLandusePolygon.Handler {
private static final ZoomFunction<Number> MIN_PIXEL_SIZE_THRESHOLDS = ZoomFunction.fromMaxZoomThresholds(Map.of(
@@ -103,10 +109,36 @@ public class Landuse implements
if ("grave_yard".equals(clazz)) {
clazz = FieldValues.CLASS_CEMETERY;
}
features.polygon(LAYER_NAME).setBufferPixels(BUFFER_SIZE)
var feature = features.polygon(LAYER_NAME).setBufferPixels(BUFFER_SIZE)
.setAttr(Fields.CLASS, clazz)
.setMinPixelSizeOverrides(MIN_PIXEL_SIZE_THRESHOLDS)
.setMinZoom(Z6_CLASSES.contains(clazz) ? 6 : 9);
if (FieldValues.CLASS_RESIDENTIAL.equals(clazz)) {
feature
.setMinPixelSize(0.1)
.setPixelTolerance(0.25);
} else {
feature
.setMinPixelSizeOverrides(MIN_PIXEL_SIZE_THRESHOLDS);
}
}
}
@Override
public List<VectorTile.Feature> postProcess(int zoom,
List<VectorTile.Feature> items) throws GeometryException {
if (zoom < 6 || zoom > 12) {
return items;
} else {
// merging only merges polygons with class "residential" for z6-z12
Map<Boolean, List<VectorTile.Feature>> splitLists =
items.stream().collect(Collectors.partitioningBy(
i -> FieldValues.CLASS_RESIDENTIAL.equals(i.attrs().get(Fields.CLASS)))
);
List<VectorTile.Feature> result = splitLists.get(Boolean.FALSE);
List<VectorTile.Feature> toMerge = splitLists.get(Boolean.TRUE);
var merged = FeatureMerge.mergeNearbyPolygons(toMerge, 1, 1, 0.1, 0.1);
result.addAll(merged);
return result;
}
}
}

View File

@@ -184,7 +184,7 @@ public class Place implements
feature.getString("name"),
feature.getString("wikidataid"),
(int) feature.getLong("scalerank"),
Stream.of("name", "namealt", "meganame", "gn_ascii", "nameascii").map(feature::getString)
Stream.of("name", "namealt", "meganame", "name_en", "nameascii").map(feature::getString)
.filter(Objects::nonNull)
.map(s -> s.toLowerCase(Locale.ROOT))
.collect(Collectors.toSet())
@@ -356,10 +356,14 @@ public class Place implements
feature.setPointLabelGridLimit(LABEL_GRID_LIMITS);
}
if ("2".equals(capital) || "yes".equals(capital)) {
feature.setAttr(Fields.CAPITAL, 2);
} else if ("4".equals(capital)) {
feature.setAttr(Fields.CAPITAL, 4);
if (capital != null) { // with Java 18, we can handle that with "case null", see https://openjdk.org/jeps/420)
switch (capital) {
case "2", "yes" -> feature.setAttr(Fields.CAPITAL, 2);
case "3" -> feature.setAttr(Fields.CAPITAL, 3);
case "4" -> feature.setAttr(Fields.CAPITAL, 4);
case "5" -> feature.setAttr(Fields.CAPITAL, 5);
case "6" -> feature.setAttr(Fields.CAPITAL, 6);
}
}
}

View File

@@ -136,7 +136,7 @@ public class Poi implements
setupPoiFeature(element, features.centroidIfConvex(LAYER_NAME));
}
private <T extends Tables.WithSubclass & Tables.WithStation & Tables.WithFunicular & Tables.WithSport & Tables.WithInformation & Tables.WithReligion & Tables.WithMappingKey & Tables.WithName & Tables.WithIndoor & Tables.WithLayer & Tables.WithSource & Tables.WithOperator & Tables.WithNetwork> void setupPoiFeature(
private <T extends Tables.WithSubclass & Tables.WithStation & Tables.WithFunicular & Tables.WithSport & Tables.WithInformation & Tables.WithReligion & Tables.WithMappingKey & Tables.WithName & Tables.WithIndoor & Tables.WithLayer & Tables.WithSource & Tables.WithOperator & Tables.WithNetwork & Tables.WithBrand & Tables.WithRef> void setupPoiFeature(
T element, FeatureCollector.Feature output) {
String rawSubclass = element.subclass();
if ("station".equals(rawSubclass) && "subway".equals(element.station())) {
@@ -156,6 +156,18 @@ public class Poi implements
}
}
// Parcel locker without name: use either brand or operator and add ref if present
if ("parcel_locker".equals(rawSubclass) && nullOrEmpty(name)) {
name = coalesce(nullIfEmpty(element.brand()), nullIfEmpty(element.operator()));
String ref = nullIfEmpty(element.ref());
if (ref != null) {
name = name == null ? ref : (name + " " + ref);
}
if (name != null) {
tags.put("name", name);
}
}
String subclass = switch (rawSubclass) {
case "information" -> nullIfEmpty(element.information());
case "place_of_worship" -> nullIfEmpty(element.religion());

View File

@@ -174,6 +174,7 @@ public class Transportation implements
entry(FieldValues.CLASS_RACEWAY, 12),
entry(FieldValues.CLASS_TERTIARY, 11),
entry(FieldValues.CLASS_BUSWAY, 11),
entry(FieldValues.CLASS_BUS_GUIDEWAY, 11),
entry(FieldValues.CLASS_SECONDARY, 9),
entry(FieldValues.CLASS_PRIMARY, 7),
entry(FieldValues.CLASS_TRUNK, 5),

View File

@@ -112,8 +112,7 @@ public class Water implements
@Override
public void process(Tables.OsmWaterPolygon element, FeatureCollector features) {
if (!"bay".equals(element.natural())) {
String clazz = "riverbank".equals(element.waterway()) ? FieldValues.CLASS_RIVER :
classMapping.getOrElse(element.source(), FieldValues.CLASS_LAKE);
String clazz = classMapping.getOrElse(element.source(), FieldValues.CLASS_LAKE);
features.polygon(LAYER_NAME)
.setBufferPixels(BUFFER_SIZE)
.setMinPixelSizeBelowZoom(11, 2)