Skip to content

Commit 7247971

Browse files
msbarrylazaa32
authored andcommitted
Upgrade basemap profile to OpenMapTiles v3.13.1 (#227)
1 parent b786e0b commit 7247971

File tree

9 files changed

+175
-81
lines changed

9 files changed

+175
-81
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@ To run `Generate.java`, use [scripts/regenerate-openmaptiles.sh](https://github.
4141
OpenMapTiles release tag:
4242

4343
```bash
44-
./scripts/regenerate-openmaptiles.sh v3.13
44+
./scripts/regenerate-openmaptiles.sh v3.13.1
4545
```
4646

4747
Then follow the instructions it prints for reformatting generated code.
4848

4949
If you want to regenerate from a different repository than the default openmaptiles, you can specify the url like this:
5050

5151
```bash
52-
./scripts/regenerate-openmaptiles.sh v3.13 https://raw.githubusercontent.com/openmaptiles/openmaptiles/
52+
./scripts/regenerate-openmaptiles.sh v3.13.1 https://raw.githubusercontent.com/openmaptiles/openmaptiles/
5353
```
5454

5555
## License

src/main/java/com/onthegomap/planetiler/openmaptiles/Generate.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ static JsonNode parseYaml(String string) {
128128
public static void main(String[] args) throws IOException {
129129
Arguments arguments = Arguments.fromArgsOrConfigFile(args);
130130
PlanetilerConfig planetilerConfig = PlanetilerConfig.from(arguments);
131-
String tag = arguments.getString("tag", "openmaptiles tag to use", "v3.13");
131+
String tag = arguments.getString("tag", "openmaptiles tag to use", "v3.13.1");
132132
String baseUrl = arguments.getString("base-url", "the url used to download the openmaptiles.yml",
133133
"https://raw.githubusercontent.com/openmaptiles/openmaptiles/");
134134
String base = baseUrl + tag + "/";

src/main/java/com/onthegomap/planetiler/openmaptiles/generated/OpenMapTilesSchema.java

Lines changed: 67 additions & 49 deletions
Large diffs are not rendered by default.

src/main/java/com/onthegomap/planetiler/openmaptiles/generated/Tables.java

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
5050

5151
/**
5252
* OSM element parsers generated from the <a href="https://github.com/omniscale/imposm3">imposm3</a> table definitions
53-
* in the <a href="https://github.com/openmaptiles/openmaptiles/blob/v3.13/openmaptiles.yaml">OpenMapTiles vector tile
53+
* in the <a href="https://github.com/openmaptiles/openmaptiles/blob/v3.13.1/openmaptiles.yaml">OpenMapTiles vector tile
5454
* schema</a>.
5555
*
5656
* These filter and parse the raw OSM key/value attribute pairs on tags into records with fields that match the columns
@@ -94,15 +94,15 @@ public record RowHandlerAndClass<T extends Row> (
9494
) {}
9595
/** An OSM element that would appear in the {@code osm_water_polygon} table generated by imposm3. */
9696
public record OsmWaterPolygon(@Override String name, @Override String nameEn, @Override String nameDe,
97-
@Override String natural, @Override String landuse, @Override String waterway, @Override String water,
98-
@Override boolean isIntermittent, @Override boolean isTunnel, @Override boolean isBridge,
97+
@Override String natural, @Override String landuse, @Override String waterway, @Override String leisure,
98+
@Override String water, @Override boolean isIntermittent, @Override boolean isTunnel, @Override boolean isBridge,
9999
@Override SourceFeature source) implements Row, WithName, WithNameEn, WithNameDe, WithNatural, WithLanduse,
100-
WithWaterway, WithWater, WithIsIntermittent, WithIsTunnel, WithIsBridge, WithSource {
100+
WithWaterway, WithLeisure, WithWater, WithIsIntermittent, WithIsTunnel, WithIsBridge, WithSource {
101101
public OsmWaterPolygon(SourceFeature source, String mappingKey) {
102102
this(source.getString("name"), source.getString("name:en"), source.getString("name:de"),
103103
source.getString("natural"), source.getString("landuse"), source.getString("waterway"),
104-
source.getString("water"), source.getBoolean("intermittent"), source.getBoolean("tunnel"),
105-
source.getBoolean("bridge"), source);
104+
source.getString("leisure"), source.getString("water"), source.getBoolean("intermittent"),
105+
source.getBoolean("tunnel"), source.getBoolean("bridge"), source);
106106
}
107107

108108
/** Imposm3 "mapping" to filter OSM elements that should appear in this "table". */
@@ -405,8 +405,8 @@ public OsmAerialwayLinestring(SourceFeature source, String mappingKey) {
405405
}
406406

407407
/** Imposm3 "mapping" to filter OSM elements that should appear in this "table". */
408-
public static final Expression MAPPING =
409-
and(matchAny("aerialway", "cable_car", "gondola"), matchType("linestring"));
408+
public static final Expression MAPPING = and(matchAny("aerialway", "chair_lift", "drag_lift", "platter", "t-bar",
409+
"gondola", "cable_car", "j-bar", "mixed_lift"), matchType("linestring"));
410410

411411
/**
412412
* Interface for layer implementations to extend to subscribe to OSM elements filtered and parsed as
@@ -691,20 +691,21 @@ public interface Handler {
691691
public record OsmPoiPoint(@Override String name, @Override String nameEn, @Override String nameDe,
692692
@Override String subclass, @Override String mappingKey, @Override String station, @Override String funicular,
693693
@Override String information, @Override String uicRef, @Override String religion, @Override long level,
694-
@Override boolean indoor, @Override long layer, @Override String sport, @Override SourceFeature source)
695-
implements Row, WithName, WithNameEn, WithNameDe, WithSubclass, WithMappingKey, WithStation, WithFunicular,
696-
WithInformation, WithUicRef, WithReligion, WithLevel, WithIndoor, WithLayer, WithSport, WithSource {
694+
@Override boolean indoor, @Override long layer, @Override String sport, @Override String operator,
695+
@Override String network, @Override SourceFeature source) implements Row, WithName, WithNameEn, WithNameDe,
696+
WithSubclass, WithMappingKey, WithStation, WithFunicular, WithInformation, WithUicRef, WithReligion, WithLevel,
697+
WithIndoor, WithLayer, WithSport, WithOperator, WithNetwork, WithSource {
697698
public OsmPoiPoint(SourceFeature source, String mappingKey) {
698699
this(source.getString("name"), source.getString("name:en"), source.getString("name:de"),
699700
source.getString(mappingKey), mappingKey, source.getString("station"), source.getString("funicular"),
700701
source.getString("information"), source.getString("uic_ref"), source.getString("religion"),
701702
source.getLong("level"), source.getBoolean("indoor"), source.getLong("layer"), source.getString("sport"),
702-
source);
703+
source.getString("operator"), source.getString("network"), source);
703704
}
704705

705706
/** Imposm3 "mapping" to filter OSM elements that should appear in this "table". */
706707
public static final Expression MAPPING = and(or(matchAny("aerialway", "station"),
707-
matchAny("amenity", "arts_centre", "bank", "bar", "bbq", "bicycle_parking", "bicycle_rental", "biergarten",
708+
matchAny("amenity", "arts_centre", "atm", "bank", "bar", "bbq", "bicycle_parking", "bicycle_rental", "biergarten",
708709
"bus_station", "cafe", "cinema", "clinic", "college", "community_centre", "courthouse", "dentist", "doctors",
709710
"drinking_water", "fast_food", "ferry_terminal", "fire_station", "food_court", "fuel", "grave_yard", "hospital",
710711
"ice_cream", "kindergarten", "library", "marketplace", "motorcycle_parking", "nightclub", "nursing_home",
@@ -758,20 +759,21 @@ public interface Handler {
758759
public record OsmPoiPolygon(@Override String name, @Override String nameEn, @Override String nameDe,
759760
@Override String subclass, @Override String mappingKey, @Override String station, @Override String funicular,
760761
@Override String information, @Override String uicRef, @Override String religion, @Override long level,
761-
@Override boolean indoor, @Override long layer, @Override String sport, @Override SourceFeature source)
762-
implements Row, WithName, WithNameEn, WithNameDe, WithSubclass, WithMappingKey, WithStation, WithFunicular,
763-
WithInformation, WithUicRef, WithReligion, WithLevel, WithIndoor, WithLayer, WithSport, WithSource {
762+
@Override boolean indoor, @Override long layer, @Override String sport, @Override String operator,
763+
@Override String network, @Override SourceFeature source) implements Row, WithName, WithNameEn, WithNameDe,
764+
WithSubclass, WithMappingKey, WithStation, WithFunicular, WithInformation, WithUicRef, WithReligion, WithLevel,
765+
WithIndoor, WithLayer, WithSport, WithOperator, WithNetwork, WithSource {
764766
public OsmPoiPolygon(SourceFeature source, String mappingKey) {
765767
this(source.getString("name"), source.getString("name:en"), source.getString("name:de"),
766768
source.getString(mappingKey), mappingKey, source.getString("station"), source.getString("funicular"),
767769
source.getString("information"), source.getString("uic_ref"), source.getString("religion"),
768770
source.getLong("level"), source.getBoolean("indoor"), source.getLong("layer"), source.getString("sport"),
769-
source);
771+
source.getString("operator"), source.getString("network"), source);
770772
}
771773

772774
/** Imposm3 "mapping" to filter OSM elements that should appear in this "table". */
773775
public static final Expression MAPPING = and(or(matchAny("aerialway", "station"),
774-
matchAny("amenity", "arts_centre", "bank", "bar", "bbq", "bicycle_parking", "bicycle_rental", "biergarten",
776+
matchAny("amenity", "arts_centre", "atm", "bank", "bar", "bbq", "bicycle_parking", "bicycle_rental", "biergarten",
775777
"bus_station", "cafe", "cinema", "clinic", "college", "community_centre", "courthouse", "dentist", "doctors",
776778
"drinking_water", "fast_food", "ferry_terminal", "fire_station", "food_court", "fuel", "grave_yard", "hospital",
777779
"ice_cream", "kindergarten", "library", "marketplace", "motorcycle_parking", "nightclub", "nursing_home",
@@ -1144,6 +1146,11 @@ public interface WithNetwork {
11441146
String network();
11451147
}
11461148

1149+
/** Rows with a String operator attribute. */
1150+
public interface WithOperator {
1151+
String operator();
1152+
}
1153+
11471154
/** Rows with a String osmcSymbol attribute. */
11481155
public interface WithOsmcSymbol {
11491156
String osmcSymbol();

src/main/java/com/onthegomap/planetiler/openmaptiles/layers/Poi.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
4343

4444
import com.carrotsearch.hppc.LongIntMap;
4545
import com.onthegomap.planetiler.FeatureCollector;
46+
import com.onthegomap.planetiler.ForwardingProfile;
4647
import com.onthegomap.planetiler.VectorTile;
47-
import com.onthegomap.planetiler.openmaptiles.OpenMapTilesProfile;
4848
import com.onthegomap.planetiler.openmaptiles.generated.OpenMapTilesSchema;
4949
import com.onthegomap.planetiler.openmaptiles.generated.Tables;
5050
import com.onthegomap.planetiler.openmaptiles.util.LanguageUtils;
@@ -68,7 +68,7 @@ public class Poi implements
6868
OpenMapTilesSchema.Poi,
6969
Tables.OsmPoiPoint.Handler,
7070
Tables.OsmPoiPolygon.Handler,
71-
OpenMapTilesProfile.FeaturePostProcessor {
71+
ForwardingProfile.FeaturePostProcessor {
7272

7373
/*
7474
* process() creates the raw POI feature from OSM elements and postProcess()
@@ -136,7 +136,7 @@ public void process(Tables.OsmPoiPolygon element, FeatureCollector features) {
136136
setupPoiFeature(element, features.centroidIfConvex(LAYER_NAME));
137137
}
138138

139-
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> void setupPoiFeature(
139+
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(
140140
T element, FeatureCollector.Feature output) {
141141
String rawSubclass = element.subclass();
142142
if ("station".equals(rawSubclass) && "subway".equals(element.station())) {
@@ -146,6 +146,16 @@ private <T extends Tables.WithSubclass & Tables.WithStation & Tables.WithFunicul
146146
rawSubclass = "halt";
147147
}
148148

149+
// ATM names fall back to operator, or else network
150+
String name = element.name();
151+
var tags = element.source().tags();
152+
if ("atm".equals(rawSubclass) && nullOrEmpty(name)) {
153+
name = coalesce(nullIfEmpty(element.operator()), nullIfEmpty(element.network()));
154+
if (name != null) {
155+
tags.put("name", name);
156+
}
157+
}
158+
149159
String subclass = switch (rawSubclass) {
150160
case "information" -> nullIfEmpty(element.information());
151161
case "place_of_worship" -> nullIfEmpty(element.religion());
@@ -154,7 +164,7 @@ private <T extends Tables.WithSubclass & Tables.WithStation & Tables.WithFunicul
154164
};
155165
String poiClass = poiClass(rawSubclass, element.mappingKey());
156166
int poiClassRank = poiClassRank(poiClass);
157-
int rankOrder = poiClassRank + ((nullOrEmpty(element.name())) ? 2000 : 0);
167+
int rankOrder = poiClassRank + ((nullOrEmpty(name)) ? 2000 : 0);
158168

159169
output.setBufferPixels(BUFFER_SIZE)
160170
.setAttr(Fields.CLASS, poiClass)

src/main/java/com/onthegomap/planetiler/openmaptiles/layers/Water.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ record WaterInfo(int minZoom, int maxZoom, String clazz) {}
7979
case "ne_50m_ocean" -> new WaterInfo(2, 4, FieldValues.CLASS_OCEAN);
8080
case "ne_10m_ocean" -> new WaterInfo(5, 5, FieldValues.CLASS_OCEAN);
8181

82+
// TODO: get OSM ID from low-zoom natural earth lakes
8283
case "ne_110m_lakes" -> new WaterInfo(0, 1, FieldValues.CLASS_LAKE);
8384
case "ne_50m_lakes" -> new WaterInfo(2, 3, FieldValues.CLASS_LAKE);
8485
case "ne_10m_lakes" -> new WaterInfo(4, 5, FieldValues.CLASS_LAKE);
@@ -109,6 +110,7 @@ public void process(Tables.OsmWaterPolygon element, FeatureCollector features) {
109110
.setBufferPixels(BUFFER_SIZE)
110111
.setMinPixelSizeBelowZoom(11, 2)
111112
.setMinZoom(6)
113+
.setAttr(Fields.ID, element.source().id())
112114
.setAttr(Fields.INTERMITTENT, element.isIntermittent() ? 1 : 0)
113115
.setAttrWithMinzoom(Fields.BRUNNEL, Utils.brunnel(element.isBridge(), element.isTunnel()), 12)
114116
.setAttr(Fields.CLASS, clazz);

src/test/java/com/onthegomap/planetiler/openmaptiles/layers/PoiTest.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,4 +207,34 @@ void testLocksmith() {
207207
"name", "The Locksmith"
208208
))));
209209
}
210+
211+
@Test
212+
void testAtm() {
213+
List<Map<String, Object>> expected = List.of(Map.of(
214+
"_layer", "poi",
215+
"class", "atm",
216+
"subclass", "atm",
217+
"name", "ATM name"
218+
));
219+
// prefer name, otherwise fall back to operator, or else network
220+
assertFeatures(14, expected, process(pointFeature(Map.of(
221+
"amenity", "atm",
222+
"name", "ATM name"
223+
))));
224+
assertFeatures(14, expected, process(pointFeature(Map.of(
225+
"amenity", "atm",
226+
"name", "ATM name",
227+
"operator", "ATM operator",
228+
"network", "ATM network"
229+
))));
230+
assertFeatures(14, expected, process(pointFeature(Map.of(
231+
"amenity", "atm",
232+
"operator", "ATM name",
233+
"network", "ATM network"
234+
))));
235+
assertFeatures(14, expected, process(pointFeature(Map.of(
236+
"amenity", "atm",
237+
"network", "ATM name"
238+
))));
239+
}
210240
}

src/test/java/com/onthegomap/planetiler/openmaptiles/layers/TransportationTest.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import java.util.Map;
2020
import java.util.stream.Stream;
2121
import org.junit.jupiter.api.Test;
22+
import org.junit.jupiter.params.ParameterizedTest;
23+
import org.junit.jupiter.params.provider.ValueSource;
2224

2325
class TransportationTest extends AbstractLayerTest {
2426

@@ -1061,32 +1063,33 @@ void testNarrowGauge() {
10611063
))));
10621064
}
10631065

1064-
@Test
1065-
void testAerialway() {
1066+
@ParameterizedTest
1067+
@ValueSource(strings = {"gondola", "chair_lift", "j-bar", "mixed_lift"})
1068+
void testAerialway(String aerialway) {
10661069
assertFeatures(12, List.of(Map.of(
10671070
"_layer", "transportation",
10681071
"class", "aerialway",
1069-
"subclass", "gondola",
1072+
"subclass", aerialway,
10701073

10711074
"_minzoom", 12,
10721075
"_maxzoom", 14,
10731076
"_type", "line"
10741077
), Map.of(
10751078
"_layer", "transportation_name",
10761079
"class", "aerialway",
1077-
"subclass", "gondola",
1080+
"subclass", aerialway,
10781081
"name", "Summit Gondola",
10791082

10801083
"_minzoom", 12,
10811084
"_maxzoom", 14,
10821085
"_type", "line"
10831086
)), process(lineFeature(Map.of(
1084-
"aerialway", "gondola",
1087+
"aerialway", aerialway,
10851088
"name", "Summit Gondola"
10861089
))));
10871090
assertFeatures(10, List.of(),
10881091
process(polygonFeature(Map.of(
1089-
"aerialway", "gondola",
1092+
"aerialway", aerialway,
10901093
"name", "Summit Gondola"
10911094
))));
10921095
}

src/test/java/com/onthegomap/planetiler/openmaptiles/layers/WaterTest.java

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
import static com.onthegomap.planetiler.openmaptiles.OpenMapTilesProfile.OSM_SOURCE;
66
import static com.onthegomap.planetiler.openmaptiles.OpenMapTilesProfile.WATER_POLYGON_SOURCE;
77

8+
import com.onthegomap.planetiler.geo.GeoUtils;
89
import com.onthegomap.planetiler.reader.SimpleFeature;
10+
import java.util.HashMap;
911
import java.util.List;
1012
import java.util.Map;
1113
import org.junit.jupiter.api.Test;
@@ -88,6 +90,28 @@ void testWaterOsmWaterPolygon() {
8890
)));
8991
}
9092

93+
@Test
94+
void testWaterOsmId() {
95+
long id = 123;
96+
assertFeatures(14, List.of(Map.of(
97+
"class", "lake",
98+
"id", id,
99+
"_layer", "water",
100+
"_type", "polygon",
101+
"_minzoom", 6,
102+
"_maxzoom", 14
103+
)), process(SimpleFeature.create(
104+
GeoUtils.worldToLatLonCoords(rectangle(0, Math.sqrt(1))),
105+
new HashMap<>(Map.<String, Object>of(
106+
"natural", "water",
107+
"water", "reservoir"
108+
)),
109+
OSM_SOURCE,
110+
null,
111+
id
112+
)));
113+
}
114+
91115
@Test
92116
void testWater() {
93117
assertFeatures(14, List.of(Map.of(
@@ -103,7 +127,7 @@ void testWater() {
103127
assertFeatures(14, List.of(
104128
Map.of("_layer", "poi"),
105129
Map.of(
106-
"class", "lake",
130+
"class", "swimming_pool",
107131

108132
"_layer", "water",
109133
"_type", "polygon",

0 commit comments

Comments
 (0)