Skip to content

Commit 8fcf166

Browse files
Simplify park classes (#318)
* planetiler version bumped from 0.10.0 to 0.10.2 * regenerate from YAML in master branch * regenerate-openmaptiles.sh master (hence includes both openmaptiles/pull/1491 and openmaptiles/pull/1779) * initial port of openmaptiles/pull/1491 * clean-up: mvn spotless:apply * added test to check classes of protected areas * aboriginal_lands now generated also as park * aboriginal_lands now generated also as park
1 parent c68a5da commit 8fcf166

8 files changed

Lines changed: 237 additions & 58 deletions

File tree

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1010
<maven.compiler.source>21</maven.compiler.source>
1111
<maven.compiler.target>21</maven.compiler.target>
12-
<planetiler.version>0.10.0</planetiler.version>
12+
<planetiler.version>0.10.2</planetiler.version>
1313
<junit.version>6.0.3</junit.version>
1414

1515
<mainClass>org.openmaptiles.OpenMapTilesMain</mainClass>

scripts/regenerate-openmaptiles.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ set -o errexit
44
set -o pipefail
55
set -o nounset
66

7-
TAG="${1:-"v3.16"}"
7+
# TODO: change to "v3.17" once that is released
8+
TAG="${1:-"master"}"
89
echo "tag=${TAG}"
910

1011
BASE_URL="${2:-"https://raw.githubusercontent.com/openmaptiles/openmaptiles/"}"

src/main/java/org/openmaptiles/generated/OpenMapTilesSchema.java

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

5050
/**
5151
* All vector tile layer definitions, attributes, and allowed values generated from the
52-
* <a href="https://github.com/openmaptiles/openmaptiles/blob/v3.16/openmaptiles.yaml">OpenMapTiles vector tile schema
53-
* v3.16</a>.
52+
* <a href="https://github.com/openmaptiles/openmaptiles/blob/master/openmaptiles.yaml">OpenMapTiles vector tile schema
53+
* master</a>.
5454
*/
5555
@SuppressWarnings("unused")
5656
public class OpenMapTilesSchema {
@@ -96,7 +96,7 @@ public static List<Layer> createInstances(Translations translations, PlanetilerC
9696
* boundaries show up. So you might not be able to use border styling for ocean water features.
9797
*
9898
* Generated from
99-
* <a href="https://github.com/openmaptiles/openmaptiles/blob/v3.16/layers/water/water.yaml">water.yaml</a>
99+
* <a href="https://github.com/openmaptiles/openmaptiles/blob/master/layers/water/water.yaml">water.yaml</a>
100100
*/
101101
public interface Water extends Layer {
102102
double BUFFER_SIZE = 4.0;
@@ -195,7 +195,7 @@ final class FieldMappings {
195195
* field applied. Waterways do not have a <code>subclass</code> field.
196196
*
197197
* Generated from
198-
* <a href="https://github.com/openmaptiles/openmaptiles/blob/v3.16/layers/waterway/waterway.yaml">waterway.yaml</a>
198+
* <a href="https://github.com/openmaptiles/openmaptiles/blob/master/layers/waterway/waterway.yaml">waterway.yaml</a>
199199
*/
200200
public interface Waterway extends Layer {
201201
double BUFFER_SIZE = 4.0;
@@ -287,7 +287,7 @@ final class FieldMappings {
287287
* layer is to style wood (<code>class=wood</code>) and grass (<code>class=grass</code>) areas.
288288
*
289289
* Generated from <a href=
290-
* "https://github.com/openmaptiles/openmaptiles/blob/v3.16/layers/landcover/landcover.yaml">landcover.yaml</a>
290+
* "https://github.com/openmaptiles/openmaptiles/blob/master/layers/landcover/landcover.yaml">landcover.yaml</a>
291291
*/
292292
public interface Landcover extends Layer {
293293
double BUFFER_SIZE = 4.0;
@@ -446,7 +446,7 @@ final class FieldMappings {
446446
* residential (urban) areas and at higher zoom levels mostly OSM <code>landuse</code> tags.
447447
*
448448
* Generated from
449-
* <a href="https://github.com/openmaptiles/openmaptiles/blob/v3.16/layers/landuse/landuse.yaml">landuse.yaml</a>
449+
* <a href="https://github.com/openmaptiles/openmaptiles/blob/master/layers/landuse/landuse.yaml">landuse.yaml</a>
450450
*/
451451
public interface Landuse extends Layer {
452452
double BUFFER_SIZE = 4.0;
@@ -542,7 +542,7 @@ final class FieldMappings {
542542
* <a href="http://wiki.openstreetmap.org/wiki/Tag:natural%3Dpeak">Natural peaks</a>
543543
*
544544
* Generated from <a href=
545-
* "https://github.com/openmaptiles/openmaptiles/blob/v3.16/layers/mountain_peak/mountain_peak.yaml">mountain_peak.yaml</a>
545+
* "https://github.com/openmaptiles/openmaptiles/blob/master/layers/mountain_peak/mountain_peak.yaml">mountain_peak.yaml</a>
546546
*/
547547
public interface MountainPeak extends Layer {
548548
double BUFFER_SIZE = 64.0;
@@ -619,14 +619,15 @@ final class FieldMappings {
619619
}
620620
}
621621
/**
622-
* The park layer in OpenMapTiles contains natural and protected areas from OpenStreetMap, such as parks tagged with
623-
* <a href="https://wiki.openstreetmap.org/wiki/Tag:boundary%3Dnational_park"><code>boundary=national_park</code></a>,
622+
* The park layer contains large area features from OpenStreetMap tagged with
623+
* <a href="http://wiki.openstreetmap.org/wiki/Tag:boundary%3Dnational_park"><code>boundary=national_park</code></a>,
624624
* <a href=
625-
* "https://wiki.openstreetmap.org/wiki/Tag:boundary%3Dprotected_area"><code>boundary=protected_area</code></a>, or
626-
* <a href="https://wiki.openstreetmap.org/wiki/Tag:leisure%3Dnature_reserve"><code>leisure=nature_reserve</code></a>.
625+
* "http://wiki.openstreetmap.org/wiki/Tag:boundary%3Dprotected_area"><code>boundary=protected_area</code></a>,
626+
* <a href="http://wiki.openstreetmap.org/wiki/Tag:leisure%3Dnature_reserve"><code>leisure=nature_reserve</code></a>,
627+
* or select values of <a href="http://wiki.openstreetmap.org/wiki/Key:historic"><code>historic= </code></a>.
627628
*
628629
* Generated from
629-
* <a href="https://github.com/openmaptiles/openmaptiles/blob/v3.16/layers/park/park.yaml">park.yaml</a>
630+
* <a href="https://github.com/openmaptiles/openmaptiles/blob/master/layers/park/park.yaml">park.yaml</a>
630631
*/
631632
public interface Park extends Layer {
632633
double BUFFER_SIZE = 4.0;
@@ -641,10 +642,12 @@ default String name() {
641642
final class Fields {
642643
/**
643644
* Use the <strong>class</strong> to differentiate between different kinds of features in the <code>parks</code>
644-
* layer. The class for <code>boundary=protected_area</code> parks is the lower-case of the
645-
* <a href="http://wiki.openstreetmap.org/wiki/key:protection_title"><code>protection_title</code></a> value with
646-
* blanks replaced by <code>_</code>. <code>national_park</code> is the class of
647-
* <code>protection_title=National Park</code> and <code>boundary=national_park</code>.
645+
* layer. For <code>boundary=protected_area</code> parks, the class is determined by the
646+
* <a href="http://wiki.openstreetmap.org/wiki/key:protected_area"><code>protected_area</code></a> tag value,
647+
* falling back to the
648+
* <a href="http://wiki.openstreetmap.org/wiki/key:protection_title"><code>protection_title</code></a> value if
649+
* not present, and defaulting to <code>protected_area</code> if neither is available. <code>national_park</code>
650+
* is the class of <code>protection_title=National Park</code> and <code>boundary=national_park</code>.
648651
* <code>nature_reserve</code> is the class of <code>protection_title=Nature Reserve</code> and
649652
* <code>leisure=nature_reserve</code>. The class for other
650653
* <a href="http://wiki.openstreetmap.org/wiki/key:protection_title"><code>protection_title</code></a> values is
@@ -689,7 +692,7 @@ final class FieldMappings {
689692
* but for most styles it makes sense to just style <code>admin_level=2</code> and <code>admin_level=4</code>.
690693
*
691694
* Generated from
692-
* <a href="https://github.com/openmaptiles/openmaptiles/blob/v3.16/layers/boundary/boundary.yaml">boundary.yaml</a>
695+
* <a href="https://github.com/openmaptiles/openmaptiles/blob/master/layers/boundary/boundary.yaml">boundary.yaml</a>
693696
*/
694697
public interface Boundary extends Layer {
695698
double BUFFER_SIZE = 4.0;
@@ -799,7 +802,7 @@ final class FieldMappings {
799802
* in the <strong>aeroway</strong> layer.
800803
*
801804
* Generated from
802-
* <a href="https://github.com/openmaptiles/openmaptiles/blob/v3.16/layers/aeroway/aeroway.yaml">aeroway.yaml</a>
805+
* <a href="https://github.com/openmaptiles/openmaptiles/blob/master/layers/aeroway/aeroway.yaml">aeroway.yaml</a>
803806
*/
804807
public interface Aeroway extends Layer {
805808
double BUFFER_SIZE = 4.0;
@@ -859,7 +862,7 @@ final class FieldMappings {
859862
* features like plazas.
860863
*
861864
* Generated from <a href=
862-
* "https://github.com/openmaptiles/openmaptiles/blob/v3.16/layers/transportation/transportation.yaml">transportation.yaml</a>
865+
* "https://github.com/openmaptiles/openmaptiles/blob/master/layers/transportation/transportation.yaml">transportation.yaml</a>
863866
*/
864867
public interface Transportation extends Layer {
865868
double BUFFER_SIZE = 4.0;
@@ -1215,7 +1218,7 @@ final class FieldMappings {
12151218
* location:underground are excluded.
12161219
*
12171220
* Generated from
1218-
* <a href="https://github.com/openmaptiles/openmaptiles/blob/v3.16/layers/building/building.yaml">building.yaml</a>
1221+
* <a href="https://github.com/openmaptiles/openmaptiles/blob/master/layers/building/building.yaml">building.yaml</a>
12191222
*/
12201223
public interface Building extends Layer {
12211224
double BUFFER_SIZE = 4.0;
@@ -1257,7 +1260,7 @@ final class FieldMappings {
12571260
* from OSM water bodies. Only the most important lakes contain labels.
12581261
*
12591262
* Generated from <a href=
1260-
* "https://github.com/openmaptiles/openmaptiles/blob/v3.16/layers/water_name/water_name.yaml">water_name.yaml</a>
1263+
* "https://github.com/openmaptiles/openmaptiles/blob/master/layers/water_name/water_name.yaml">water_name.yaml</a>
12611264
*/
12621265
public interface WaterName extends Layer {
12631266
double BUFFER_SIZE = 256.0;
@@ -1334,7 +1337,7 @@ final class FieldMappings {
13341337
* while for other roads you should use <code>name</code>.
13351338
*
13361339
* Generated from <a href=
1337-
* "https://github.com/openmaptiles/openmaptiles/blob/v3.16/layers/transportation_name/transportation_name.yaml">transportation_name.yaml</a>
1340+
* "https://github.com/openmaptiles/openmaptiles/blob/master/layers/transportation_name/transportation_name.yaml">transportation_name.yaml</a>
13381341
*/
13391342
public interface TransportationName extends Layer {
13401343
double BUFFER_SIZE = 8.0;
@@ -1606,7 +1609,7 @@ final class FieldMappings {
16061609
* create a text hierarchy.
16071610
*
16081611
* Generated from
1609-
* <a href="https://github.com/openmaptiles/openmaptiles/blob/v3.16/layers/place/place.yaml">place.yaml</a>
1612+
* <a href="https://github.com/openmaptiles/openmaptiles/blob/master/layers/place/place.yaml">place.yaml</a>
16101613
*/
16111614
public interface Place extends Layer {
16121615
double BUFFER_SIZE = 256.0;
@@ -1730,7 +1733,7 @@ final class FieldMappings {
17301733
* tag are prioritized for preservation).
17311734
*
17321735
* Generated from <a href=
1733-
* "https://github.com/openmaptiles/openmaptiles/blob/v3.16/layers/housenumber/housenumber.yaml">housenumber.yaml</a>
1736+
* "https://github.com/openmaptiles/openmaptiles/blob/master/layers/housenumber/housenumber.yaml">housenumber.yaml</a>
17341737
*/
17351738
public interface Housenumber extends Layer {
17361739
double BUFFER_SIZE = 8.0;
@@ -1762,7 +1765,7 @@ final class FieldMappings {
17621765
* <a href="http://wiki.openstreetmap.org/wiki/Points_of_interest">Points of interests</a> containing a of a variety
17631766
* of OpenStreetMap tags. Mostly contains amenities, sport, shop and tourist POIs.
17641767
*
1765-
* Generated from <a href="https://github.com/openmaptiles/openmaptiles/blob/v3.16/layers/poi/poi.yaml">poi.yaml</a>
1768+
* Generated from <a href="https://github.com/openmaptiles/openmaptiles/blob/master/layers/poi/poi.yaml">poi.yaml</a>
17661769
*/
17671770
public interface Poi extends Layer {
17681771
double BUFFER_SIZE = 64.0;
@@ -1835,6 +1838,7 @@ final class Fields {
18351838
* <li>castle
18361839
* <li>atm
18371840
* <li>fuel
1841+
* <li>zoo
18381842
* </ul>
18391843
*/
18401844
public static final String CLASS = "class";
@@ -1854,9 +1858,10 @@ final class Fields {
18541858
* <a href="http://wiki.openstreetmap.org/wiki/Key:aerialway"><code>aerialway</code></a>,
18551859
* <a href="http://wiki.openstreetmap.org/wiki/Key:building"><code>building</code></a>,
18561860
* <a href="http://wiki.openstreetmap.org/wiki/Key:highway"><code>highway</code></a>,
1857-
* <a href="https://wiki.openstreetmap.org/wiki/Key:office"><code>office</code></a> or
1858-
* <a href="http://wiki.openstreetmap.org/wiki/Key:waterway"><code>waterway</code></a> tag. Use this to do more
1859-
* precise styling.
1861+
* <a href="https://wiki.openstreetmap.org/wiki/Key:office"><code>office</code></a>,
1862+
* <a href="http://wiki.openstreetmap.org/wiki/Key:waterway"><code>waterway</code></a> or
1863+
* <a href="http://wiki.openstreetmap.org/wiki/Key:zoo"><code>zoo</code></a> tag. Use this to do more precise
1864+
* styling.
18601865
*/
18611866
public static final String SUBCLASS = "subclass";
18621867
/**
@@ -1932,10 +1937,12 @@ final class FieldValues {
19321937
public static final String CLASS_CASTLE = "castle";
19331938
public static final String CLASS_ATM = "atm";
19341939
public static final String CLASS_FUEL = "fuel";
1935-
public static final Set<String> CLASS_VALUES = Set.of("shop", "office", "town_hall", "golf", "fast_food", "park",
1936-
"bus", "railway", "aerialway", "entrance", "campsite", "laundry", "grocery", "library", "college", "lodging",
1937-
"ice_cream", "post", "cafe", "school", "alcohol_shop", "bar", "harbor", "car", "hospital", "cemetery",
1938-
"attraction", "beer", "music", "stadium", "art_gallery", "clothing_store", "swimming", "castle", "atm", "fuel");
1940+
public static final String CLASS_ZOO = "zoo";
1941+
public static final Set<String> CLASS_VALUES =
1942+
Set.of("shop", "office", "town_hall", "golf", "fast_food", "park", "bus", "railway", "aerialway", "entrance",
1943+
"campsite", "laundry", "grocery", "library", "college", "lodging", "ice_cream", "post", "cafe", "school",
1944+
"alcohol_shop", "bar", "harbor", "car", "hospital", "cemetery", "attraction", "beer", "music", "stadium",
1945+
"art_gallery", "clothing_store", "swimming", "castle", "atm", "fuel", "zoo");
19391946
}
19401947
/** Complex mappings to generate attribute values from OSM element tags in the poi layer. */
19411948
final class FieldMappings {
@@ -1999,14 +2006,16 @@ final class FieldMappings {
19992006
MultiExpression.entry("swimming", matchAny("subclass", "swimming_area", "swimming")),
20002007
MultiExpression.entry("castle", matchAny("subclass", "castle", "ruins")),
20012008
MultiExpression.entry("atm", matchAny("subclass", "atm")),
2002-
MultiExpression.entry("fuel", matchAny("subclass", "fuel", "charging_station"))));
2009+
MultiExpression.entry("fuel", matchAny("subclass", "fuel", "charging_station")),
2010+
MultiExpression.entry("zoo", matchAny("subclass", "zoo", "enclosure'", "petting_zoo", "aviary", "wildlife_park",
2011+
"birds", "safari_park", "butterfly", "falconry", "reptile", "terrarium"))));
20032012
}
20042013
}
20052014
/**
20062015
* <a href="http://wiki.openstreetmap.org/wiki/Tag:aeroway%3Daerodrome">Aerodrome labels</a>
20072016
*
20082017
* Generated from <a href=
2009-
* "https://github.com/openmaptiles/openmaptiles/blob/v3.16/layers/aerodrome_label/aerodrome_label.yaml">aerodrome_label.yaml</a>
2018+
* "https://github.com/openmaptiles/openmaptiles/blob/master/layers/aerodrome_label/aerodrome_label.yaml">aerodrome_label.yaml</a>
20102019
*/
20112020
public interface AerodromeLabel extends Layer {
20122021
double BUFFER_SIZE = 64.0;

src/main/java/org/openmaptiles/generated/Tables.java

Lines changed: 35 additions & 8 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.16/openmaptiles.yaml">OpenMapTiles vector tile
53+
* in the <a href="https://github.com/openmaptiles/openmaptiles/blob/master/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
@@ -238,19 +238,22 @@ public interface Handler {
238238
}
239239
/** An OSM element that would appear in the {@code osm_park_polygon} table generated by imposm3. */
240240
public record OsmParkPolygon(@Override String name, @Override String nameEn, @Override String nameDe,
241-
@Override String landuse, @Override String leisure, @Override String boundary, @Override String protectionTitle,
242-
@Override SourceFeature source) implements Row, WithName, WithNameEn, WithNameDe, WithLanduse, WithLeisure,
243-
WithBoundary, WithProtectionTitle, WithSource {
241+
@Override String landuse, @Override String leisure, @Override String boundary, @Override String protectedArea,
242+
@Override String protectClass, @Override String protectionTitle, @Override String historic,
243+
@Override boolean maritime, @Override SourceFeature source)
244+
implements Row, WithName, WithNameEn, WithNameDe, WithLanduse, WithLeisure, WithBoundary, WithProtectedArea,
245+
WithProtectClass, WithProtectionTitle, WithHistoric, WithMaritime, WithSource {
244246
public OsmParkPolygon(SourceFeature source, String mappingKey) {
245247
this(source.getString("name"), source.getString("name:en"), source.getString("name:de"),
246248
source.getString("landuse"), source.getString("leisure"), source.getString("boundary"),
247-
source.getString("protection_title"), source);
249+
source.getString("protected_area"), source.getString("protect_class"), source.getString("protection_title"),
250+
source.getString("historic"), source.getBoolean("maritime"), source);
248251
}
249252

250253
/** Imposm3 "mapping" to filter OSM elements that should appear in this "table". */
251-
public static final Expression MAPPING =
252-
and(or(matchAny("leisure", "nature_reserve"), matchAny("boundary", "national_park", "protected_area")),
253-
matchType("polygon"));
254+
public static final Expression MAPPING = and(or(matchAny("leisure", "nature_reserve"),
255+
matchAny("boundary", "national_park", "protected_area", "aboriginal_lands"),
256+
matchAny("historic", "archaeological_site", "battlefield", "district")), matchType("polygon"));
254257

255258
/**
256259
* Interface for layer implementations to extend to subscribe to OSM elements filtered and parsed as
@@ -776,6 +779,8 @@ public OsmPoiPoint(SourceFeature source, String mappingKey) {
776779
"rugby_union", "running", "sailing", "scuba_diving", "shooting", "shooting_range", "skateboard", "skating",
777780
"skiing", "soccer", "surfing", "swimming", "table_soccer", "table_tennis", "team_handball", "tennis",
778781
"toboggan", "volleyball", "water_ski", "yoga"),
782+
matchAny("zoo", "enclosure", "petting_zoo", "aviary", "wildlife_park", "birds", "safari_park", "butterfly",
783+
"falconry", "reptile", "terrarium"),
779784
matchAny("tourism", "alpine_hut", "aquarium", "artwork", "attraction", "bed_and_breakfast", "camp_site",
780785
"caravan_site", "chalet", "gallery", "guest_house", "hostel", "hotel", "information", "motel", "museum",
781786
"picnic_site", "theme_park", "viewpoint", "zoo"),
@@ -855,6 +860,8 @@ public OsmPoiPolygon(SourceFeature source, String mappingKey) {
855860
"rugby_union", "running", "sailing", "scuba_diving", "shooting", "shooting_range", "skateboard", "skating",
856861
"skiing", "soccer", "surfing", "swimming", "table_soccer", "table_tennis", "team_handball", "tennis",
857862
"toboggan", "volleyball", "water_ski", "yoga"),
863+
matchAny("zoo", "enclosure", "petting_zoo", "aviary", "wildlife_park", "birds", "safari_park", "butterfly",
864+
"falconry", "reptile", "terrarium"),
858865
matchAny("tourism", "alpine_hut", "aquarium", "artwork", "attraction", "bed_and_breakfast", "camp_site",
859866
"caravan_site", "chalet", "gallery", "guest_house", "hostel", "hotel", "information", "motel", "museum",
860867
"picnic_site", "theme_park", "viewpoint", "zoo"),
@@ -1026,6 +1033,11 @@ public interface WithHighway {
10261033
String highway();
10271034
}
10281035

1036+
/** Rows with a String historic attribute. */
1037+
public interface WithHistoric {
1038+
String historic();
1039+
}
1040+
10291041
/** Rows with a String horse attribute. */
10301042
public interface WithHorse {
10311043
String horse();
@@ -1151,6 +1163,11 @@ public interface WithMappingKey {
11511163
String mappingKey();
11521164
}
11531165

1166+
/** Rows with a boolean maritime attribute. */
1167+
public interface WithMaritime {
1168+
boolean maritime();
1169+
}
1170+
11541171
/** Rows with a String material attribute. */
11551172
public interface WithMaterial {
11561173
String material();
@@ -1216,6 +1233,16 @@ public interface WithPopulation {
12161233
long population();
12171234
}
12181235

1236+
/** Rows with a String protectClass attribute. */
1237+
public interface WithProtectClass {
1238+
String protectClass();
1239+
}
1240+
1241+
/** Rows with a String protectedArea attribute. */
1242+
public interface WithProtectedArea {
1243+
String protectedArea();
1244+
}
1245+
12191246
/** Rows with a String protectionTitle attribute. */
12201247
public interface WithProtectionTitle {
12211248
String protectionTitle();

0 commit comments

Comments
 (0)