OpenMapTiles 3.15.0 SNAPSHOT (#126)

* version bumped from 3.14.0 to 3.15.0-SNAPSHOT

* regenerate-openmaptiles.sh 07f243c5d9efa558fa539d7a31b2ae50507aaa9d (to match content of OMT PR 1457)

* SQL -> Java re-implementation of OMT PR 1457

* version bumped from 3.14.0 to 3.15.0-SNAPSHOT

* WaterName.areaToMinZoom(): improved handling of rounding and precission + added unit tests

* mvn spotless:apply

* water label min. zoom calculation simplified

* comment adjusted to be hopefully more useful

* mvn spotless:apply

* minzoom for CA_TRANSCANADA and US_INTERSTATE trunk now 4 (to match OMT PR 1440)

* minzoom for some other Canada trunks now 4 (to match OMT PR 1446)

* equals() simplified + clean-up of comments

* regenerate-openmaptiles.sh 5f7b2c11b3224759a21133381ca7d959a1f3cf51 (to match content of OMT PR 1465)

* GB road relations processing adjusted to match OMT PR 1465, e.g. handle also primary and secondary roads

* regenerate-openmaptiles.sh edb42f2db3c2b0ec37045367720eed84d7bbd71f (to match content of OMT PR 1466)

* IE road relations processing adjusted to match OMT PR 1466, e.g. handle IE roates in similar way as GB routes

* fixed handling of networkType for secondary GB routes

* clean-up: case statements simplified

* mvn spotless:apply

* clazz calculation moved up so that minzoom can be set to 3 for only lakes (to match OMT PR 1475)

* unit tests adjusted + extended to cover 'minzoom=3 fore lakes' change

* fixed minor typo from previous PR

* render POIs for large universities at low zoom (to match OMT PR 1479)

* clean-up, to make the diff/PR smaller

* regenerate-openmaptiles.sh 5e9b7c475d53a5bd5ea394da361594d3f4ce2d66 (to match content of OMT PR 1485)

* handle 'grade1' and 'tracktype' as per OMT PR 1485

* added implementation of agg_stop

It is based on OMT PR 1480 (which contains latest the fix) and the rest of older code
(which was not worling properly until the fix).

* clean-up: mvn spotless:apply

* Long ferries (as per OMT PR 1486)

* regenerate-openmaptiles.sh b3d67ed5b327c9059aeea0b3304772c6b4c8c7e9  (to match content of OMT PR 1489)

* Add aboriginal lands (as per OMT PR 1489)

* handle duplicate route relations (to match OMT PR 1501)

* regenerate-openmaptiles.sh master, to match several OMT PRs which adjusted only YML

* URLs in comments adjusted to match OMT PR 1560

* Convert separated addresses to dashed addresses

* add brunnel (and layer) attributes only for certain zoomlevels, depending on feature size (matching OMT PR 1579)

* unit test testInterstateMotorway(): brunnel tag for test line no longer available at Z8

* unit test testInterstateMotorway() clean-up: Z13 was tested twice

* minor clean-up: fixed unit test naming

* partial fix for differences in transportation_name layer

The difference is between OpenMapTiles/master (OMT) and
planetiler-openmaptiles/omt_3_15_0 (PT-OMT) (e.g. development versions).

The point is, that while PT-OMT was using limit of "8km" for Z9-Z11, OMT
is using limit "ST_Length(geometry) > 8000 / POWER(2, zoom_level - 9)
AND zoom_level BETWEEN 9 AND 11".

Some further differences still visible, hence further commits expected.

* further adjustments to better match what is done with ferries in OMT

... (as per OMT PR 1486)

But FERRY_MIN_PIXEL_SIZE is "too much" in the contexct of Planetiler,
since it is applied within tiles, hence causes gaps in lines if a line
"strikes a little" certain tile. Hence we will need to divert a little.

* ferry minLength tweak + clean-up

* mvn spotless:apply

* fixed minor typo

* minor reformatting

* ferry line length filter replaced with min. zoom calculation

hence the results are much closer to what OMT is doing for Z4-Z9

* testFerry() adjusted to match previous commit

ferry test polygon with area 1 now qualifies for min. zoom 5

* clea-up of unused stuff + mvn spotless:apply

* mvn spotless:apply

* added TODO node for follow-up pull-request/simplification

* clean-up: common getMinZoom() code moved to Utils

* minzoom clipping for brunnel was adjusted do Z9-Z12 -> test adjusted too

* clean-up

* use same tolerance for all transportation items, like OSM does

* clean-up, since ferry and non-ferry procesing is now same

* we need regenerate to work with master branch for now

* first sub-class search for agg_stop simplified a little

* contains() used instead of indexOf() for better readability

* numbers as list, not array, so that getFirst() and getLast() can be used

* better trimming and filtring of housenumbers

* adjusted handling of large house numbers

* several unit tests collapsed to one with @ParameterizedTest + @CsvSource

* AGG_STOP_SUBCLASS_ORDER simplified from Map to List

* fixed major omission from previous commit

* clamp() used to replace min()&max() combo

* agg_stop now implemented

* fixed typo in the error message

* prepare IE and GB boundary geometry outside of synchronized{}

* fixed typo in the error message

* mvn spotless:apply

* switch statements for IE and GB route networks simplified

* avoid RouteNetwork->String mapping, not needed for anyMatch()

* fix: attr. brunnel optional based on size on Z4-Z11, attr. layer optional between Z9-Z11

* tolerance change in transportation reverted, added note to README as per why

* fix: monzoom for sea&co. is Z0-Z14 based on area, for the rest it is Z3-Z14 again based on area

* clean-up: avoid doing area->side->area, do just area

* regenerate-openmaptiles.sh 6c31841f4674f15e15afde346a060cf7c22e6cdd (to match content of OMT PR 1591)

* relevant process() functions adjusted to match changes in transportation/mapping.yaml

* regenerate-openmaptiles.sh master, instead of 6c31841f4674f15e15afde346a060cf7c22e6cdd (to match content of OMT PR 1591, in a cleaner way)

* introduce duplicate housenumber filtering (matching OMT PR 1391)

* (less related) clean-up: use isEmpty() instead if size check

* testContainsHousenumber UT adjusted, since duplicate housenumber filtering is reducing amount of house numbers

* use combination of uic_ref, name, network and operator as key for agg_stop sets

If we rely on only on `uic_ref` we group together also stations which are
too far apart (even different cities). With this combo results seem OK,
e.g. all grouped stations are within around 950m (1000 pixels at Z14) of
each other (1000 being used in `PARTITION BY LabelGrid(...` in
`layers/poi/poi.sql` in OpenMapTiles).

* agg_stop comparison made more explicit, since we want to match same exact one

* mvn spotless:apply

* name now important for agg_stop processing, hence name:es (ab)used for unit tests

* agg_stop: simplified processing of nearest station

Results still same, only ordering is different:
- previously: agg_stop=1 first
- now: FIFO

* agg_stop: forther code simplification

* fixed major typo introduced in previous merge

* setMinPixelSize() + setMinZoom() used instead of areaToMinZoom()

* clean-up: unused stuff removed

* mvn spotless:apply

* setAttrWithMinSize() used instead of getBrunnelMinzoom()

getFerryMinzoom() kept since we'd like to replicate `sql_filter: ST_Length(...` from OMT

* getMinZoomForLength() no longer used, hence removed

* clean-up: LOG2 not used, hence removed

* added BY_TEMP_HAS_NAME comparator to avoid its repeated construction during run-time

* duplicate houcenumber processing simplified further

* clean-up: get(0) replaced with getFirst()

* clean-up: CPU-intensive prepare() moved out of synchronized block

* regenerate-openmaptiles.sh 3cf77e2a542d8a369bb08bf2538cdde0b3effb2b (to match content of OMT PR 1423)

* unit test adjusted for POI office class changes

* regenerate-openmaptiles.sh master (to match content of OMT PR 1544)

* added charging_station implementation matching OMT PR 1544

* use setMinPixelSizeBelowZoom() instead of uniAreaToMinZoom()

* use setMinPixelSizeBelowZoom() instead of getFerryMinzoom()

* fixed unit test, to match recent tweaks
This commit is contained in:
Peter Hanecak
2023-12-22 10:23:37 +01:00
committed by GitHub
parent 58e2c89500
commit add205e26c
21 changed files with 1719 additions and 259 deletions

View File

@@ -26,11 +26,11 @@ available options.
## Differences from OpenMapTiles ## Differences from OpenMapTiles
- Road name abbreviations are not implemented yet in the `transportation_name` layer - Road name abbreviations are not implemented yet in the `transportation_name` layer
- `agg_stop` tag not implemented yet in the `poi` layer
- `brunnel` tag is excluded from `transportation_name` layer to avoid breaking apart long `transportation_name` - `brunnel` tag is excluded from `transportation_name` layer to avoid breaking apart long `transportation_name`
lines, to revert this behavior set `--transportation-name-brunnel=true` lines, to revert this behavior set `--transportation-name-brunnel=true`
- `rank` field on `mountain_peak` linestrings only has 3 levels (1: has wikipedia page and name, 2: has name, 3: no name - `rank` field on `mountain_peak` linestrings only has 3 levels (1: has wikipedia page and name, 2: has name, 3: no name
or wikipedia page or name) or wikipedia page or name)
- some line and polygon tolerances are different, can be tweaked with `--simplify-tolerance` parameter
## Customizing ## Customizing

View File

@@ -22,7 +22,7 @@
<groupId>org.openmaptiles</groupId> <groupId>org.openmaptiles</groupId>
<artifactId>planetiler-openmaptiles</artifactId> <artifactId>planetiler-openmaptiles</artifactId>
<version>3.14.0</version> <version>3.15.0-SNAPSHOT</version>
<name>OpenMapTiles Vector Tile Schema implementation for Planetiler tool</name> <name>OpenMapTiles Vector Tile Schema implementation for Planetiler tool</name>

View File

@@ -4,7 +4,8 @@ set -o errexit
set -o pipefail set -o pipefail
set -o nounset set -o nounset
TAG="${1:-"v3.14"}" # TODO: change to "v3.15" once that is released
TAG="${1:-"master"}"
echo "tag=${TAG}" echo "tag=${TAG}"
BASE_URL="${2:-"https://raw.githubusercontent.com/openmaptiles/openmaptiles/"}" BASE_URL="${2:-"https://raw.githubusercontent.com/openmaptiles/openmaptiles/"}"

View File

@@ -220,12 +220,12 @@ public class OpenMapTilesProfile extends ForwardingProfile {
/** /**
* Layers should implement this interface to subscribe to elements from * Layers should implement this interface to subscribe to elements from
* <a href="https://github.com/lukasmartinelli/osm-lakelines">OSM lake centerlines source</a>. * <a href="https://github.com/openmaptiles/osm-lakelines">OSM lake centerlines source</a>.
*/ */
public interface LakeCenterlineProcessor { public interface LakeCenterlineProcessor {
/** /**
* Process an element from the <a href="https://github.com/lukasmartinelli/osm-lakelines">OSM lake centerlines * Process an element from the <a href="https://github.com/openmaptiles/osm-lakelines">OSM lake centerlines
* source</a> * source</a>
* *
* @see Profile#processFeature(SourceFeature, FeatureCollector) * @see Profile#processFeature(SourceFeature, FeatureCollector)

View File

@@ -49,8 +49,8 @@ import org.openmaptiles.Layer;
/** /**
* All vector tile layer definitions, attributes, and allowed values generated from the * All vector tile layer definitions, attributes, and allowed values generated from the
* <a href="https://github.com/openmaptiles/openmaptiles/blob/v3.14/openmaptiles.yaml">OpenMapTiles vector tile schema * <a href="https://github.com/openmaptiles/openmaptiles/blob/master/openmaptiles.yaml">OpenMapTiles vector tile schema
* v3.14</a>. * master</a>.
*/ */
@SuppressWarnings("unused") @SuppressWarnings("unused")
public class OpenMapTilesSchema { public class OpenMapTilesSchema {
@@ -59,11 +59,11 @@ public class OpenMapTilesSchema {
public static final String VERSION = "3.14.0"; public static final String VERSION = "3.14.0";
public static final String ATTRIBUTION = public static final String ATTRIBUTION =
"<a href=\"https://www.openmaptiles.org/\" target=\"_blank\">&copy; OpenMapTiles</a> <a href=\"https://www.openstreetmap.org/copyright\" target=\"_blank\">&copy; OpenStreetMap contributors</a>"; "<a href=\"https://www.openmaptiles.org/\" target=\"_blank\">&copy; OpenMapTiles</a> <a href=\"https://www.openstreetmap.org/copyright\" target=\"_blank\">&copy; OpenStreetMap contributors</a>";
public static final List<String> LANGUAGES = List.of("am", "ar", "az", "be", "bg", "br", "bs", "ca", "co", "cs", "cy", public static final List<String> LANGUAGES = List.of("am", "ar", "az", "be", "bg", "bn", "br", "bs", "ca", "co", "cs",
"da", "de", "el", "en", "eo", "es", "et", "eu", "fi", "fr", "fy", "ga", "gd", "he", "hi", "hr", "hu", "hy", "id", "cy", "da", "de", "el", "en", "eo", "es", "et", "eu", "fa", "fi", "fr", "fy", "ga", "gd", "he", "hi", "hr", "hu",
"is", "it", "ja", "ja_kana", "ja_rm", "ja-Latn", "ja-Hira", "ka", "kk", "kn", "ko", "ko-Latn", "ku", "la", "lb", "hy", "id", "is", "it", "ja", "ja_kana", "ja_rm", "ja-Latn", "ja-Hira", "ka", "kk", "kn", "ko", "ko-Latn", "ku",
"lt", "lv", "mk", "mt", "ml", "nl", "no", "oc", "pl", "pt", "rm", "ro", "ru", "sk", "sl", "sq", "sr", "sr-Latn", "la", "lb", "lt", "lv", "mk", "mt", "ml", "nl", "no", "oc", "pa", "pnb", "pl", "pt", "rm", "ro", "ru", "sk", "sl",
"sv", "ta", "te", "th", "tr", "uk", "zh"); "sq", "sr", "sr-Latn", "sv", "ta", "te", "th", "tr", "uk", "ur", "vi", "zh", "zh-Hant", "zh-Hans");
/** Returns a list of expected layer implementation instances from the {@code layers} package. */ /** Returns a list of expected layer implementation instances from the {@code layers} package. */
public static List<Layer> createInstances(Translations translations, PlanetilerConfig config, Stats stats) { public static List<Layer> createInstances(Translations translations, PlanetilerConfig config, Stats stats) {
@@ -96,7 +96,7 @@ public class OpenMapTilesSchema {
* boundaries show up. So you might not be able to use border styling for ocean water features. * boundaries show up. So you might not be able to use border styling for ocean water features.
* *
* Generated from * Generated from
* <a href="https://github.com/openmaptiles/openmaptiles/blob/v3.14/layers/water/water.yaml">water.yaml</a> * <a href="https://github.com/openmaptiles/openmaptiles/blob/master/layers/water/water.yaml">water.yaml</a>
*/ */
public interface Water extends Layer { public interface Water extends Layer {
double BUFFER_SIZE = 4.0; double BUFFER_SIZE = 4.0;
@@ -117,11 +117,15 @@ public class OpenMapTilesSchema {
/** /**
* All water polygons from <a href="http://osmdata.openstreetmap.de/">OpenStreetMapData</a> have the class * All water polygons from <a href="http://osmdata.openstreetmap.de/">OpenStreetMapData</a> have the class
* <code>ocean</code>. Water bodies with the * <code>ocean</code>. The water-covered areas of flowing water bodies with the
* <a href="http://wiki.openstreetmap.org/wiki/Tag:water=river"><code>water=river</code></a> tag are classified as * <a href="http://wiki.openstreetmap.org/wiki/Tag:water=river"><code>water=river</code></a>,
* river. Wet and dry docks tagged * <a href="http://wiki.openstreetmap.org/wiki/Tag:water=canal"><code>water=canal</code></a>,
* <a href="http://wiki.openstreetmap.org/wiki/Tag:water=stream"><code>water=stream</code></a>,
* <a href="http://wiki.openstreetmap.org/wiki/Tag:water=ditch"><code>water=ditch</code></a>, or
* <a href="http://wiki.openstreetmap.org/wiki/Tag:water=drain"><code>water=drain</code></a> tags are classified
* as river. Wet and dry docks tagged
* <a href="http://wiki.openstreetmap.org/wiki/Tag:waterway=dock"><code>waterway=dock</code></a> are classified as * <a href="http://wiki.openstreetmap.org/wiki/Tag:waterway=dock"><code>waterway=dock</code></a> are classified as
* a <code>dock</code>. Swimming pools tagged * a <code>dock</code>. Various minor waterbodies are classified as a <code>pond</code>. Swimming pools tagged
* <a href="https://wiki.openstreetmap.org/wiki/Tag:leisure=swimming_pool"><code>leisure=swimming_pool</code></a> * <a href="https://wiki.openstreetmap.org/wiki/Tag:leisure=swimming_pool"><code>leisure=swimming_pool</code></a>
* are classified as a <code>swimming_pool</code> All other water bodies are classified as <code>lake</code>. * are classified as a <code>swimming_pool</code> All other water bodies are classified as <code>lake</code>.
* <p> * <p>
@@ -129,6 +133,7 @@ public class OpenMapTilesSchema {
* <ul> * <ul>
* <li>dock * <li>dock
* <li>river * <li>river
* <li>pond
* <li>lake * <li>lake
* <li>ocean * <li>ocean
* <li>swimming_pool * <li>swimming_pool
@@ -163,10 +168,11 @@ public class OpenMapTilesSchema {
final class FieldValues { final class FieldValues {
public static final String CLASS_DOCK = "dock"; public static final String CLASS_DOCK = "dock";
public static final String CLASS_RIVER = "river"; public static final String CLASS_RIVER = "river";
public static final String CLASS_POND = "pond";
public static final String CLASS_LAKE = "lake"; public static final String CLASS_LAKE = "lake";
public static final String CLASS_OCEAN = "ocean"; public static final String CLASS_OCEAN = "ocean";
public static final String CLASS_SWIMMING_POOL = "swimming_pool"; public static final String CLASS_SWIMMING_POOL = "swimming_pool";
public static final Set<String> CLASS_VALUES = Set.of("dock", "river", "lake", "ocean", "swimming_pool"); public static final Set<String> CLASS_VALUES = Set.of("dock", "river", "pond", "lake", "ocean", "swimming_pool");
public static final String BRUNNEL_BRIDGE = "bridge"; public static final String BRUNNEL_BRIDGE = "bridge";
public static final String BRUNNEL_TUNNEL = "tunnel"; public static final String BRUNNEL_TUNNEL = "tunnel";
public static final Set<String> BRUNNEL_VALUES = Set.of("bridge", "tunnel"); public static final Set<String> BRUNNEL_VALUES = Set.of("bridge", "tunnel");
@@ -175,8 +181,9 @@ public class OpenMapTilesSchema {
final class FieldMappings { final class FieldMappings {
public static final MultiExpression<String> Class = public static final MultiExpression<String> Class =
MultiExpression.of(List.of(MultiExpression.entry("dock", matchAny("waterway", "dock")), MultiExpression.of(List.of(MultiExpression.entry("dock", matchAny("waterway", "dock")),
MultiExpression.entry("river", matchAny("water", "river")), MultiExpression.entry("lake", FALSE), MultiExpression.entry("river", matchAny("water", "river", "stream", "canal", "ditch", "drain")),
MultiExpression.entry("ocean", FALSE), MultiExpression.entry("pond", matchAny("water", "pond", "basin", "wastewater")),
MultiExpression.entry("lake", FALSE), MultiExpression.entry("ocean", FALSE),
MultiExpression.entry("swimming_pool", matchAny("leisure", "swimming_pool")))); MultiExpression.entry("swimming_pool", matchAny("leisure", "swimming_pool"))));
} }
} }
@@ -188,7 +195,7 @@ public class OpenMapTilesSchema {
* field applied. Waterways do not have a <code>subclass</code> field. * field applied. Waterways do not have a <code>subclass</code> field.
* *
* Generated from * Generated from
* <a href="https://github.com/openmaptiles/openmaptiles/blob/v3.14/layers/waterway/waterway.yaml">waterway.yaml</a> * <a href="https://github.com/openmaptiles/openmaptiles/blob/master/layers/waterway/waterway.yaml">waterway.yaml</a>
*/ */
public interface Waterway extends Layer { public interface Waterway extends Layer {
double BUFFER_SIZE = 4.0; double BUFFER_SIZE = 4.0;
@@ -273,7 +280,7 @@ public class OpenMapTilesSchema {
* layer is to style wood (<code>class=wood</code>) and grass (<code>class=grass</code>) areas. * layer is to style wood (<code>class=wood</code>) and grass (<code>class=grass</code>) areas.
* *
* Generated from <a href= * Generated from <a href=
* "https://github.com/openmaptiles/openmaptiles/blob/v3.14/layers/landcover/landcover.yaml">landcover.yaml</a> * "https://github.com/openmaptiles/openmaptiles/blob/master/layers/landcover/landcover.yaml">landcover.yaml</a>
*/ */
public interface Landcover extends Layer { public interface Landcover extends Layer {
double BUFFER_SIZE = 4.0; double BUFFER_SIZE = 4.0;
@@ -430,7 +437,7 @@ public class OpenMapTilesSchema {
* residential (urban) areas and at higher zoom levels mostly OSM <code>landuse</code> tags. * residential (urban) areas and at higher zoom levels mostly OSM <code>landuse</code> tags.
* *
* Generated from * Generated from
* <a href="https://github.com/openmaptiles/openmaptiles/blob/v3.14/layers/landuse/landuse.yaml">landuse.yaml</a> * <a href="https://github.com/openmaptiles/openmaptiles/blob/master/layers/landuse/landuse.yaml">landuse.yaml</a>
*/ */
public interface Landuse extends Layer { public interface Landuse extends Layer {
double BUFFER_SIZE = 4.0; double BUFFER_SIZE = 4.0;
@@ -526,7 +533,7 @@ public class OpenMapTilesSchema {
* <a href="http://wiki.openstreetmap.org/wiki/Tag:natural%3Dpeak">Natural peaks</a> * <a href="http://wiki.openstreetmap.org/wiki/Tag:natural%3Dpeak">Natural peaks</a>
* *
* Generated from <a href= * Generated from <a href=
* "https://github.com/openmaptiles/openmaptiles/blob/v3.14/layers/mountain_peak/mountain_peak.yaml">mountain_peak.yaml</a> * "https://github.com/openmaptiles/openmaptiles/blob/master/layers/mountain_peak/mountain_peak.yaml">mountain_peak.yaml</a>
*/ */
public interface MountainPeak extends Layer { public interface MountainPeak extends Layer {
double BUFFER_SIZE = 64.0; double BUFFER_SIZE = 64.0;
@@ -594,14 +601,18 @@ public class OpenMapTilesSchema {
} }
} }
/** /**
* The park layer contains parks from OpenStreetMap tagged with * The park layer in OpenMapTiles contains natural and protected areas from OpenStreetMap, such as parks tagged with
* <a href="http://wiki.openstreetmap.org/wiki/Tag:boundary%3Dnational_park"><code>boundary=national_park</code></a>, * <a href="https://wiki.openstreetmap.org/wiki/Tag:boundary%3Dnational_park"><code>boundary=national_park</code></a>,
* <a href= * <a href=
* "http://wiki.openstreetmap.org/wiki/Tag:boundary%3Dprotected_area"><code>boundary=protected_area</code></a>, or * "https://wiki.openstreetmap.org/wiki/Tag:boundary%3Dprotected_area"><code>boundary=protected_area</code></a>, or
* <a href="http://wiki.openstreetmap.org/wiki/Tag:leisure%3Dnature_reserve"><code>leisure=nature_reserve</code></a>. * <a href="https://wiki.openstreetmap.org/wiki/Tag:leisure%3Dnature_reserve"><code>leisure=nature_reserve</code></a>.
* This layer also includes boundaries for indigenous lands tagged with <a href=
* "https://wiki.openstreetmap.org/wiki/Tag:boundary%3Daboriginal_lands"><code>boundary=aboriginal_lands</code></a>.
* Indigenous boundaries are not parks, but they are included in this layer for technical reasons related to data
* processing. These boundaries represent areas with special legal and administrative status for indigenous peoples.
* *
* Generated from * Generated from
* <a href="https://github.com/openmaptiles/openmaptiles/blob/v3.14/layers/park/park.yaml">park.yaml</a> * <a href="https://github.com/openmaptiles/openmaptiles/blob/master/layers/park/park.yaml">park.yaml</a>
*/ */
public interface Park extends Layer { public interface Park extends Layer {
double BUFFER_SIZE = 4.0; double BUFFER_SIZE = 4.0;
@@ -615,15 +626,16 @@ public class OpenMapTilesSchema {
/** Attribute names for map elements in the park layer. */ /** Attribute names for map elements in the park layer. */
final class Fields { final class Fields {
/** /**
* Use the <strong>class</strong> to differentiate between different parks. The class for * Use the <strong>class</strong> to differentiate between different kinds of features in the <code>parks</code>
* <code>boundary=protected_area</code> parks is the lower-case of the * layer, for example between parks and non-parks. The class for <code>boundary=protected_area</code> parks is the
* lower-case of the
* <a href="http://wiki.openstreetmap.org/wiki/key:protection_title"><code>protection_title</code></a> value with * <a href="http://wiki.openstreetmap.org/wiki/key:protection_title"><code>protection_title</code></a> value with
* blanks replaced by <code>_</code>. <code>national_park</code> is the class of * blanks replaced by <code>_</code>. <code>national_park</code> is the class of
* <code>protection_title=National Park</code> and <code>boundary=national_park</code>. * <code>protection_title=National Park</code> and <code>boundary=national_park</code>.
* <code>nature_reserve</code> is the class of <code>protection_title=Nature Reserve</code> and * <code>nature_reserve</code> is the class of <code>protection_title=Nature Reserve</code> and
* <code>leisure=nature_reserve</code>. The class for other * <code>leisure=nature_reserve</code>. The class for other
* <a href="http://wiki.openstreetmap.org/wiki/key:protection_title"><code>protection_title</code></a> values is * <a href="http://wiki.openstreetmap.org/wiki/key:protection_title"><code>protection_title</code></a> values is
* similarly assigned. * similarly assigned. The class for <code>boundary=aboriginal_lands</code> is <code>aboriginal_lands</code>.
*/ */
public static final String CLASS = "class"; public static final String CLASS = "class";
/** /**
@@ -661,7 +673,7 @@ public class OpenMapTilesSchema {
* but for most styles it makes sense to just style <code>admin_level=2</code> and <code>admin_level=4</code>. * but for most styles it makes sense to just style <code>admin_level=2</code> and <code>admin_level=4</code>.
* *
* Generated from * Generated from
* <a href="https://github.com/openmaptiles/openmaptiles/blob/v3.14/layers/boundary/boundary.yaml">boundary.yaml</a> * <a href="https://github.com/openmaptiles/openmaptiles/blob/master/layers/boundary/boundary.yaml">boundary.yaml</a>
*/ */
public interface Boundary extends Layer { public interface Boundary extends Layer {
double BUFFER_SIZE = 4.0; double BUFFER_SIZE = 4.0;
@@ -762,7 +774,7 @@ public class OpenMapTilesSchema {
* in the <strong>aeroway</strong> layer. * in the <strong>aeroway</strong> layer.
* *
* Generated from * Generated from
* <a href="https://github.com/openmaptiles/openmaptiles/blob/v3.14/layers/aeroway/aeroway.yaml">aeroway.yaml</a> * <a href="https://github.com/openmaptiles/openmaptiles/blob/master/layers/aeroway/aeroway.yaml">aeroway.yaml</a>
*/ */
public interface Aeroway extends Layer { public interface Aeroway extends Layer {
double BUFFER_SIZE = 4.0; double BUFFER_SIZE = 4.0;
@@ -822,7 +834,7 @@ public class OpenMapTilesSchema {
* features like plazas. * features like plazas.
* *
* Generated from <a href= * Generated from <a href=
* "https://github.com/openmaptiles/openmaptiles/blob/v3.14/layers/transportation/transportation.yaml">transportation.yaml</a> * "https://github.com/openmaptiles/openmaptiles/blob/master/layers/transportation/transportation.yaml">transportation.yaml</a>
*/ */
public interface Transportation extends Layer { public interface Transportation extends Layer {
double BUFFER_SIZE = 4.0; double BUFFER_SIZE = 4.0;
@@ -907,8 +919,9 @@ public class OpenMapTilesSchema {
* The network type derived mainly from * The network type derived mainly from
* <a href="http://wiki.openstreetmap.org/wiki/Key:network"><code>network</code></a> tag of the road. See more * <a href="http://wiki.openstreetmap.org/wiki/Key:network"><code>network</code></a> tag of the road. See more
* info about <a href="http://wiki.openstreetmap.org/wiki/Road_signs_in_the_United_States"><code>us- </code></a>, * info about <a href="http://wiki.openstreetmap.org/wiki/Road_signs_in_the_United_States"><code>us- </code></a>,
* <a href="https://en.wikipedia.org/wiki/Trans-Canada_Highway"><code>ca-transcanada</code></a>, or * <a href="https://en.wikipedia.org/wiki/Trans-Canada_Highway"><code>ca-transcanada</code></a>,
* <a href="http://wiki.openstreetmap.org/wiki/United_Kingdom_Tagging_Guidelines#UK_roads"><code>gb- </code></a>. * <a href="http://wiki.openstreetmap.org/wiki/United_Kingdom_Tagging_Guidelines#UK_roads"><code>gb- </code></a>,
* or <a href="http://wiki.openstreetmap.org/wiki/Ireland/Roads"><code>ie- </code></a>.
*/ */
public static final String NETWORK = "network"; public static final String NETWORK = "network";
@@ -1166,7 +1179,7 @@ public class OpenMapTilesSchema {
* location:underground are excluded. * location:underground are excluded.
* *
* Generated from * Generated from
* <a href="https://github.com/openmaptiles/openmaptiles/blob/v3.14/layers/building/building.yaml">building.yaml</a> * <a href="https://github.com/openmaptiles/openmaptiles/blob/master/layers/building/building.yaml">building.yaml</a>
*/ */
public interface Building extends Layer { public interface Building extends Layer {
double BUFFER_SIZE = 4.0; double BUFFER_SIZE = 4.0;
@@ -1208,7 +1221,7 @@ public class OpenMapTilesSchema {
* from OSM water bodies. Only the most important lakes contain labels. * from OSM water bodies. Only the most important lakes contain labels.
* *
* Generated from <a href= * Generated from <a href=
* "https://github.com/openmaptiles/openmaptiles/blob/v3.14/layers/water_name/water_name.yaml">water_name.yaml</a> * "https://github.com/openmaptiles/openmaptiles/blob/master/layers/water_name/water_name.yaml">water_name.yaml</a>
*/ */
public interface WaterName extends Layer { public interface WaterName extends Layer {
double BUFFER_SIZE = 256.0; double BUFFER_SIZE = 256.0;
@@ -1231,11 +1244,14 @@ public class OpenMapTilesSchema {
public static final String NAME_DE = "name_de"; public static final String NAME_DE = "name_de";
/** /**
* Distinguish between <code>lake</code>, <code>ocean</code> and <code>sea</code>. * Distinguish between <code>lake</code>, <code>ocean</code>, <code>bay</code>, <code>strait</code>, and
* <code>sea</code>.
* <p> * <p>
* allowed values: * allowed values:
* <ul> * <ul>
* <li>"lake" * <li>"lake"
* <li>"bay"
* <li>"strait"
* <li>"sea" * <li>"sea"
* <li>"ocean" * <li>"ocean"
* </ul> * </ul>
@@ -1257,9 +1273,11 @@ public class OpenMapTilesSchema {
/** Attribute values for map elements in the water_name layer. */ /** Attribute values for map elements in the water_name layer. */
final class FieldValues { final class FieldValues {
public static final String CLASS_LAKE = "lake"; public static final String CLASS_LAKE = "lake";
public static final String CLASS_BAY = "bay";
public static final String CLASS_STRAIT = "strait";
public static final String CLASS_SEA = "sea"; public static final String CLASS_SEA = "sea";
public static final String CLASS_OCEAN = "ocean"; public static final String CLASS_OCEAN = "ocean";
public static final Set<String> CLASS_VALUES = Set.of("lake", "sea", "ocean"); public static final Set<String> CLASS_VALUES = Set.of("lake", "bay", "strait", "sea", "ocean");
} }
/** Complex mappings to generate attribute values from OSM element tags in the water_name layer. */ /** Complex mappings to generate attribute values from OSM element tags in the water_name layer. */
final class FieldMappings { final class FieldMappings {
@@ -1273,7 +1291,7 @@ public class OpenMapTilesSchema {
* while for other roads you should use <code>name</code>. * while for other roads you should use <code>name</code>.
* *
* Generated from <a href= * Generated from <a href=
* "https://github.com/openmaptiles/openmaptiles/blob/v3.14/layers/transportation_name/transportation_name.yaml">transportation_name.yaml</a> * "https://github.com/openmaptiles/openmaptiles/blob/master/layers/transportation_name/transportation_name.yaml">transportation_name.yaml</a>
*/ */
public interface TransportationName extends Layer { public interface TransportationName extends Layer {
double BUFFER_SIZE = 8.0; double BUFFER_SIZE = 8.0;
@@ -1316,8 +1334,14 @@ public class OpenMapTilesSchema {
* <li>"us-highway" * <li>"us-highway"
* <li>"us-state" * <li>"us-state"
* <li>"ca-transcanada" * <li>"ca-transcanada"
* <li>"ca-provincial-arterial"
* <li>"ca-provincial"
* <li>"gb-motorway" * <li>"gb-motorway"
* <li>"gb-trunk" * <li>"gb-trunk"
* <li>"gb-primary"
* <li>"ie-motorway"
* <li>"ie-national"
* <li>"ie-regional"
* <li>"road (default)" * <li>"road (default)"
* </ul> * </ul>
*/ */
@@ -1427,11 +1451,18 @@ public class OpenMapTilesSchema {
public static final String NETWORK_US_HIGHWAY = "us-highway"; public static final String NETWORK_US_HIGHWAY = "us-highway";
public static final String NETWORK_US_STATE = "us-state"; public static final String NETWORK_US_STATE = "us-state";
public static final String NETWORK_CA_TRANSCANADA = "ca-transcanada"; public static final String NETWORK_CA_TRANSCANADA = "ca-transcanada";
public static final String NETWORK_CA_PROVINCIAL_ARTERIAL = "ca-provincial-arterial";
public static final String NETWORK_CA_PROVINCIAL = "ca-provincial";
public static final String NETWORK_GB_MOTORWAY = "gb-motorway"; public static final String NETWORK_GB_MOTORWAY = "gb-motorway";
public static final String NETWORK_GB_TRUNK = "gb-trunk"; public static final String NETWORK_GB_TRUNK = "gb-trunk";
public static final String NETWORK_GB_PRIMARY = "gb-primary";
public static final String NETWORK_IE_MOTORWAY = "ie-motorway";
public static final String NETWORK_IE_NATIONAL = "ie-national";
public static final String NETWORK_IE_REGIONAL = "ie-regional";
public static final String NETWORK_ROAD = "road"; public static final String NETWORK_ROAD = "road";
public static final Set<String> NETWORK_VALUES = public static final Set<String> NETWORK_VALUES =
Set.of("us-interstate", "us-highway", "us-state", "ca-transcanada", "gb-motorway", "gb-trunk", "road"); Set.of("us-interstate", "us-highway", "us-state", "ca-transcanada", "ca-provincial-arterial", "ca-provincial",
"gb-motorway", "gb-trunk", "gb-primary", "ie-motorway", "ie-national", "ie-regional", "road");
public static final String CLASS_MOTORWAY = "motorway"; public static final String CLASS_MOTORWAY = "motorway";
public static final String CLASS_TRUNK = "trunk"; public static final String CLASS_TRUNK = "trunk";
public static final String CLASS_PRIMARY = "primary"; public static final String CLASS_PRIMARY = "primary";
@@ -1490,7 +1521,7 @@ public class OpenMapTilesSchema {
* create a text hierarchy. * create a text hierarchy.
* *
* Generated from * Generated from
* <a href="https://github.com/openmaptiles/openmaptiles/blob/v3.14/layers/place/place.yaml">place.yaml</a> * <a href="https://github.com/openmaptiles/openmaptiles/blob/master/layers/place/place.yaml">place.yaml</a>
*/ */
public interface Place extends Layer { public interface Place extends Layer {
double BUFFER_SIZE = 256.0; double BUFFER_SIZE = 256.0;
@@ -1542,6 +1573,7 @@ public class OpenMapTilesSchema {
* <li>"town" * <li>"town"
* <li>"village" * <li>"village"
* <li>"hamlet" * <li>"hamlet"
* <li>"borough"
* <li>"suburb" * <li>"suburb"
* <li>"quarter" * <li>"quarter"
* <li>"neighbourhood" * <li>"neighbourhood"
@@ -1579,13 +1611,14 @@ public class OpenMapTilesSchema {
public static final String CLASS_TOWN = "town"; public static final String CLASS_TOWN = "town";
public static final String CLASS_VILLAGE = "village"; public static final String CLASS_VILLAGE = "village";
public static final String CLASS_HAMLET = "hamlet"; public static final String CLASS_HAMLET = "hamlet";
public static final String CLASS_BOROUGH = "borough";
public static final String CLASS_SUBURB = "suburb"; public static final String CLASS_SUBURB = "suburb";
public static final String CLASS_QUARTER = "quarter"; public static final String CLASS_QUARTER = "quarter";
public static final String CLASS_NEIGHBOURHOOD = "neighbourhood"; public static final String CLASS_NEIGHBOURHOOD = "neighbourhood";
public static final String CLASS_ISOLATED_DWELLING = "isolated_dwelling"; public static final String CLASS_ISOLATED_DWELLING = "isolated_dwelling";
public static final String CLASS_ISLAND = "island"; public static final String CLASS_ISLAND = "island";
public static final Set<String> CLASS_VALUES = Set.of("continent", "country", "state", "province", "city", "town", public static final Set<String> CLASS_VALUES = Set.of("continent", "country", "state", "province", "city", "town",
"village", "hamlet", "suburb", "quarter", "neighbourhood", "isolated_dwelling", "island"); "village", "hamlet", "borough", "suburb", "quarter", "neighbourhood", "isolated_dwelling", "island");
} }
/** Complex mappings to generate attribute values from OSM element tags in the place layer. */ /** Complex mappings to generate attribute values from OSM element tags in the place layer. */
final class FieldMappings { final class FieldMappings {
@@ -1595,10 +1628,11 @@ public class OpenMapTilesSchema {
/** /**
* Everything in OpenStreetMap which contains a <code>addr:housenumber</code> tag useful for labelling housenumbers on * Everything in OpenStreetMap which contains a <code>addr:housenumber</code> tag useful for labelling housenumbers on
* a map. This adds significant size to <em>z14</em>. For buildings the centroid of the building is used as * a map. This adds significant size to <em>z14</em>. For buildings the centroid of the building is used as
* housenumber. * housenumber. Duplicates within a tile are dropped if they have the same street/block_number (records without name
* tag are prioritized for preservation).
* *
* Generated from <a href= * Generated from <a href=
* "https://github.com/openmaptiles/openmaptiles/blob/v3.14/layers/housenumber/housenumber.yaml">housenumber.yaml</a> * "https://github.com/openmaptiles/openmaptiles/blob/master/layers/housenumber/housenumber.yaml">housenumber.yaml</a>
*/ */
public interface Housenumber extends Layer { public interface Housenumber extends Layer {
double BUFFER_SIZE = 8.0; double BUFFER_SIZE = 8.0;
@@ -1611,7 +1645,10 @@ public class OpenMapTilesSchema {
/** Attribute names for map elements in the housenumber layer. */ /** Attribute names for map elements in the housenumber layer. */
final class Fields { final class Fields {
/** Value of the <a href="http://wiki.openstreetmap.org/wiki/Key:addr"><code>addr:housenumber</code></a> tag. */ /**
* Value of the <a href="http://wiki.openstreetmap.org/wiki/Key:addr"><code>addr:housenumber</code></a> tag. If
* there are multiple values separated by semi-colons, the first and last value separated by a dash.
*/
public static final String HOUSENUMBER = "housenumber"; public static final String HOUSENUMBER = "housenumber";
} }
/** Attribute values for map elements in the housenumber layer. */ /** Attribute values for map elements in the housenumber layer. */
@@ -1627,7 +1664,7 @@ public class OpenMapTilesSchema {
* <a href="http://wiki.openstreetmap.org/wiki/Points_of_interest">Points of interests</a> containing a of a variety * <a href="http://wiki.openstreetmap.org/wiki/Points_of_interest">Points of interests</a> containing a of a variety
* of OpenStreetMap tags. Mostly contains amenities, sport, shop and tourist POIs. * of OpenStreetMap tags. Mostly contains amenities, sport, shop and tourist POIs.
* *
* Generated from <a href="https://github.com/openmaptiles/openmaptiles/blob/v3.14/layers/poi/poi.yaml">poi.yaml</a> * Generated from <a href="https://github.com/openmaptiles/openmaptiles/blob/master/layers/poi/poi.yaml">poi.yaml</a>
*/ */
public interface Poi extends Layer { public interface Poi extends Layer {
double BUFFER_SIZE = 64.0; double BUFFER_SIZE = 64.0;
@@ -1656,6 +1693,7 @@ public class OpenMapTilesSchema {
* allowed values: * allowed values:
* <ul> * <ul>
* <li>shop * <li>shop
* <li>office
* <li>town_hall * <li>town_hall
* <li>golf * <li>golf
* <li>fast_food * <li>fast_food
@@ -1689,6 +1727,7 @@ public class OpenMapTilesSchema {
* <li>swimming * <li>swimming
* <li>castle * <li>castle
* <li>atm * <li>atm
* <li>fuel
* </ul> * </ul>
*/ */
public static final String CLASS = "class"; public static final String CLASS = "class";
@@ -1751,6 +1790,7 @@ public class OpenMapTilesSchema {
/** Attribute values for map elements in the poi layer. */ /** Attribute values for map elements in the poi layer. */
final class FieldValues { final class FieldValues {
public static final String CLASS_SHOP = "shop"; public static final String CLASS_SHOP = "shop";
public static final String CLASS_OFFICE = "office";
public static final String CLASS_TOWN_HALL = "town_hall"; public static final String CLASS_TOWN_HALL = "town_hall";
public static final String CLASS_GOLF = "golf"; public static final String CLASS_GOLF = "golf";
public static final String CLASS_FAST_FOOD = "fast_food"; public static final String CLASS_FAST_FOOD = "fast_food";
@@ -1784,10 +1824,11 @@ public class OpenMapTilesSchema {
public static final String CLASS_SWIMMING = "swimming"; public static final String CLASS_SWIMMING = "swimming";
public static final String CLASS_CASTLE = "castle"; public static final String CLASS_CASTLE = "castle";
public static final String CLASS_ATM = "atm"; public static final String CLASS_ATM = "atm";
public static final Set<String> CLASS_VALUES = Set.of("shop", "town_hall", "golf", "fast_food", "park", "bus", public static final String CLASS_FUEL = "fuel";
"railway", "aerialway", "entrance", "campsite", "laundry", "grocery", "library", "college", "lodging", public static final Set<String> CLASS_VALUES = Set.of("shop", "office", "town_hall", "golf", "fast_food", "park",
"bus", "railway", "aerialway", "entrance", "campsite", "laundry", "grocery", "library", "college", "lodging",
"ice_cream", "post", "cafe", "school", "alcohol_shop", "bar", "harbor", "car", "hospital", "cemetery", "ice_cream", "post", "cafe", "school", "alcohol_shop", "bar", "harbor", "car", "hospital", "cemetery",
"attraction", "beer", "music", "stadium", "art_gallery", "clothing_store", "swimming", "castle", "atm"); "attraction", "beer", "music", "stadium", "art_gallery", "clothing_store", "swimming", "castle", "atm", "fuel");
} }
/** Complex mappings to generate attribute values from OSM element tags in the poi layer. */ /** Complex mappings to generate attribute values from OSM element tags in the poi layer. */
final class FieldMappings { final class FieldMappings {
@@ -1798,8 +1839,18 @@ public class OpenMapTilesSchema {
"erotic", "electronics", "fabric", "florist", "frozen_food", "furniture", "video_games", "video", "general", "erotic", "electronics", "fabric", "florist", "frozen_food", "furniture", "video_games", "video", "general",
"gift", "hardware", "hearing_aids", "hifi", "ice_cream", "interior_decoration", "jewelry", "kiosk", "gift", "hardware", "hearing_aids", "hifi", "ice_cream", "interior_decoration", "jewelry", "kiosk",
"locksmith", "lamps", "mall", "massage", "motorcycle", "mobile_phone", "newsagent", "optician", "outdoor", "locksmith", "lamps", "mall", "massage", "motorcycle", "mobile_phone", "newsagent", "optician", "outdoor",
"perfumery", "perfume", "pet", "photo", "second_hand", "shoes", "sports", "stationery", "tailor", "tattoo", "paint", "perfumery", "perfume", "pet", "photo", "second_hand", "shoes", "sports", "stationery", "tailor",
"ticket", "tobacco", "toys", "travel_agency", "watches", "weapons", "wholesale")), "tattoo", "ticket", "tobacco", "toys", "travel_agency", "watches", "weapons", "wholesale")),
MultiExpression.entry("office",
matchAny("subclass", "accountant", "advertising_agency", "architect", "association", "bail_bond_agent",
"charity", "company", "construction_company", "consulting", "cooperative", "courier", "coworking",
"diplomatic", "educational_institution", "employment_agency", "energy_supplier", "engineer", "estate_agent",
"financial", "financial_advisor", "forestry", "foundation", "geodesist", "government", "graphic_design",
"guide", "harbour_master", "health_insurance", "insurance", "interior_design", "it", "lawyer", "logistics",
"marketing", "moving_company", "newspaper", "ngo", "notary", "physician", "political_party",
"private_investigator", "property_management", "publisher", "quango", "religion", "research", "security",
"surveyor", "tax_advisor", "taxi", "telecommunication", "therapist", "translator", "travel_agent",
"tutoring", "union", "university", "water_utility", "web_design", "wedding_planner")),
MultiExpression.entry("town_hall", MultiExpression.entry("town_hall",
matchAny("subclass", "townhall", "public_building", "courthouse", "community_centre")), matchAny("subclass", "townhall", "public_building", "courthouse", "community_centre")),
MultiExpression.entry("golf", matchAny("subclass", "golf", "golf_course", "miniature_golf")), MultiExpression.entry("golf", matchAny("subclass", "golf", "golf_course", "miniature_golf")),
@@ -1839,14 +1890,15 @@ public class OpenMapTilesSchema {
MultiExpression.entry("clothing_store", matchAny("subclass", "bag", "clothes")), MultiExpression.entry("clothing_store", matchAny("subclass", "bag", "clothes")),
MultiExpression.entry("swimming", matchAny("subclass", "swimming_area", "swimming")), MultiExpression.entry("swimming", matchAny("subclass", "swimming_area", "swimming")),
MultiExpression.entry("castle", matchAny("subclass", "castle", "ruins")), MultiExpression.entry("castle", matchAny("subclass", "castle", "ruins")),
MultiExpression.entry("atm", matchAny("subclass", "atm")))); MultiExpression.entry("atm", matchAny("subclass", "atm")),
MultiExpression.entry("fuel", matchAny("subclass", "fuel", "charging_station"))));
} }
} }
/** /**
* <a href="http://wiki.openstreetmap.org/wiki/Tag:aeroway%3Daerodrome">Aerodrome labels</a> * <a href="http://wiki.openstreetmap.org/wiki/Tag:aeroway%3Daerodrome">Aerodrome labels</a>
* *
* Generated from <a href= * Generated from <a href=
* "https://github.com/openmaptiles/openmaptiles/blob/v3.14/layers/aerodrome_label/aerodrome_label.yaml">aerodrome_label.yaml</a> * "https://github.com/openmaptiles/openmaptiles/blob/master/layers/aerodrome_label/aerodrome_label.yaml">aerodrome_label.yaml</a>
*/ */
public interface AerodromeLabel extends Layer { public interface AerodromeLabel extends Layer {
double BUFFER_SIZE = 64.0; double BUFFER_SIZE = 64.0;

View File

@@ -50,7 +50,7 @@ import java.util.Map;
/** /**
* OSM element parsers generated from the <a href="https://github.com/omniscale/imposm3">imposm3</a> table definitions * OSM element parsers generated from the <a href="https://github.com/omniscale/imposm3">imposm3</a> table definitions
* in the <a href="https://github.com/openmaptiles/openmaptiles/blob/v3.14/openmaptiles.yaml">OpenMapTiles vector tile * in the <a href="https://github.com/openmaptiles/openmaptiles/blob/master/openmaptiles.yaml">OpenMapTiles vector tile
* schema</a>. * schema</a>.
* *
* These filter and parse the raw OSM key/value attribute pairs on tags into records with fields that match the columns * These filter and parse the raw OSM key/value attribute pairs on tags into records with fields that match the columns
@@ -94,21 +94,23 @@ public class Tables {
) {} ) {}
/** An OSM element that would appear in the {@code osm_water_polygon} table generated by imposm3. */ /** An OSM element that would appear in the {@code osm_water_polygon} table generated by imposm3. */
public record OsmWaterPolygon(@Override String name, @Override String nameEn, @Override String nameDe, public record OsmWaterPolygon(@Override String name, @Override String nameEn, @Override String nameDe,
@Override String natural, @Override String landuse, @Override String waterway, @Override String leisure, @Override String place, @Override String natural, @Override String landuse, @Override String waterway,
@Override String water, @Override boolean isIntermittent, @Override boolean isTunnel, @Override boolean isBridge, @Override String leisure, @Override String water, @Override boolean isIntermittent, @Override boolean isTunnel,
@Override SourceFeature source) implements Row, WithName, WithNameEn, WithNameDe, WithNatural, WithLanduse, @Override boolean isBridge, @Override SourceFeature source)
WithWaterway, WithLeisure, WithWater, WithIsIntermittent, WithIsTunnel, WithIsBridge, WithSource { implements Row, WithName, WithNameEn, WithNameDe, WithPlace, WithNatural, WithLanduse, WithWaterway, WithLeisure,
WithWater, WithIsIntermittent, WithIsTunnel, WithIsBridge, WithSource {
public OsmWaterPolygon(SourceFeature source, String mappingKey) { public OsmWaterPolygon(SourceFeature source, String mappingKey) {
this(source.getString("name"), source.getString("name:en"), source.getString("name:de"), this(source.getString("name"), source.getString("name:en"), source.getString("name:de"),
source.getString("natural"), source.getString("landuse"), source.getString("waterway"), source.getString("place"), source.getString("natural"), source.getString("landuse"),
source.getString("leisure"), source.getString("water"), source.getBoolean("intermittent"), source.getString("waterway"), source.getString("leisure"), source.getString("water"),
source.getBoolean("tunnel"), source.getBoolean("bridge"), source); source.getBoolean("intermittent"), source.getBoolean("tunnel"), source.getBoolean("bridge"), source);
} }
/** Imposm3 "mapping" to filter OSM elements that should appear in this "table". */ /** Imposm3 "mapping" to filter OSM elements that should appear in this "table". */
public static final Expression MAPPING = and( public static final Expression MAPPING = and(
or(matchAny("landuse", "reservoir", "basin", "salt_pond"), matchAny("leisure", "swimming_pool"), or(matchAny("landuse", "reservoir", "basin", "salt_pond"), matchAny("leisure", "swimming_pool"),
matchAny("natural", "water", "bay", "spring"), matchAny("waterway", "dock"), matchAny("water", "river")), matchAny("natural", "water", "bay", "spring"), matchAny("waterway", "dock"),
matchAny("water", "river", "stream", "canal", "ditch", "drain", "pond", "basin", "wastewater")),
not(matchAny("covered", "yes")), matchType("polygon")); not(matchAny("covered", "yes")), matchType("polygon"));
/** /**
@@ -246,9 +248,8 @@ public class Tables {
} }
/** Imposm3 "mapping" to filter OSM elements that should appear in this "table". */ /** Imposm3 "mapping" to filter OSM elements that should appear in this "table". */
public static final Expression MAPPING = public static final Expression MAPPING = and(or(matchAny("leisure", "nature_reserve"),
and(or(matchAny("leisure", "nature_reserve"), matchAny("boundary", "national_park", "protected_area")), matchAny("boundary", "national_park", "protected_area", "aboriginal_lands")), matchType("polygon"));
matchType("polygon"));
/** /**
* Interface for layer implementations to extend to subscribe to OSM elements filtered and parsed as * Interface for layer implementations to extend to subscribe to OSM elements filtered and parsed as
@@ -316,25 +317,27 @@ public class Tables {
} }
} }
/** An OSM element that would appear in the {@code osm_highway_linestring} table generated by imposm3. */ /** An OSM element that would appear in the {@code osm_highway_linestring} table generated by imposm3. */
public record OsmHighwayLinestring(@Override String highway, @Override String construction, @Override String ref, public record OsmHighwayLinestring(@Override String highway, @Override String construction,
@Override String network, @Override int zOrder, @Override long layer, @Override long level, @Override String tracktype, @Override String ref, @Override String network, @Override int zOrder,
@Override boolean indoor, @Override String name, @Override String nameEn, @Override String nameDe, @Override long layer, @Override long level, @Override boolean indoor, @Override String name,
@Override String shortName, @Override boolean isTunnel, @Override boolean isBridge, @Override boolean isRamp, @Override String nameEn, @Override String nameDe, @Override String shortName, @Override boolean isTunnel,
@Override boolean isFord, @Override int isOneway, @Override boolean isArea, @Override String service, @Override boolean isBridge, @Override boolean isRamp, @Override boolean isFord, @Override int isOneway,
@Override String access, @Override boolean toll, @Override String usage, @Override String publicTransport, @Override boolean isArea, @Override String service, @Override String access, @Override boolean toll,
@Override String manMade, @Override String bicycle, @Override String foot, @Override String horse, @Override String usage, @Override String publicTransport, @Override String manMade, @Override String bicycle,
@Override String mtbScale, @Override String sacScale, @Override String surface, @Override boolean expressway, @Override String foot, @Override String horse, @Override String mtbScale, @Override String sacScale,
@Override SourceFeature source) implements Row, WithHighway, WithConstruction, WithRef, WithNetwork, WithZOrder, @Override String surface, @Override boolean expressway, @Override SourceFeature source)
WithLayer, WithLevel, WithIndoor, WithName, WithNameEn, WithNameDe, WithShortName, WithIsTunnel, WithIsBridge, implements Row, WithHighway, WithConstruction, WithTracktype, WithRef, WithNetwork, WithZOrder, WithLayer,
WithIsRamp, WithIsFord, WithIsOneway, WithIsArea, WithService, WithAccess, WithToll, WithUsage, WithPublicTransport, WithLevel, WithIndoor, WithName, WithNameEn, WithNameDe, WithShortName, WithIsTunnel, WithIsBridge, WithIsRamp,
WithIsFord, WithIsOneway, WithIsArea, WithService, WithAccess, WithToll, WithUsage, WithPublicTransport,
WithManMade, WithBicycle, WithFoot, WithHorse, WithMtbScale, WithSacScale, WithSurface, WithExpressway, WithSource { WithManMade, WithBicycle, WithFoot, WithHorse, WithMtbScale, WithSacScale, WithSurface, WithExpressway, WithSource {
public OsmHighwayLinestring(SourceFeature source, String mappingKey) { public OsmHighwayLinestring(SourceFeature source, String mappingKey) {
this(source.getString("highway"), source.getString("construction"), source.getString("ref"), this(source.getString("highway"), source.getString("construction"), source.getString("tracktype"),
source.getString("network"), source.getWayZorder(), source.getLong("layer"), source.getLong("level"), source.getString("ref"), source.getString("network"), source.getWayZorder(), source.getLong("layer"),
source.getBoolean("indoor"), source.getString("name"), source.getString("name:en"), source.getString("name:de"), source.getLong("level"), source.getBoolean("indoor"), source.getString("name"), source.getString("name:en"),
source.getString("short_name"), source.getBoolean("tunnel"), source.getBoolean("bridge"), source.getString("name:de"), source.getString("short_name"), source.getBoolean("tunnel"),
source.getBoolean("ramp"), source.getBoolean("ford"), source.getDirection("oneway"), source.getBoolean("area"), source.getBoolean("bridge"), source.getBoolean("ramp"), source.getBoolean("ford"),
source.getString("service"), source.getString("access"), source.getBoolean("toll"), source.getString("usage"), source.getDirection("oneway"), source.getBoolean("area"), source.getString("service"),
source.getString("access"), source.getBoolean("toll"), source.getString("usage"),
source.getString("public_transport"), source.getString("man_made"), source.getString("bicycle"), source.getString("public_transport"), source.getString("man_made"), source.getString("bicycle"),
source.getString("foot"), source.getString("horse"), source.getString("mtb:scale"), source.getString("foot"), source.getString("horse"), source.getString("mtb:scale"),
source.getString("sac_scale"), source.getString("surface"), source.getBoolean("expressway"), source); source.getString("sac_scale"), source.getString("surface"), source.getBoolean("expressway"), source);
@@ -361,18 +364,16 @@ public class Tables {
public record OsmRailwayLinestring(@Override String railway, @Override String ref, @Override String network, public record OsmRailwayLinestring(@Override String railway, @Override String ref, @Override String network,
@Override int zOrder, @Override long layer, @Override long level, @Override boolean indoor, @Override String name, @Override int zOrder, @Override long layer, @Override long level, @Override boolean indoor, @Override String name,
@Override String nameEn, @Override String nameDe, @Override String shortName, @Override boolean isTunnel, @Override String nameEn, @Override String nameDe, @Override String shortName, @Override boolean isTunnel,
@Override boolean isBridge, @Override boolean isRamp, @Override boolean isFord, @Override int isOneway, @Override boolean isBridge, @Override boolean isRamp, @Override boolean isFord, @Override boolean isArea,
@Override boolean isArea, @Override String service, @Override String usage, @Override SourceFeature source) @Override String service, @Override String usage, @Override SourceFeature source) implements Row, WithRailway,
implements Row, WithRailway, WithRef, WithNetwork, WithZOrder, WithLayer, WithLevel, WithIndoor, WithName, WithRef, WithNetwork, WithZOrder, WithLayer, WithLevel, WithIndoor, WithName, WithNameEn, WithNameDe, WithShortName,
WithNameEn, WithNameDe, WithShortName, WithIsTunnel, WithIsBridge, WithIsRamp, WithIsFord, WithIsOneway, WithIsArea, WithIsTunnel, WithIsBridge, WithIsRamp, WithIsFord, WithIsArea, WithService, WithUsage, WithSource {
WithService, WithUsage, WithSource {
public OsmRailwayLinestring(SourceFeature source, String mappingKey) { public OsmRailwayLinestring(SourceFeature source, String mappingKey) {
this(source.getString("railway"), source.getString("ref"), source.getString("network"), source.getWayZorder(), this(source.getString("railway"), source.getString("ref"), source.getString("network"), source.getWayZorder(),
source.getLong("layer"), source.getLong("level"), source.getBoolean("indoor"), source.getString("name"), source.getLong("layer"), source.getLong("level"), source.getBoolean("indoor"), source.getString("name"),
source.getString("name:en"), source.getString("name:de"), source.getString("short_name"), source.getString("name:en"), source.getString("name:de"), source.getString("short_name"),
source.getBoolean("tunnel"), source.getBoolean("bridge"), source.getBoolean("ramp"), source.getBoolean("ford"), source.getBoolean("tunnel"), source.getBoolean("bridge"), source.getBoolean("ramp"), source.getBoolean("ford"),
source.getDirection("oneway"), source.getBoolean("area"), source.getString("service"), source.getBoolean("area"), source.getString("service"), source.getString("usage"), source);
source.getString("usage"), source);
} }
/** Imposm3 "mapping" to filter OSM elements that should appear in this "table". */ /** Imposm3 "mapping" to filter OSM elements that should appear in this "table". */
@@ -420,16 +421,14 @@ public class Tables {
public record OsmShipwayLinestring(@Override String shipway, @Override int zOrder, @Override long layer, public record OsmShipwayLinestring(@Override String shipway, @Override int zOrder, @Override long layer,
@Override String name, @Override String nameEn, @Override String nameDe, @Override String shortName, @Override String name, @Override String nameEn, @Override String nameDe, @Override String shortName,
@Override boolean isTunnel, @Override boolean isBridge, @Override boolean isRamp, @Override boolean isFord, @Override boolean isTunnel, @Override boolean isBridge, @Override boolean isRamp, @Override boolean isFord,
@Override int isOneway, @Override boolean isArea, @Override String service, @Override String usage, @Override boolean isArea, @Override String service, @Override String usage, @Override SourceFeature source)
@Override SourceFeature source)
implements Row, WithShipway, WithZOrder, WithLayer, WithName, WithNameEn, WithNameDe, WithShortName, WithIsTunnel, implements Row, WithShipway, WithZOrder, WithLayer, WithName, WithNameEn, WithNameDe, WithShortName, WithIsTunnel,
WithIsBridge, WithIsRamp, WithIsFord, WithIsOneway, WithIsArea, WithService, WithUsage, WithSource { WithIsBridge, WithIsRamp, WithIsFord, WithIsArea, WithService, WithUsage, WithSource {
public OsmShipwayLinestring(SourceFeature source, String mappingKey) { public OsmShipwayLinestring(SourceFeature source, String mappingKey) {
this(source.getString("route"), source.getWayZorder(), source.getLong("layer"), source.getString("name"), this(source.getString("route"), source.getWayZorder(), source.getLong("layer"), source.getString("name"),
source.getString("name:en"), source.getString("name:de"), source.getString("short_name"), source.getString("name:en"), source.getString("name:de"), source.getString("short_name"),
source.getBoolean("tunnel"), source.getBoolean("bridge"), source.getBoolean("ramp"), source.getBoolean("ford"), source.getBoolean("tunnel"), source.getBoolean("bridge"), source.getBoolean("ramp"), source.getBoolean("ford"),
source.getDirection("oneway"), source.getBoolean("area"), source.getString("service"), source.getBoolean("area"), source.getString("service"), source.getString("usage"), source);
source.getString("usage"), source);
} }
/** Imposm3 "mapping" to filter OSM elements that should appear in this "table". */ /** Imposm3 "mapping" to filter OSM elements that should appear in this "table". */
@@ -521,16 +520,19 @@ public class Tables {
} }
/** An OSM element that would appear in the {@code osm_marine_point} table generated by imposm3. */ /** An OSM element that would appear in the {@code osm_marine_point} table generated by imposm3. */
public record OsmMarinePoint(@Override String name, @Override String nameEn, @Override String nameDe, public record OsmMarinePoint(@Override String name, @Override String nameEn, @Override String nameDe,
@Override String place, @Override long rank, @Override boolean isIntermittent, @Override SourceFeature source) @Override String place, @Override String natural, @Override long rank, @Override boolean isIntermittent,
implements Row, WithName, WithNameEn, WithNameDe, WithPlace, WithRank, WithIsIntermittent, WithSource { @Override SourceFeature source)
implements Row, WithName, WithNameEn, WithNameDe, WithPlace, WithNatural, WithRank, WithIsIntermittent, WithSource {
public OsmMarinePoint(SourceFeature source, String mappingKey) { public OsmMarinePoint(SourceFeature source, String mappingKey) {
this(source.getString("name"), source.getString("name:en"), source.getString("name:de"), this(source.getString("name"), source.getString("name:en"), source.getString("name:de"),
source.getString("place"), source.getLong("rank"), source.getBoolean("intermittent"), source); source.getString("place"), source.getString("natural"), source.getLong("rank"),
source.getBoolean("intermittent"), source);
} }
/** Imposm3 "mapping" to filter OSM elements that should appear in this "table". */ /** Imposm3 "mapping" to filter OSM elements that should appear in this "table". */
public static final Expression MAPPING = public static final Expression MAPPING =
and(matchAny("place", "ocean", "sea"), matchField("name"), matchType("point")); and(or(matchAny("place", "ocean", "sea"), matchAny("natural", "bay", "strait")), matchField("name"),
matchType("point"));
/** /**
* Interface for layer implementations to extend to subscribe to OSM elements filtered and parsed as * Interface for layer implementations to extend to subscribe to OSM elements filtered and parsed as
@@ -656,9 +658,8 @@ public class Tables {
} }
/** Imposm3 "mapping" to filter OSM elements that should appear in this "table". */ /** Imposm3 "mapping" to filter OSM elements that should appear in this "table". */
public static final Expression MAPPING = and( public static final Expression MAPPING = and(matchAny("place", "city", "town", "village", "hamlet", "borough",
matchAny("place", "city", "town", "village", "hamlet", "suburb", "quarter", "neighbourhood", "isolated_dwelling"), "suburb", "quarter", "neighbourhood", "isolated_dwelling"), matchField("name"), matchType("point"));
matchField("name"), matchType("point"));
/** /**
* Interface for layer implementations to extend to subscribe to OSM elements filtered and parsed as * Interface for layer implementations to extend to subscribe to OSM elements filtered and parsed as
@@ -669,10 +670,12 @@ public class Tables {
} }
} }
/** An OSM element that would appear in the {@code osm_housenumber_point} table generated by imposm3. */ /** An OSM element that would appear in the {@code osm_housenumber_point} table generated by imposm3. */
public record OsmHousenumberPoint(@Override String housenumber, @Override SourceFeature source) public record OsmHousenumberPoint(@Override String housenumber, @Override String street, @Override String blockNumber,
implements Row, WithHousenumber, WithSource { @Override String hasName, @Override SourceFeature source)
implements Row, WithHousenumber, WithStreet, WithBlockNumber, WithHasName, WithSource {
public OsmHousenumberPoint(SourceFeature source, String mappingKey) { public OsmHousenumberPoint(SourceFeature source, String mappingKey) {
this(source.getString("addr:housenumber"), source); this(source.getString("addr:housenumber"), source.getString("addr:street"), source.getString("addr:block_number"),
source.getString("name"), source);
} }
/** Imposm3 "mapping" to filter OSM elements that should appear in this "table". */ /** Imposm3 "mapping" to filter OSM elements that should appear in this "table". */
@@ -708,12 +711,13 @@ public class Tables {
/** Imposm3 "mapping" to filter OSM elements that should appear in this "table". */ /** Imposm3 "mapping" to filter OSM elements that should appear in this "table". */
public static final Expression MAPPING = and(or(matchAny("aerialway", "station"), public static final Expression MAPPING = and(or(matchAny("aerialway", "station"),
matchAny("amenity", "arts_centre", "atm", "bank", "bar", "bbq", "bicycle_parking", "bicycle_rental", "biergarten", matchAny("amenity", "arts_centre", "atm", "bank", "bar", "bbq", "bicycle_parking", "bicycle_rental", "biergarten",
"bus_station", "cafe", "cinema", "clinic", "college", "community_centre", "courthouse", "dentist", "doctors", "bus_station", "cafe", "charging_station", "cinema", "clinic", "college", "community_centre", "courthouse",
"drinking_water", "fast_food", "ferry_terminal", "fire_station", "food_court", "fuel", "grave_yard", "hospital", "dentist", "doctors", "drinking_water", "fast_food", "ferry_terminal", "fire_station", "food_court", "fuel",
"ice_cream", "kindergarten", "library", "marketplace", "motorcycle_parking", "nightclub", "nursing_home", "grave_yard", "hospital", "ice_cream", "kindergarten", "library", "marketplace", "motorcycle_parking",
"parking", "pharmacy", "place_of_worship", "police", "parcel_locker", "post_box", "post_office", "prison", "nightclub", "nursing_home", "parking", "pharmacy", "place_of_worship", "police", "parcel_locker", "post_box",
"pub", "public_building", "recycling", "restaurant", "school", "shelter", "swimming_pool", "taxi", "telephone", "post_office", "prison", "pub", "public_building", "recycling", "restaurant", "school", "shelter",
"theatre", "toilets", "townhall", "university", "veterinary", "waste_basket"), "swimming_pool", "taxi", "telephone", "theatre", "toilets", "townhall", "university", "veterinary",
"waste_basket"),
matchAny("barrier", "bollard", "border_control", "cycle_barrier", "gate", "lift_gate", "sally_port", "stile", matchAny("barrier", "bollard", "border_control", "cycle_barrier", "gate", "lift_gate", "sally_port", "stile",
"toll_booth"), "toll_booth"),
matchAny("building", "dormitory"), matchAny("highway", "bus_stop"), matchAny("building", "dormitory"), matchAny("highway", "bus_stop"),
@@ -722,7 +726,15 @@ public class Tables {
matchAny("leisure", "dog_park", "escape_game", "garden", "golf_course", "ice_rink", "hackerspace", "marina", matchAny("leisure", "dog_park", "escape_game", "garden", "golf_course", "ice_rink", "hackerspace", "marina",
"miniature_golf", "park", "pitch", "playground", "sports_centre", "stadium", "swimming_area", "swimming_pool", "miniature_golf", "park", "pitch", "playground", "sports_centre", "stadium", "swimming_area", "swimming_pool",
"water_park"), "water_park"),
matchAny("office", "diplomatic"), matchAny("office", "accountant", "advertising_agency", "architect", "association", "bail_bond_agent", "charity",
"company", "construction_company", "consulting", "cooperative", "courier", "coworking", "diplomatic",
"educational_institution", "employment_agency", "energy_supplier", "engineer", "estate_agent", "financial",
"financial_advisor", "forestry", "foundation", "geodesist", "government", "graphic_design", "guide",
"harbour_master", "health_insurance", "insurance", "interior_design", "it", "lawyer", "logistics", "marketing",
"moving_company", "newspaper", "ngo", "notary", "physician", "political_party", "private_investigator",
"property_management", "publisher", "quango", "religion", "research", "security", "surveyor", "tax_advisor",
"taxi", "telecommunication", "therapist", "translator", "travel_agent", "tutoring", "union", "university",
"water_utility", "web_design", "wedding_planner"),
matchAny("railway", "halt", "station", "subway_entrance", "train_station_entrance", "tram_stop"), matchAny("railway", "halt", "station", "subway_entrance", "train_station_entrance", "tram_stop"),
matchAny("shop", "accessories", "alcohol", "antiques", "art", "bag", "bakery", "beauty", "bed", "beverages", matchAny("shop", "accessories", "alcohol", "antiques", "art", "bag", "bakery", "beauty", "bed", "beverages",
"bicycle", "books", "boutique", "butcher", "camera", "car", "car_repair", "car_parts", "carpet", "charity", "bicycle", "books", "boutique", "butcher", "camera", "car", "car_repair", "car_parts", "carpet", "charity",
@@ -731,9 +743,9 @@ public class Tables {
"erotic", "fabric", "florist", "frozen_food", "furniture", "garden_centre", "general", "gift", "greengrocer", "erotic", "fabric", "florist", "frozen_food", "furniture", "garden_centre", "general", "gift", "greengrocer",
"hairdresser", "hardware", "hearing_aids", "hifi", "ice_cream", "interior_decoration", "jewelry", "kiosk", "hairdresser", "hardware", "hearing_aids", "hifi", "ice_cream", "interior_decoration", "jewelry", "kiosk",
"lamps", "laundry", "locksmith", "mall", "massage", "mobile_phone", "motorcycle", "music", "musical_instrument", "lamps", "laundry", "locksmith", "mall", "massage", "mobile_phone", "motorcycle", "music", "musical_instrument",
"newsagent", "optician", "outdoor", "perfume", "perfumery", "pet", "photo", "second_hand", "shoes", "sports", "newsagent", "optician", "outdoor", "paint", "perfume", "perfumery", "pet", "photo", "second_hand", "shoes",
"stationery", "supermarket", "tailor", "tattoo", "ticket", "tobacco", "toys", "travel_agency", "video", "sports", "stationery", "supermarket", "tailor", "tattoo", "ticket", "tobacco", "toys", "travel_agency",
"video_games", "watches", "weapons", "wholesale", "wine"), "video", "video_games", "watches", "weapons", "wholesale", "wine"),
matchAny("sport", "american_football", "archery", "athletics", "australian_football", "badminton", "baseball", matchAny("sport", "american_football", "archery", "athletics", "australian_football", "badminton", "baseball",
"basketball", "beachvolleyball", "billiards", "bmx", "boules", "bowls", "boxing", "canadian_football", "canoe", "basketball", "beachvolleyball", "billiards", "bmx", "boules", "bowls", "boxing", "canadian_football", "canoe",
"chess", "climbing", "climbing_adventure", "cricket", "cricket_nets", "croquet", "curling", "cycling", "chess", "climbing", "climbing_adventure", "cricket", "cricket_nets", "croquet", "curling", "cycling",
@@ -778,12 +790,13 @@ public class Tables {
/** Imposm3 "mapping" to filter OSM elements that should appear in this "table". */ /** Imposm3 "mapping" to filter OSM elements that should appear in this "table". */
public static final Expression MAPPING = and(or(matchAny("aerialway", "station"), public static final Expression MAPPING = and(or(matchAny("aerialway", "station"),
matchAny("amenity", "arts_centre", "atm", "bank", "bar", "bbq", "bicycle_parking", "bicycle_rental", "biergarten", matchAny("amenity", "arts_centre", "atm", "bank", "bar", "bbq", "bicycle_parking", "bicycle_rental", "biergarten",
"bus_station", "cafe", "cinema", "clinic", "college", "community_centre", "courthouse", "dentist", "doctors", "bus_station", "cafe", "charging_station", "cinema", "clinic", "college", "community_centre", "courthouse",
"drinking_water", "fast_food", "ferry_terminal", "fire_station", "food_court", "fuel", "grave_yard", "hospital", "dentist", "doctors", "drinking_water", "fast_food", "ferry_terminal", "fire_station", "food_court", "fuel",
"ice_cream", "kindergarten", "library", "marketplace", "motorcycle_parking", "nightclub", "nursing_home", "grave_yard", "hospital", "ice_cream", "kindergarten", "library", "marketplace", "motorcycle_parking",
"parking", "pharmacy", "place_of_worship", "police", "parcel_locker", "post_box", "post_office", "prison", "nightclub", "nursing_home", "parking", "pharmacy", "place_of_worship", "police", "parcel_locker", "post_box",
"pub", "public_building", "recycling", "restaurant", "school", "shelter", "swimming_pool", "taxi", "telephone", "post_office", "prison", "pub", "public_building", "recycling", "restaurant", "school", "shelter",
"theatre", "toilets", "townhall", "university", "veterinary", "waste_basket"), "swimming_pool", "taxi", "telephone", "theatre", "toilets", "townhall", "university", "veterinary",
"waste_basket"),
matchAny("barrier", "bollard", "border_control", "cycle_barrier", "gate", "lift_gate", "sally_port", "stile", matchAny("barrier", "bollard", "border_control", "cycle_barrier", "gate", "lift_gate", "sally_port", "stile",
"toll_booth"), "toll_booth"),
matchAny("building", "dormitory"), matchAny("highway", "bus_stop"), matchAny("building", "dormitory"), matchAny("highway", "bus_stop"),
@@ -792,7 +805,15 @@ public class Tables {
matchAny("leisure", "dog_park", "escape_game", "garden", "golf_course", "ice_rink", "hackerspace", "marina", matchAny("leisure", "dog_park", "escape_game", "garden", "golf_course", "ice_rink", "hackerspace", "marina",
"miniature_golf", "park", "pitch", "playground", "sports_centre", "stadium", "swimming_area", "swimming_pool", "miniature_golf", "park", "pitch", "playground", "sports_centre", "stadium", "swimming_area", "swimming_pool",
"water_park"), "water_park"),
matchAny("office", "diplomatic"), matchAny("office", "accountant", "advertising_agency", "architect", "association", "bail_bond_agent", "charity",
"company", "construction_company", "consulting", "cooperative", "courier", "coworking", "diplomatic",
"educational_institution", "employment_agency", "energy_supplier", "engineer", "estate_agent", "financial",
"financial_advisor", "forestry", "foundation", "geodesist", "government", "graphic_design", "guide",
"harbour_master", "health_insurance", "insurance", "interior_design", "it", "lawyer", "logistics", "marketing",
"moving_company", "newspaper", "ngo", "notary", "physician", "political_party", "private_investigator",
"property_management", "publisher", "quango", "religion", "research", "security", "surveyor", "tax_advisor",
"taxi", "telecommunication", "therapist", "translator", "travel_agent", "tutoring", "union", "university",
"water_utility", "web_design", "wedding_planner"),
matchAny("railway", "halt", "station", "subway_entrance", "train_station_entrance", "tram_stop"), matchAny("railway", "halt", "station", "subway_entrance", "train_station_entrance", "tram_stop"),
matchAny("shop", "accessories", "alcohol", "antiques", "art", "bag", "bakery", "beauty", "bed", "beverages", matchAny("shop", "accessories", "alcohol", "antiques", "art", "bag", "bakery", "beauty", "bed", "beverages",
"bicycle", "books", "boutique", "butcher", "camera", "car", "car_repair", "car_parts", "carpet", "charity", "bicycle", "books", "boutique", "butcher", "camera", "car", "car_repair", "car_parts", "carpet", "charity",
@@ -801,9 +822,9 @@ public class Tables {
"erotic", "fabric", "florist", "frozen_food", "furniture", "garden_centre", "general", "gift", "greengrocer", "erotic", "fabric", "florist", "frozen_food", "furniture", "garden_centre", "general", "gift", "greengrocer",
"hairdresser", "hardware", "hearing_aids", "hifi", "ice_cream", "interior_decoration", "jewelry", "kiosk", "hairdresser", "hardware", "hearing_aids", "hifi", "ice_cream", "interior_decoration", "jewelry", "kiosk",
"lamps", "laundry", "locksmith", "mall", "massage", "mobile_phone", "motorcycle", "music", "musical_instrument", "lamps", "laundry", "locksmith", "mall", "massage", "mobile_phone", "motorcycle", "music", "musical_instrument",
"newsagent", "optician", "outdoor", "perfume", "perfumery", "pet", "photo", "second_hand", "shoes", "sports", "newsagent", "optician", "outdoor", "paint", "perfume", "perfumery", "pet", "photo", "second_hand", "shoes",
"stationery", "supermarket", "tailor", "tattoo", "ticket", "tobacco", "toys", "travel_agency", "video", "sports", "stationery", "supermarket", "tailor", "tattoo", "ticket", "tobacco", "toys", "travel_agency",
"video_games", "watches", "weapons", "wholesale", "wine"), "video", "video_games", "watches", "weapons", "wholesale", "wine"),
matchAny("sport", "american_football", "archery", "athletics", "australian_football", "badminton", "baseball", matchAny("sport", "american_football", "archery", "athletics", "australian_football", "badminton", "baseball",
"basketball", "beachvolleyball", "billiards", "bmx", "boules", "bowls", "boxing", "canadian_football", "canoe", "basketball", "beachvolleyball", "billiards", "bmx", "boules", "bowls", "boxing", "canadian_football", "canoe",
"chess", "climbing", "climbing_adventure", "cricket", "cricket_nets", "croquet", "curling", "cycling", "chess", "climbing", "climbing_adventure", "cricket", "cricket_nets", "croquet", "curling", "cycling",
@@ -885,6 +906,11 @@ public class Tables {
String bicycle(); String bicycle();
} }
/** Rows with a String blockNumber attribute. */
public interface WithBlockNumber {
String blockNumber();
}
/** Rows with a String boundary attribute. */ /** Rows with a String boundary attribute. */
public interface WithBoundary { public interface WithBoundary {
String boundary(); String boundary();
@@ -965,6 +991,11 @@ public class Tables {
String funicular(); String funicular();
} }
/** Rows with a String hasName attribute. */
public interface WithHasName {
String hasName();
}
/** Rows with a String height attribute. */ /** Rows with a String height attribute. */
public interface WithHeight { public interface WithHeight {
String height(); String height();
@@ -1225,6 +1256,11 @@ public class Tables {
String station(); String station();
} }
/** Rows with a String street attribute. */
public interface WithStreet {
String street();
}
/** Rows with a String subclass attribute. */ /** Rows with a String subclass attribute. */
public interface WithSubclass { public interface WithSubclass {
String subclass(); String subclass();
@@ -1245,6 +1281,11 @@ public class Tables {
String tourism(); String tourism();
} }
/** Rows with a String tracktype attribute. */
public interface WithTracktype {
String tracktype();
}
/** Rows with a String uicRef attribute. */ /** Rows with a String uicRef attribute. */
public interface WithUicRef { public interface WithUicRef {
String uicRef(); String uicRef();

View File

@@ -43,9 +43,18 @@ import com.onthegomap.planetiler.config.PlanetilerConfig;
import com.onthegomap.planetiler.geo.GeometryException; import com.onthegomap.planetiler.geo.GeometryException;
import com.onthegomap.planetiler.stats.Stats; import com.onthegomap.planetiler.stats.Stats;
import com.onthegomap.planetiler.util.Translations; import com.onthegomap.planetiler.util.Translations;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.function.Predicate;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import org.openmaptiles.generated.OpenMapTilesSchema; import org.openmaptiles.generated.OpenMapTilesSchema;
import org.openmaptiles.generated.Tables; import org.openmaptiles.generated.Tables;
import org.openmaptiles.util.Utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* Defines the logic for generating map elements in the {@code housenumber} layer from source features. * Defines the logic for generating map elements in the {@code housenumber} layer from source features.
@@ -59,19 +68,96 @@ public class Housenumber implements
Tables.OsmHousenumberPoint.Handler, Tables.OsmHousenumberPoint.Handler,
ForwardingProfile.FeaturePostProcessor { ForwardingProfile.FeaturePostProcessor {
public Housenumber(Translations translations, PlanetilerConfig config, Stats stats) {} private static final Logger LOGGER = LoggerFactory.getLogger(Housenumber.class);
private static final String OSM_SEPARATOR = ";";
private static final String DISPLAY_SEPARATOR = "";
private static final Pattern NO_CONVERSION_PATTERN = Pattern.compile("[^0-9;]");
private static final String TEMP_PARTITION = "_partition";
private static final String TEMP_HAS_NAME = "_has_name";
private static final Comparator<VectorTile.Feature> BY_TEMP_HAS_NAME = Comparator
.comparing(i -> (Boolean) i.attrs().get(TEMP_HAS_NAME), Boolean::compare);
private final Stats stats;
public Housenumber(Translations translations, PlanetilerConfig config, Stats stats) {
this.stats = stats;
}
private static String displayHousenumberNonumeric(List<String> numbers) {
return numbers.getFirst()
.concat(DISPLAY_SEPARATOR)
.concat(numbers.getLast());
}
protected static String displayHousenumber(String housenumber) {
if (!housenumber.contains(OSM_SEPARATOR)) {
return housenumber;
}
List<String> numbers = Arrays.stream(housenumber.split(OSM_SEPARATOR))
.map(String::trim)
.filter(Predicate.not(String::isEmpty))
.toList();
if (numbers.isEmpty()) {
// not much to do with strange/invalid entries like "3;" or ";" etc.
return housenumber;
}
Matcher matcher = NO_CONVERSION_PATTERN.matcher(housenumber);
if (matcher.find()) {
return displayHousenumberNonumeric(numbers);
}
// numeric display house number
var statistics = numbers.stream()
.collect(Collectors.summarizingLong(Long::parseUnsignedLong));
return String.valueOf(statistics.getMin())
.concat(DISPLAY_SEPARATOR)
.concat(String.valueOf(statistics.getMax()));
}
@Override @Override
public void process(Tables.OsmHousenumberPoint element, FeatureCollector features) { public void process(Tables.OsmHousenumberPoint element, FeatureCollector features) {
String housenumber;
try {
housenumber = displayHousenumber(element.housenumber());
} catch (NumberFormatException e) {
// should not be happening (thanks to NO_CONVERSION_PATTERN) but ...
stats.dataError("housenumber_range");
LOGGER.warn("Failed to convert housenumber range: {}", element.housenumber());
housenumber = element.housenumber();
}
String partition = Utils.coalesce(element.street(), "")
.concat(Utils.coalesce(element.blockNumber(), ""))
.concat(housenumber);
Boolean hasName = element.hasName() == null ? Boolean.FALSE : !element.hasName().isEmpty();
features.centroidIfConvex(LAYER_NAME) features.centroidIfConvex(LAYER_NAME)
.setBufferPixels(BUFFER_SIZE) .setBufferPixels(BUFFER_SIZE)
.setAttr(Fields.HOUSENUMBER, element.housenumber()) .setAttr(Fields.HOUSENUMBER, housenumber)
.setAttr(TEMP_PARTITION, partition)
.setAttr(TEMP_HAS_NAME, hasName)
.setMinZoom(14); .setMinZoom(14);
} }
@Override @Override
public List<VectorTile.Feature> postProcess(int zoom, List<VectorTile.Feature> list) throws GeometryException { public List<VectorTile.Feature> postProcess(int zoom, List<VectorTile.Feature> list) throws GeometryException {
// remove duplicate house numbers, features without name tag are prioritized
var items = list.stream()
.collect(Collectors.groupingBy(f -> f.attrs().get(TEMP_PARTITION)))
.values().stream()
.flatMap(
g -> g.stream().min(BY_TEMP_HAS_NAME).stream()
)
.toList();
// remove temporary attributes
for (var item : items) {
item.attrs().remove(TEMP_HAS_NAME);
item.attrs().remove(TEMP_PARTITION);
}
// reduces the size of some heavy z14 tiles with many repeated housenumber values by 60% or more // reduces the size of some heavy z14 tiles with many repeated housenumber values by 60% or more
return FeatureMerge.mergeMultiPoint(list); return FeatureMerge.mergeMultiPoint(items);
} }
} }

View File

@@ -91,15 +91,20 @@ public class Park implements
@Override @Override
public void process(Tables.OsmParkPolygon element, FeatureCollector features) { public void process(Tables.OsmParkPolygon element, FeatureCollector features) {
String clazz;
if ("aboriginal_lands".equals(element.boundary())) {
clazz = "aboriginal_lands";
} else {
String protectionTitle = element.protectionTitle(); String protectionTitle = element.protectionTitle();
if (protectionTitle != null) { if (protectionTitle != null) {
protectionTitle = protectionTitle.replace(' ', '_').toLowerCase(Locale.ROOT); protectionTitle = protectionTitle.replace(' ', '_').toLowerCase(Locale.ROOT);
} }
String clazz = coalesce( clazz = coalesce(
nullIfEmpty(protectionTitle), nullIfEmpty(protectionTitle),
nullIfEmpty(element.boundary()), nullIfEmpty(element.boundary()),
nullIfEmpty(element.leisure()) nullIfEmpty(element.leisure())
); );
}
// park shape // park shape
var outline = features.polygon(LAYER_NAME).setBufferPixels(BUFFER_SIZE) var outline = features.polygon(LAYER_NAME).setBufferPixels(BUFFER_SIZE)
@@ -138,7 +143,7 @@ public class Park implements
// sql filter: area > 70000*2^(20-zoom_level) // sql filter: area > 70000*2^(20-zoom_level)
// simplifies to: zoom_level > 20 - log(area / 70000) / log(2) // simplifies to: zoom_level > 20 - log(area / 70000) / log(2)
int minzoom = (int) Math.floor(20 - Math.log(area / WORLD_AREA_FOR_70K_SQUARE_METERS) / LOG2); int minzoom = (int) Math.floor(20 - Math.log(area / WORLD_AREA_FOR_70K_SQUARE_METERS) / LOG2);
minzoom = Math.min(14, Math.max(5, minzoom)); minzoom = Math.clamp(minzoom, 5, 14);
return minzoom; return minzoom;
} }

View File

@@ -235,7 +235,7 @@ public class Place implements
rank = country.rank; rank = country.rank;
} }
rank = Math.max(1, Math.min(6, rank)); rank = Math.clamp(rank, 1, 6);
features.point(LAYER_NAME).setBufferPixels(BUFFER_SIZE) features.point(LAYER_NAME).setBufferPixels(BUFFER_SIZE)
.putAttrs(names) .putAttrs(names)
@@ -261,7 +261,7 @@ public class Place implements
if (nullOrEmpty(names.get(Fields.NAME_EN))) { if (nullOrEmpty(names.get(Fields.NAME_EN))) {
names.put(Fields.NAME_EN, state.name); names.put(Fields.NAME_EN, state.name);
} }
int rank = Math.min(6, Math.max(1, state.rank)); int rank = Math.clamp(state.rank, 1, 6);
features.point(LAYER_NAME).setBufferPixels(BUFFER_SIZE) features.point(LAYER_NAME).setBufferPixels(BUFFER_SIZE)
.putAttrs(names) .putAttrs(names)

View File

@@ -48,14 +48,26 @@ import com.onthegomap.planetiler.VectorTile;
import com.onthegomap.planetiler.collection.Hppc; import com.onthegomap.planetiler.collection.Hppc;
import com.onthegomap.planetiler.config.PlanetilerConfig; import com.onthegomap.planetiler.config.PlanetilerConfig;
import com.onthegomap.planetiler.expression.MultiExpression; import com.onthegomap.planetiler.expression.MultiExpression;
import com.onthegomap.planetiler.geo.GeoUtils;
import com.onthegomap.planetiler.geo.GeometryException;
import com.onthegomap.planetiler.reader.SimpleFeature;
import com.onthegomap.planetiler.stats.Stats; import com.onthegomap.planetiler.stats.Stats;
import com.onthegomap.planetiler.util.Parse; import com.onthegomap.planetiler.util.Parse;
import com.onthegomap.planetiler.util.Translations; import com.onthegomap.planetiler.util.Translations;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
import java.util.function.Consumer;
import org.locationtech.jts.geom.Point;
import org.openmaptiles.OpenMapTilesProfile;
import org.openmaptiles.generated.OpenMapTilesSchema; import org.openmaptiles.generated.OpenMapTilesSchema;
import org.openmaptiles.generated.Tables; import org.openmaptiles.generated.Tables;
import org.openmaptiles.util.OmtLanguageUtils; import org.openmaptiles.util.OmtLanguageUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* Defines the logic for generating map elements for things like shops, parks, and schools in the {@code poi} layer from * Defines the logic for generating map elements for things like shops, parks, and schools in the {@code poi} layer from
@@ -68,13 +80,15 @@ public class Poi implements
OpenMapTilesSchema.Poi, OpenMapTilesSchema.Poi,
Tables.OsmPoiPoint.Handler, Tables.OsmPoiPoint.Handler,
Tables.OsmPoiPolygon.Handler, Tables.OsmPoiPolygon.Handler,
ForwardingProfile.FeaturePostProcessor { ForwardingProfile.FeaturePostProcessor,
OpenMapTilesProfile.FinishHandler {
/* /*
* process() creates the raw POI feature from OSM elements and postProcess() * process() creates the raw POI feature from OSM elements and postProcess()
* assigns the feature rank from order in the tile at render-time. * assigns the feature rank from order in the tile at render-time.
*/ */
private static final Logger LOGGER = LoggerFactory.getLogger(Poi.class);
private static final Map<String, Integer> CLASS_RANKS = Map.ofEntries( private static final Map<String, Integer> CLASS_RANKS = Map.ofEntries(
entry(FieldValues.CLASS_HOSPITAL, 20), entry(FieldValues.CLASS_HOSPITAL, 20),
entry(FieldValues.CLASS_RAILWAY, 40), entry(FieldValues.CLASS_RAILWAY, 40),
@@ -99,12 +113,25 @@ public class Poi implements
entry(FieldValues.CLASS_CLOTHING_STORE, 700), entry(FieldValues.CLASS_CLOTHING_STORE, 700),
entry(FieldValues.CLASS_BAR, 800) entry(FieldValues.CLASS_BAR, 800)
); );
private static final Set<String> UNIVERSITY_POI_SUBCLASSES = Set.of("university", "college");
private static final List<String> AGG_STOP_SUBCLASS_ORDER = List.of(
"subway",
"tram_stop",
"bus_station",
"bus_stop"
);
private static final Comparator<Tables.OsmPoiPoint> BY_SUBCLASS = Comparator
.comparingInt(s -> AGG_STOP_SUBCLASS_ORDER.indexOf(s.subclass()));
private static final Set<String> BRAND_OPERATOR_REF_SUBCLASSES = Set.of("charging_station", "parcel_locker");
private final MultiExpression.Index<String> classMapping; private final MultiExpression.Index<String> classMapping;
private final Translations translations; private final Translations translations;
private final Stats stats;
private final Map<String, List<Tables.OsmPoiPoint>> aggStops = new HashMap<>();
public Poi(Translations translations, PlanetilerConfig config, Stats stats) { public Poi(Translations translations, PlanetilerConfig config, Stats stats) {
this.classMapping = FieldMappings.Class.index(); this.classMapping = FieldMappings.Class.index();
this.translations = translations; this.translations = translations;
this.stats = stats;
} }
static int poiClassRank(String clazz) { static int poiClassRank(String clazz) {
@@ -125,19 +152,112 @@ public class Poi implements
return lowZoom ? 12 : 14; return lowZoom ? 12 : 14;
} }
@Override
public void release() {
aggStops.clear();
}
@Override @Override
public void process(Tables.OsmPoiPoint element, FeatureCollector features) { public void process(Tables.OsmPoiPoint element, FeatureCollector features) {
// TODO handle uic_ref => agg_stop if (element.uicRef() != null && AGG_STOP_SUBCLASS_ORDER.contains(element.subclass())) {
setupPoiFeature(element, features.point(LAYER_NAME)); // multiple threads may update this concurrently
String aggStopKey = element.uicRef()
.concat(coalesce(nullIfEmpty(element.name()), ""))
.concat(coalesce(nullIfEmpty(element.network()), ""))
.concat(coalesce(nullIfEmpty(element.operator()), ""));
synchronized (this) {
aggStops.computeIfAbsent(aggStopKey, key -> new ArrayList<>()).add(element);
}
} else {
setupPoiFeature(element, features.point(LAYER_NAME), null);
}
}
private void processAggStop(Tables.OsmPoiPoint element, FeatureCollector.Factory featureCollectors,
Consumer<FeatureCollector.Feature> emit, Integer aggStop) {
try {
var features = featureCollectors.get(SimpleFeature.fromWorldGeometry(element.source().worldGeometry()));
setupPoiFeature(element, features.point(LAYER_NAME), aggStop);
for (var feature : features) {
emit.accept(feature);
}
} catch (GeometryException e) {
e.log(stats, "agg_stop_geometry_2",
"Error getting geometry for the stop " + element.source().id() + " (agg_stop)");
}
}
/**
* We've put aside some stops for {@code agg_stop} processing and we do that processing here.
* <p>
* The main point is to group together stops with same {@code uid_ref} and then order them first based on subclass
* (see {@code AGG_STOP_ORDER}) and then based on distance from centroid (calculated from all the stops). The first
* one gets {@code agg_stop=1}, the rest will be "normal" (e.g. no {@code agg_stop} attribute).
* <p>
* ref: <a href=
* "https://github.com/openmaptiles/openmaptiles/blob/master/layers/poi/poi_stop_agg.sql#L26,L28">poi_stop_agg.sql</a>
*/
@Override
public void finish(String sourceName, FeatureCollector.Factory featureCollectors,
Consumer<FeatureCollector.Feature> emit) {
if (OpenMapTilesProfile.OSM_SOURCE.equals(sourceName)) {
var timer = stats.startStage("agg_stop");
LOGGER.info("Processing {} agg_stop sets", aggStops.size());
for (var aggStopSet : aggStops.values()) {
if (aggStopSet.size() == 1) {
processAggStop(aggStopSet.getFirst(), featureCollectors, emit, 1);
continue;
}
Tables.OsmPoiPoint nearest = null;
try {
// find most important stops based on subclass
var firstSubclass = aggStopSet.stream().min(BY_SUBCLASS).get().subclass();
var topAggStops =
aggStopSet.stream().filter(s -> firstSubclass.equals(s.subclass())).toArray(Tables.OsmPoiPoint[]::new);
// calculate the centroid and ...
List<Point> aggStopPoints = new ArrayList<>(aggStopSet.size());
for (var aggStop : aggStopSet) {
aggStopPoints.add(aggStop.source().worldGeometry().getCentroid());
}
var aggStopCentroid = GeoUtils.combinePoints(aggStopPoints).getCentroid();
// ... find one stop nearest to the centroid
double minDistance = Double.MAX_VALUE;
for (var aggStop : topAggStops) {
double distance = aggStopCentroid.distance(aggStop.source().worldGeometry());
if (distance < minDistance) {
minDistance = distance;
nearest = aggStop;
}
}
} catch (GeometryException e) {
e.log(stats, "agg_stop_geometry_1",
"Error getting geometry for some of the stops with UIC ref. " + aggStopSet.getFirst().uicRef() +
" (agg_stop)");
// we're not able to calculate agg_stop, so simply dump the stops as they are
nearest = null;
}
// now emit the stops
final Tables.OsmPoiPoint nearestFinal = nearest; // final needed for lambda
aggStopSet
.forEach(s -> processAggStop(s, featureCollectors, emit, s == nearestFinal ? 1 : null));
}
timer.stop();
}
} }
@Override @Override
public void process(Tables.OsmPoiPolygon element, FeatureCollector features) { public void process(Tables.OsmPoiPolygon element, FeatureCollector features) {
setupPoiFeature(element, features.centroidIfConvex(LAYER_NAME)); setupPoiFeature(element, features.centroidIfConvex(LAYER_NAME), null);
} }
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( 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) { T element, FeatureCollector.Feature output, Integer aggStop) {
String rawSubclass = element.subclass(); String rawSubclass = element.subclass();
if ("station".equals(rawSubclass) && "subway".equals(element.station())) { if ("station".equals(rawSubclass) && "subway".equals(element.station())) {
rawSubclass = "subway"; rawSubclass = "subway";
@@ -157,7 +277,7 @@ public class Poi implements
} }
// Parcel locker without name: use either brand or operator and add ref if present // Parcel locker without name: use either brand or operator and add ref if present
if ("parcel_locker".equals(rawSubclass) && nullOrEmpty(name)) { if (BRAND_OPERATOR_REF_SUBCLASSES.contains(rawSubclass) && nullOrEmpty(name)) {
name = coalesce(nullIfEmpty(element.brand()), nullIfEmpty(element.operator())); name = coalesce(nullIfEmpty(element.brand()), nullIfEmpty(element.operator()));
String ref = nullIfEmpty(element.ref()); String ref = nullIfEmpty(element.ref());
if (ref != null) { if (ref != null) {
@@ -178,16 +298,24 @@ public class Poi implements
int poiClassRank = poiClassRank(poiClass); int poiClassRank = poiClassRank(poiClass);
int rankOrder = poiClassRank + ((nullOrEmpty(name)) ? 2000 : 0); int rankOrder = poiClassRank + ((nullOrEmpty(name)) ? 2000 : 0);
int minzoom = minzoom(element.subclass(), element.mappingKey());
if (UNIVERSITY_POI_SUBCLASSES.contains(rawSubclass)) {
// universities that are at least 10% of a tile may appear from Z10
output.setMinPixelSizeBelowZoom(13, 80); // 80x80px is ~10% of a 256x256px tile
minzoom = 10;
}
output.setBufferPixels(BUFFER_SIZE) output.setBufferPixels(BUFFER_SIZE)
.setAttr(Fields.CLASS, poiClass) .setAttr(Fields.CLASS, poiClass)
.setAttr(Fields.SUBCLASS, subclass) .setAttr(Fields.SUBCLASS, subclass)
.setAttr(Fields.LAYER, nullIfLong(element.layer(), 0)) .setAttr(Fields.LAYER, nullIfLong(element.layer(), 0))
.setAttr(Fields.LEVEL, Parse.parseLongOrNull(element.source().getTag("level"))) .setAttr(Fields.LEVEL, Parse.parseLongOrNull(element.source().getTag("level")))
.setAttr(Fields.INDOOR, element.indoor() ? 1 : null) .setAttr(Fields.INDOOR, element.indoor() ? 1 : null)
.setAttr(Fields.AGG_STOP, aggStop)
.putAttrs(OmtLanguageUtils.getNames(element.source().tags(), translations)) .putAttrs(OmtLanguageUtils.getNames(element.source().tags(), translations))
.setPointLabelGridPixelSize(14, 64) .setPointLabelGridPixelSize(14, 64)
.setSortKey(rankOrder) .setSortKey(rankOrder)
.setMinZoom(minzoom(element.subclass(), element.mappingKey())); .setMinZoom(minzoom);
} }
@Override @Override

View File

@@ -62,6 +62,7 @@ import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import java.util.Set; import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import java.util.regex.Matcher; import java.util.regex.Matcher;
@@ -103,7 +104,8 @@ public class Transportation implements
*/ */
private static final Logger LOGGER = LoggerFactory.getLogger(Transportation.class); private static final Logger LOGGER = LoggerFactory.getLogger(Transportation.class);
private static final Pattern GREAT_BRITAIN_REF_NETWORK_PATTERN = Pattern.compile("^[AM][0-9AM()]+"); private static final Pattern GREAT_BRITAIN_REF_NETWORK_PATTERN = Pattern.compile("^[ABM][0-9ABM()]+");
private static final Pattern IRELAND_REF_NETWORK_PATTERN = Pattern.compile("^[MNRL][0-9]+");
private static final MultiExpression.Index<String> classMapping = FieldMappings.Class.index(); private static final MultiExpression.Index<String> classMapping = FieldMappings.Class.index();
private static final Set<String> RAILWAY_RAIL_VALUES = Set.of( private static final Set<String> RAILWAY_RAIL_VALUES = Set.of(
FieldValues.SUBCLASS_RAIL, FieldValues.SUBCLASS_RAIL,
@@ -132,11 +134,22 @@ public class Transportation implements
); );
private static final Set<String> SURFACE_PAVED_VALUES = Set.of( private static final Set<String> SURFACE_PAVED_VALUES = Set.of(
"paved", "asphalt", "cobblestone", "concrete", "concrete:lanes", "concrete:plates", "metal", "paved", "asphalt", "cobblestone", "concrete", "concrete:lanes", "concrete:plates", "metal",
"paving_stones", "sett", "unhewn_cobblestone", "wood" "paving_stones", "sett", "unhewn_cobblestone", "wood", "grade1"
); );
private static final Set<String> ACCESS_NO_VALUES = Set.of( private static final Set<String> ACCESS_NO_VALUES = Set.of(
"private", "no" "private", "no"
); );
private static final Set<RouteNetwork> TRUNK_AS_MOTORWAY_BY_NETWORK = Set.of(
RouteNetwork.CA_TRANSCANADA,
RouteNetwork.CA_PROVINCIAL_ARTERIAL,
RouteNetwork.US_INTERSTATE
);
private static final Set<String> CA_AB_PRIMARY_AS_ARTERIAL_BY_REF = Set.of(
"2", "3", "4"
);
private static final Set<String> CA_BC_AS_ARTERIAL_BY_REF = Set.of(
"3", "5", "99"
);
private static final ZoomFunction.MeterToPixelThresholds MIN_LENGTH = ZoomFunction.meterThresholds() private static final ZoomFunction.MeterToPixelThresholds MIN_LENGTH = ZoomFunction.meterThresholds()
.put(7, 50) .put(7, 50)
.put(6, 100) .put(6, 100)
@@ -150,13 +163,15 @@ public class Transportation implements
.thenComparingInt(r -> r.ref().length()) .thenComparingInt(r -> r.ref().length())
.thenComparing(RouteRelation::ref); .thenComparing(RouteRelation::ref);
private static final Set<Integer> ONEWAY_VALUES = Set.of(-1, 1); private static final Set<Integer> ONEWAY_VALUES = Set.of(-1, 1);
private final Map<String, Integer> MINZOOMS;
private static final String LIMIT_MERGE_TAG = "__limit_merge"; private static final String LIMIT_MERGE_TAG = "__limit_merge";
private final AtomicBoolean loggedNoGb = new AtomicBoolean(false); private final AtomicBoolean loggedNoGb = new AtomicBoolean(false);
private final AtomicBoolean loggedNoIreland = new AtomicBoolean(false);
private final boolean z13Paths; private final boolean z13Paths;
private final Map<String, Integer> MINZOOMS;
private final Stats stats; private final Stats stats;
private final PlanetilerConfig config; private final PlanetilerConfig config;
private PreparedGeometry greatBritain = null; private PreparedGeometry greatBritain = null;
private PreparedGeometry ireland = null;
public Transportation(Translations translations, PlanetilerConfig config, Stats stats) { public Transportation(Translations translations, PlanetilerConfig config, Stats stats) {
this.config = config; this.config = config;
@@ -239,16 +254,32 @@ public class Transportation implements
@Override @Override
public void processNaturalEarth(String table, SourceFeature feature, public void processNaturalEarth(String table, SourceFeature feature,
FeatureCollector features) { FeatureCollector features) {
if ("ne_10m_admin_0_countries".equals(table) && feature.hasTag("iso_a2", "GB")) { if (!"ne_10m_admin_0_countries".equals(table)) {
// multiple threads call this method concurrently, GB polygon *should* only be found return;
}
// multiple threads call this method concurrently, GB (or IE) polygon *should* only be found
// once, but just to be safe synchronize updates to that field // once, but just to be safe synchronize updates to that field
synchronized (this) { if (feature.hasTag("iso_a2", "GB")) {
try { try {
Geometry boundary = feature.polygon().buffer(GeoUtils.metersToPixelAtEquator(0, 10_000) / 256d); var prepared = PreparedGeometryFactory.prepare(
greatBritain = PreparedGeometryFactory.prepare(boundary); feature.polygon().buffer(GeoUtils.metersToPixelAtEquator(0, 10_000) / 256d)
);
synchronized (this) {
greatBritain = prepared;
}
} catch (GeometryException e) { } catch (GeometryException e) {
LOGGER.error("Failed to get Great Britain Polygon: " + e); LOGGER.error("Failed to get Great Britain Polygon: " + e);
} }
} else if (feature.hasTag("iso_a2", "IE")) {
try {
var prepared = PreparedGeometryFactory.prepare(
feature.polygon().buffer(GeoUtils.metersToPixelAtEquator(0, 10_000) / 256d)
);
synchronized (this) {
ireland = prepared;
}
} catch (GeometryException e) {
LOGGER.error("Failed to get Ireland Polygon: " + e);
} }
} }
} }
@@ -268,6 +299,26 @@ public class Transportation implements
networkType = RouteNetwork.US_STATE; networkType = RouteNetwork.US_STATE;
} else if (network != null && network.startsWith("CA:transcanada")) { } else if (network != null && network.startsWith("CA:transcanada")) {
networkType = RouteNetwork.CA_TRANSCANADA; networkType = RouteNetwork.CA_TRANSCANADA;
} else if ("CA:QC:A".equals(network)) {
networkType = RouteNetwork.CA_PROVINCIAL_ARTERIAL;
} else if ("CA:ON:primary".equals(network)) {
if (ref != null && ref.length() == 3 && ref.startsWith("4")) {
networkType = RouteNetwork.CA_PROVINCIAL_ARTERIAL;
} else if ("QEW".equals(ref)) {
networkType = RouteNetwork.CA_PROVINCIAL_ARTERIAL;
} else {
networkType = RouteNetwork.CA_PROVINCIAL;
}
} else if ("CA:MB:PTH".equals(network) && "75".equals(ref)) {
networkType = RouteNetwork.CA_PROVINCIAL_ARTERIAL;
} else if ("CA:AB:primary".equals(network) && ref != null && CA_AB_PRIMARY_AS_ARTERIAL_BY_REF.contains(ref)) {
networkType = RouteNetwork.CA_PROVINCIAL_ARTERIAL;
} else if ("CA:BC".equals(network) && ref != null && CA_BC_AS_ARTERIAL_BY_REF.contains(ref)) {
networkType = RouteNetwork.CA_PROVINCIAL_ARTERIAL;
} else if (network != null && ((network.length() == 5 && network.startsWith("CA:")) ||
(network.length() >= 6 && network.startsWith("CA:") && network.charAt(5) == ':'))) {
// in SQL: LIKE 'CA:__' OR network LIKE 'CA:__:%'; but wanted to avoid regexp hence more ugly
networkType = RouteNetwork.CA_PROVINCIAL;
} }
int rank = switch (coalesce(network, "")) { int rank = switch (coalesce(network, "")) {
@@ -307,12 +358,15 @@ public class Transportation implements
try { try {
Geometry wayGeometry = element.source().worldGeometry(); Geometry wayGeometry = element.source().worldGeometry();
if (greatBritain.intersects(wayGeometry)) { if (greatBritain.intersects(wayGeometry)) {
Transportation.RouteNetwork networkType = Transportation.RouteNetwork networkType = switch (element.highway()) {
"motorway".equals(element.highway()) ? Transportation.RouteNetwork.GB_MOTORWAY : case "motorway" -> Transportation.RouteNetwork.GB_MOTORWAY;
Transportation.RouteNetwork.GB_TRUNK; case "trunk" -> RouteNetwork.GB_TRUNK;
String network = "motorway".equals(element.highway()) ? "omt-gb-motorway" : "omt-gb-trunk"; case "primary", "secondary" -> RouteNetwork.GB_PRIMARY;
result.add(new RouteRelation(refMatcher.group(), network, networkType, (byte) -1, default -> null;
0)); };
result.add(new RouteRelation(refMatcher.group(),
networkType == null ? null : networkType.network,
networkType, (byte) -1, 0));
} }
} catch (GeometryException e) { } catch (GeometryException e) {
e.log(stats, "omt_transportation_name_gb_test", e.log(stats, "omt_transportation_name_gb_test",
@@ -320,6 +374,31 @@ public class Transportation implements
} }
} }
} }
// Similarly Ireland.
refMatcher = IRELAND_REF_NETWORK_PATTERN.matcher(ref);
if (refMatcher.find()) {
if (ireland == null) {
if (!loggedNoIreland.get() && loggedNoIreland.compareAndSet(false, true)) {
LOGGER.warn("No IE polygon for inferring route network types");
}
} else {
try {
Geometry wayGeometry = element.source().worldGeometry();
if (ireland.intersects(wayGeometry)) {
String highway = coalesce(element.highway(), "");
Transportation.RouteNetwork networkType = switch (highway) {
case "motorway" -> Transportation.RouteNetwork.IE_MOTORWAY;
case "trunk", "primary" -> RouteNetwork.IE_NATIONAL;
default -> RouteNetwork.IE_REGIONAL;
};
result.add(new RouteRelation(refMatcher.group(), networkType.network, networkType, (byte) -1, 0));
}
} catch (GeometryException e) {
e.log(stats, "omt_transportation_name_ie_test",
"Unable to test highway against IE route network: " + element.source().id());
}
}
}
} }
Collections.sort(result); Collections.sort(result);
return result; return result;
@@ -362,13 +441,11 @@ public class Transportation implements
.setAttr(Fields.CLASS, highwayClass) .setAttr(Fields.CLASS, highwayClass)
.setAttr(Fields.SUBCLASS, highwaySubclass(highwayClass, element.publicTransport(), highway)) .setAttr(Fields.SUBCLASS, highwaySubclass(highwayClass, element.publicTransport(), highway))
.setAttr(Fields.NETWORK, networkType != null ? networkType.name : null) .setAttr(Fields.NETWORK, networkType != null ? networkType.name : null)
// TODO: including brunnel at low zooms leads to some large 300-400+kb z4-7 tiles, instead .setAttrWithMinSize(Fields.BRUNNEL, brunnel(element.isBridge(), element.isTunnel(), element.isFord()), 4, 4, 12)
// we should only set brunnel if the line is above a certain length
.setAttr(Fields.BRUNNEL, brunnel(element.isBridge(), element.isTunnel(), element.isFord()))
// z8+ // z8+
.setAttrWithMinzoom(Fields.EXPRESSWAY, element.expressway() && !"motorway".equals(highway) ? 1 : null, 8) .setAttrWithMinzoom(Fields.EXPRESSWAY, element.expressway() && !"motorway".equals(highway) ? 1 : null, 8)
// z9+ // z9+
.setAttrWithMinzoom(Fields.LAYER, nullIfLong(element.layer(), 0), 9) .setAttrWithMinSize(Fields.LAYER, nullIfLong(element.layer(), 0), 4, 9, 12)
.setAttrWithMinzoom(Fields.BICYCLE, nullIfEmpty(element.bicycle()), 9) .setAttrWithMinzoom(Fields.BICYCLE, nullIfEmpty(element.bicycle()), 9)
.setAttrWithMinzoom(Fields.FOOT, nullIfEmpty(element.foot()), 9) .setAttrWithMinzoom(Fields.FOOT, nullIfEmpty(element.foot()), 9)
.setAttrWithMinzoom(Fields.HORSE, nullIfEmpty(element.horse()), 9) .setAttrWithMinzoom(Fields.HORSE, nullIfEmpty(element.horse()), 9)
@@ -381,7 +458,7 @@ public class Transportation implements
// z12+ // z12+
.setAttrWithMinzoom(Fields.SERVICE, service, 12) .setAttrWithMinzoom(Fields.SERVICE, service, 12)
.setAttrWithMinzoom(Fields.ONEWAY, nullIfInt(element.isOneway(), 0), 12) .setAttrWithMinzoom(Fields.ONEWAY, nullIfInt(element.isOneway(), 0), 12)
.setAttrWithMinzoom(Fields.SURFACE, surface(element.surface()), 12) .setAttrWithMinzoom(Fields.SURFACE, surface(coalesce(element.surface(), element.tracktype())), 12)
.setMinPixelSize(0) // merge during post-processing, then limit by size .setMinPixelSize(0) // merge during post-processing, then limit by size
.setSortKey(element.zOrder()) .setSortKey(element.zOrder())
.setMinZoom(minzoom); .setMinZoom(minzoom);
@@ -415,6 +492,14 @@ public class Transportation implements
case FieldValues.CLASS_SERVICE -> isDrivewayOrParkingAisle(service(element.service())) ? 14 : 13; case FieldValues.CLASS_SERVICE -> isDrivewayOrParkingAisle(service(element.service())) ? 14 : 13;
case FieldValues.CLASS_TRACK, FieldValues.CLASS_PATH -> routeRank == 1 ? 12 : case FieldValues.CLASS_TRACK, FieldValues.CLASS_PATH -> routeRank == 1 ? 12 :
(z13Paths || !nullOrEmpty(element.name()) || routeRank <= 2 || !nullOrEmpty(element.sacScale())) ? 13 : 14; (z13Paths || !nullOrEmpty(element.name()) || routeRank <= 2 || !nullOrEmpty(element.sacScale())) ? 13 : 14;
case FieldValues.CLASS_TRUNK -> {
// trunks in some networks to have same min. zoom as highway = "motorway"
String clazz = routeRelations.stream()
.map(RouteRelation::networkType)
.filter(Objects::nonNull)
.anyMatch(TRUNK_AS_MOTORWAY_BY_NETWORK::contains) ? FieldValues.CLASS_MOTORWAY : FieldValues.CLASS_TRUNK;
yield MINZOOMS.getOrDefault(clazz, Integer.MAX_VALUE);
}
default -> MINZOOMS.getOrDefault(baseClass, Integer.MAX_VALUE); default -> MINZOOMS.getOrDefault(baseClass, Integer.MAX_VALUE);
}; };
} }
@@ -463,7 +548,6 @@ public class Transportation implements
.setAttr(Fields.CLASS, clazz) .setAttr(Fields.CLASS, clazz)
.setAttr(Fields.SUBCLASS, railway) .setAttr(Fields.SUBCLASS, railway)
.setAttr(Fields.SERVICE, service(service)) .setAttr(Fields.SERVICE, service(service))
.setAttr(Fields.ONEWAY, nullIfInt(element.isOneway(), 0))
.setAttr(Fields.RAMP, element.isRamp() ? 1L : null) .setAttr(Fields.RAMP, element.isRamp() ? 1L : null)
.setAttrWithMinzoom(Fields.BRUNNEL, brunnel(element.isBridge(), element.isTunnel(), element.isFord()), 10) .setAttrWithMinzoom(Fields.BRUNNEL, brunnel(element.isBridge(), element.isTunnel(), element.isFord()), 10)
.setAttrWithMinzoom(Fields.LAYER, nullIfLong(element.layer(), 0), 9) .setAttrWithMinzoom(Fields.LAYER, nullIfLong(element.layer(), 0), 9)
@@ -494,13 +578,13 @@ public class Transportation implements
.setAttr(Fields.CLASS, element.shipway()) // "ferry" .setAttr(Fields.CLASS, element.shipway()) // "ferry"
// no subclass // no subclass
.setAttr(Fields.SERVICE, service(element.service())) .setAttr(Fields.SERVICE, service(element.service()))
.setAttr(Fields.ONEWAY, nullIfInt(element.isOneway(), 0))
.setAttr(Fields.RAMP, element.isRamp() ? 1L : null) .setAttr(Fields.RAMP, element.isRamp() ? 1L : null)
.setAttr(Fields.BRUNNEL, brunnel(element.isBridge(), element.isTunnel(), element.isFord())) .setAttr(Fields.BRUNNEL, brunnel(element.isBridge(), element.isTunnel(), element.isFord()))
.setAttr(Fields.LAYER, nullIfLong(element.layer(), 0)) .setAttr(Fields.LAYER, nullIfLong(element.layer(), 0))
.setSortKey(element.zOrder()) .setSortKey(element.zOrder())
.setMinPixelSize(0) // merge during post-processing, then limit by size .setMinPixelSize(0) // merge during post-processing, then limit by size
.setMinZoom(11); .setMinZoom(4)
.setMinPixelSizeBelowZoom(10, 32); // `sql_filter: ST_Length(...)` used in OpenMapTiles translates to 32px
} }
@Override @Override
@@ -548,17 +632,25 @@ public class Transportation implements
enum RouteNetwork { enum RouteNetwork {
US_INTERSTATE("us-interstate"), US_INTERSTATE("us-interstate", null),
US_HIGHWAY("us-highway"), US_HIGHWAY("us-highway", null),
US_STATE("us-state"), US_STATE("us-state", null),
CA_TRANSCANADA("ca-transcanada"), CA_TRANSCANADA("ca-transcanada", null),
GB_MOTORWAY("gb-motorway"), CA_PROVINCIAL_ARTERIAL("ca-provincial-arterial", null),
GB_TRUNK("gb-trunk"); CA_PROVINCIAL("ca-provincial", null),
GB_MOTORWAY("gb-motorway", "omt-gb-motorway"),
GB_TRUNK("gb-trunk", "omt-gb-trunk"),
GB_PRIMARY("gb-primary", "omt-gb-primary"),
IE_MOTORWAY("ie-motorway", "omt-ie-motorway"),
IE_NATIONAL("ie-national", "omt-ie-national"),
IE_REGIONAL("ie-regional", "omt-ie-regional");
final String name; final String name;
final String network;
RouteNetwork(String name) { RouteNetwork(String name, String network) {
this.name = name; this.name = name;
this.network = network;
} }
} }

View File

@@ -111,8 +111,8 @@ public class TransportationName implements
.put(7, 20_000) .put(7, 20_000)
.put(8, 14_000) .put(8, 14_000)
.put(9, 8_000) .put(9, 8_000)
.put(10, 8_000) .put(10, 4_000)
.put(11, 8_000); .put(11, 2_000);
private final boolean brunnel; private final boolean brunnel;
private final boolean sizeForShield; private final boolean sizeForShield;
private final boolean limitMerge; private final boolean limitMerge;
@@ -279,7 +279,9 @@ public class TransportationName implements
} }
if (brunnel) { if (brunnel) {
feature.setAttr(Fields.BRUNNEL, brunnel(element.isBridge(), element.isTunnel(), element.isFord())); // from OMT: "Drop brunnel if length of way < 2% of tile width (less than 3 pixels)"
feature.setAttrWithMinSize(Fields.BRUNNEL, brunnel(element.isBridge(), element.isTunnel(), element.isFord()),
3, 4, 12);
} }
/* /*

View File

@@ -35,6 +35,7 @@ See https://github.com/openmaptiles/openmaptiles/blob/master/LICENSE.md for deta
*/ */
package org.openmaptiles.layers; package org.openmaptiles.layers;
import static org.openmaptiles.util.Utils.coalesce;
import static org.openmaptiles.util.Utils.nullIfEmpty; import static org.openmaptiles.util.Utils.nullIfEmpty;
import com.carrotsearch.hppc.LongObjectMap; import com.carrotsearch.hppc.LongObjectMap;
@@ -48,6 +49,7 @@ import com.onthegomap.planetiler.stats.Stats;
import com.onthegomap.planetiler.util.Parse; import com.onthegomap.planetiler.util.Parse;
import com.onthegomap.planetiler.util.Translations; import com.onthegomap.planetiler.util.Translations;
import java.util.Map; import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentSkipListMap; import java.util.concurrent.ConcurrentSkipListMap;
import org.locationtech.jts.geom.Geometry; import org.locationtech.jts.geom.Geometry;
import org.openmaptiles.OpenMapTilesProfile; import org.openmaptiles.OpenMapTilesProfile;
@@ -80,9 +82,7 @@ public class WaterName implements
*/ */
private static final Logger LOGGER = LoggerFactory.getLogger(WaterName.class); private static final Logger LOGGER = LoggerFactory.getLogger(WaterName.class);
private static final double WORLD_AREA_FOR_70K_SQUARE_METERS = private static final Set<String> SEA_OR_OCEAN_PLACE = Set.of("sea", "ocean");
Math.pow(GeoUtils.metersToPixelAtEquator(0, Math.sqrt(70_000)) / 256d, 2);
private static final double LOG2 = Math.log(2);
private final Translations translations; private final Translations translations;
// need to synchronize updates from multiple threads // need to synchronize updates from multiple threads
private final LongObjectMap<Geometry> lakeCenterlines = Hppc.newLongObjectHashMap(); private final LongObjectMap<Geometry> lakeCenterlines = Hppc.newLongObjectHashMap();
@@ -141,7 +141,10 @@ public class WaterName implements
@Override @Override
public void process(Tables.OsmMarinePoint element, FeatureCollector features) { public void process(Tables.OsmMarinePoint element, FeatureCollector features) {
if (!element.name().isBlank()) { if (!element.name().isBlank()) {
String place = element.place(); String clazz = coalesce(
nullIfEmpty(element.natural()),
nullIfEmpty(element.place())
);
var source = element.source(); var source = element.source();
// use name from OSM, but get min zoom from natural earth based on fuzzy name match... // use name from OSM, but get min zoom from natural earth based on fuzzy name match...
Integer rank = Parse.parseIntOrNull(source.getTag("rank")); Integer rank = Parse.parseIntOrNull(source.getTag("rank"));
@@ -159,11 +162,25 @@ public class WaterName implements
rank = next.getValue(); rank = next.getValue();
} }
} }
int minZoom = "ocean".equals(place) ? 0 : rank != null ? rank : 8; int minZoom;
if ("ocean".equals(element.place())) {
minZoom = 0;
} else if (rank != null) {
// FIXME: While this looks like matching properly stuff in https://github.com/openmaptiles/openmaptiles/pull/1457/files#diff-201daa1c61c99073fe3280d440c9feca5ed2236b251ad454caa14cc203f952d1R74 ,
// it includes not just https://www.openstreetmap.org/relation/13360255 but also https://www.openstreetmap.org/node/1385157299 (and some others).
// Hence check how that OpenMapTiles code works for "James Bay" and:
// a) if same as here then, fix there and then here
// b) if OK (while here NOK), fix only here
minZoom = rank;
} else if ("bay".equals(element.natural())) {
minZoom = 13;
} else {
minZoom = 8;
}
features.point(LAYER_NAME) features.point(LAYER_NAME)
.setBufferPixels(BUFFER_SIZE) .setBufferPixels(BUFFER_SIZE)
.putAttrs(OmtLanguageUtils.getNames(source.tags(), translations)) .putAttrs(OmtLanguageUtils.getNames(source.tags(), translations))
.setAttr(Fields.CLASS, place) .setAttr(Fields.CLASS, clazz)
.setAttr(Fields.INTERMITTENT, element.isIntermittent() ? 1 : 0) .setAttr(Fields.INTERMITTENT, element.isIntermittent() ? 1 : 0)
.setMinZoom(minZoom); .setMinZoom(minZoom);
} }
@@ -172,31 +189,35 @@ public class WaterName implements
@Override @Override
public void process(Tables.OsmWaterPolygon element, FeatureCollector features) { public void process(Tables.OsmWaterPolygon element, FeatureCollector features) {
if (nullIfEmpty(element.name()) != null) { if (nullIfEmpty(element.name()) != null) {
try {
Geometry centerlineGeometry = lakeCenterlines.get(element.source().id()); Geometry centerlineGeometry = lakeCenterlines.get(element.source().id());
FeatureCollector.Feature feature; FeatureCollector.Feature feature;
int minzoom = 9; int minzoom = 9;
String place = element.place();
String clazz;
if ("bay".equals(element.natural())) {
clazz = FieldValues.CLASS_BAY;
} else if ("sea".equals(place)) {
clazz = FieldValues.CLASS_SEA;
} else {
clazz = FieldValues.CLASS_LAKE;
minzoom = 3;
}
if (centerlineGeometry != null) { if (centerlineGeometry != null) {
// prefer lake centerline if it exists // prefer lake centerline if it exists
feature = features.geometry(LAYER_NAME, centerlineGeometry) feature = features.geometry(LAYER_NAME, centerlineGeometry)
.setMinPixelSizeBelowZoom(13, 6d * element.name().length()); .setMinPixelSizeBelowZoom(13, 6d * element.name().length());
} else { } else {
// otherwise just use a label point inside the lake // otherwise just use a label point inside the lake
feature = features.pointOnSurface(LAYER_NAME); feature = features.pointOnSurface(LAYER_NAME)
Geometry geometry = element.source().worldGeometry(); .setMinZoom(place != null && SEA_OR_OCEAN_PLACE.contains(place) ? 0 : 3)
double area = geometry.getArea(); .setMinPixelSize(128); // tiles are 256x256, so 128x128 is 1/4 of a tile
minzoom = (int) Math.floor(20 - Math.log(area / WORLD_AREA_FOR_70K_SQUARE_METERS) / LOG2);
minzoom = Math.min(14, Math.max(9, minzoom));
} }
feature feature
.setAttr(Fields.CLASS, FieldValues.CLASS_LAKE) .setAttr(Fields.CLASS, clazz)
.setBufferPixels(BUFFER_SIZE) .setBufferPixels(BUFFER_SIZE)
.putAttrs(OmtLanguageUtils.getNames(element.source().tags(), translations)) .putAttrs(OmtLanguageUtils.getNames(element.source().tags(), translations))
.setAttr(Fields.INTERMITTENT, element.isIntermittent() ? 1 : 0) .setAttr(Fields.INTERMITTENT, element.isIntermittent() ? 1 : 0)
.setMinZoom(minzoom); .setMinZoom(minzoom);
} catch (GeometryException e) {
e.log(stats, "omt_water_polygon", "Unable to get geometry for water polygon " + element.source().id());
}
} }
} }
} }

View File

@@ -74,5 +74,4 @@ public class Utils {
public static String brunnel(boolean isBridge, boolean isTunnel, boolean isFord) { public static String brunnel(boolean isBridge, boolean isTunnel, boolean isFord) {
return isBridge ? "bridge" : isTunnel ? "tunnel" : isFord ? "ford" : null; return isBridge ? "bridge" : isTunnel ? "tunnel" : isFord ? "ford" : null;
} }
} }

View File

@@ -137,7 +137,7 @@ class OpenMapTilesTest {
assertFeatureNear(mbtiles, "housenumber", Map.of( assertFeatureNear(mbtiles, "housenumber", Map.of(
"housenumber", "27" "housenumber", "27"
), 7.42117, 43.73652, 14, 14); ), 7.42117, 43.73652, 14, 14);
assertNumFeatures("housenumber", Map.of(), 14, 274, Point.class); assertNumFeatures("housenumber", Map.of(), 14, 231, Point.class);
} }
@Test @Test

View File

@@ -137,6 +137,16 @@ public abstract class AbstractLayerTest {
); );
} }
SourceFeature lineFeatureWithLength(double length, Map<String, Object> props) {
return SimpleFeature.create(
GeoUtils.worldToLatLonCoords(newLineString(0, 0, 0, length)),
new HashMap<>(props),
OpenMapTilesProfile.OSM_SOURCE,
null,
0
);
}
SourceFeature closedWayFeature(Map<String, Object> props) { SourceFeature closedWayFeature(Map<String, Object> props) {
return SimpleFeature.createFakeOsmFeature( return SimpleFeature.createFakeOsmFeature(
newLineString(0, 0, 1, 0, 1, 1, 0, 1, 0, 0), newLineString(0, 0, 1, 0, 1, 1, 0, 1, 0, 0),

View File

@@ -1,8 +1,14 @@
package org.openmaptiles.layers; package org.openmaptiles.layers;
import static org.junit.jupiter.api.Assertions.assertEquals;
import com.onthegomap.planetiler.geo.GeometryException;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
class HousenumberTest extends AbstractLayerTest { class HousenumberTest extends AbstractLayerTest {
@@ -27,4 +33,127 @@ class HousenumberTest extends AbstractLayerTest {
"addr:housenumber", "10" "addr:housenumber", "10"
)))); ))));
} }
@ParameterizedTest
@CsvSource({
"1, 1",
"1;1a;2;2/b;20;3, 13",
"1;1a;2;2/b;20;3;, 13",
"1;2;20;3, 120",
"1;2;20;3;, 120",
";, ;",
";;, ;;",
"2712;935803935803, 2712935803935803",
})
void testDisplayHousenumber(String outlier, String expected) {
assertEquals(expected, Housenumber.displayHousenumber(outlier));
}
@Test
void testTempAttrs() {
assertFeatures(14, List.of(Map.of(
"_has_name", Boolean.TRUE,
"_partition", "streetX765/6"
)), process(polygonFeature(Map.of(
"addr:housenumber", "765/6",
"addr:block_number", "X",
"addr:street", "street",
"name", "name"
))));
}
@Test
void testNonduplicateHousenumber() throws GeometryException {
var layerName = Housenumber.LAYER_NAME;
var hn1 = pointFeature(
layerName,
Map.of(
"housenumber", "764/2",
"_partition", "764/2"
),
1
);
var hn2 = pointFeature(
layerName,
Map.of(
"housenumber", "765/6",
"_partition", "765/6"
),
1
);
Assertions.assertEquals(
2,
profile.postProcessLayerFeatures(layerName, 14, List.of(hn1, hn2)).size()
);
}
@Test
void testNonduplicateStreet() throws GeometryException {
var layerName = Housenumber.LAYER_NAME;
var housenumber = "765/6";
var hn1 = pointFeature(
layerName,
Map.of(
"housenumber", housenumber,
"_partition", "street 1" + housenumber
),
1
);
var hn2 = pointFeature(
layerName,
Map.of(
"housenumber", housenumber,
"_partition", "street 2" + housenumber
),
1
);
var result = profile.postProcessLayerFeatures(layerName, 14, List.of(hn1, hn2));
Assertions.assertEquals(
1, // same housenumber => two points merged into one multipoint
result.size()
);
Assertions.assertEquals(
5, // two point in multipoint => 5 commands
result.getFirst().geometry().commands().length);
}
@Test
void testDuplicateHousenumber() throws GeometryException {
var layerName = Housenumber.LAYER_NAME;
var housenumber = "765/6";
var hn1 = pointFeature(
layerName,
Map.of(
"housenumber", housenumber + " (no name)",
"_has_name", false,
"_partition", housenumber
),
1
);
var hn2 = pointFeature(
layerName,
Map.of(
"housenumber", housenumber + " (with name)",
"_has_name", true,
"_partition", housenumber
),
1
);
var result = profile.postProcessLayerFeatures(layerName, 14, List.of(hn1, hn2));
Assertions.assertEquals(List.of(
pointFeature(
layerName,
Map.of("housenumber", "765/6 (no name)"),
1
)
), result);
Assertions.assertEquals(
3, // only one point in multipoint => 3 commands
result.getFirst().geometry().commands().length);
}
} }

View File

@@ -45,6 +45,30 @@ class ParkTest extends AbstractLayerTest {
)))); ))));
} }
@Test
void testAbotiginalLand() {
assertFeatures(13, List.of(Map.of(
"_layer", "park",
"_type", "polygon",
"class", "aboriginal_lands",
"name", "Hualapai Tribe",
"_minpixelsize", 2d,
"_minzoom", 4,
"_maxzoom", 14
), Map.of(
"_layer", "park",
"_type", "point",
"class", "aboriginal_lands",
"name", "Hualapai Tribe",
"_minzoom", 5,
"_maxzoom", 14
)), process(polygonFeature(Map.of(
"boundary", "aboriginal_lands",
"name", "Hualapai Tribe",
"protection_title", "National Park"
))));
}
@Test @Test
void testSmallerPark() { void testSmallerPark() {
double z11area = Math.pow((GeoUtils.metersToPixelAtEquator(0, Math.sqrt(70_000)) / 256d), 2) * Math.pow(2, 20 - 11); double z11area = Math.pow((GeoUtils.metersToPixelAtEquator(0, Math.sqrt(70_000)) / 256d), 2) * Math.pow(2, 20 - 11);

View File

@@ -1,13 +1,19 @@
package org.openmaptiles.layers; package org.openmaptiles.layers;
import static com.onthegomap.planetiler.TestUtils.newPoint;
import com.onthegomap.planetiler.FeatureCollector;
import com.onthegomap.planetiler.geo.GeometryException; import com.onthegomap.planetiler.geo.GeometryException;
import com.onthegomap.planetiler.reader.SimpleFeature;
import com.onthegomap.planetiler.reader.SourceFeature; import com.onthegomap.planetiler.reader.SourceFeature;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource; import org.junit.jupiter.params.provider.ValueSource;
import org.openmaptiles.OpenMapTilesProfile;
class PoiTest extends AbstractLayerTest { class PoiTest extends AbstractLayerTest {
@@ -63,6 +69,167 @@ class PoiTest extends AbstractLayerTest {
)))); ))));
} }
private List<FeatureCollector.Feature> testAggStops(List<SourceFeature> sourceFeatures) {
sourceFeatures.forEach(this::process);
List<FeatureCollector.Feature> features = new ArrayList<>();
profile.finish(OpenMapTilesProfile.OSM_SOURCE, featureCollectorFactory, features::add);
return features;
}
@Test
void testAggStopJustOne() {
var result = testAggStops(List.of(pointFeature(Map.of(
"highway", "bus_stop",
"name", "station",
"uic_ref", "1"
))));
assertFeatures(14, List.of(Map.of(
"_layer", "poi",
"class", "bus",
"subclass", "bus_stop",
"agg_stop", 1,
"_minzoom", 14
)), result);
}
@Test
void testAggStopTwoWithSameSubclass() {
var result = testAggStops(List.of(
pointFeature(Map.of(
"railway", "tram_stop",
"name", "station",
"name:es", "test 1",
"uic_ref", "1"
)),
pointFeature(Map.of(
"railway", "tram_stop",
"name", "station",
"name:es", "test 2",
"uic_ref", "1"
))
));
assertFeatures(14, List.of(
Map.of(
"_layer", "poi",
"name:es", "test 1",
"class", "railway",
"subclass", "tram_stop",
"agg_stop", 1,
"_minzoom", 14
),
Map.of(
"_layer", "poi",
"name:es", "test 2",
"class", "railway",
"subclass", "tram_stop",
"agg_stop", "<null>",
"_minzoom", 14
)
), result);
}
@Test
void testAggStopThreeWithMixedSubclass() {
var result = testAggStops(List.of(
pointFeature(Map.of(
"highway", "bus_stop",
"name", "station",
"name:es", "test 1",
"uic_ref", "1"
)),
pointFeature(Map.of(
"highway", "bus_stop",
"name", "station",
"name:es", "test 2",
"uic_ref", "1"
)),
pointFeature(Map.of(
"railway", "tram_stop",
"name", "station",
"name:es", "test 3",
"uic_ref", "1"
))
));
assertFeatures(14, List.of(
Map.of(
"_layer", "poi",
"name:es", "test 1",
"class", "bus",
"subclass", "bus_stop",
"agg_stop", "<null>",
"_minzoom", 14
),
Map.of(
"_layer", "poi",
"name:es", "test 2",
"class", "bus",
"subclass", "bus_stop",
"agg_stop", "<null>",
"_minzoom", 14
),
Map.of(
"_layer", "poi",
"name:es", "test 3",
"class", "railway",
"subclass", "tram_stop",
"agg_stop", 1,
"_minzoom", 14
)
), result);
}
@Test
void testAggStopThreeWithSameSubclass() {
var result = testAggStops(List.of(
SimpleFeature.create(newPoint(0, 0), Map.of(
"highway", "bus_stop",
"name", "station",
"name:es", "test 1",
"uic_ref", "1"
), OpenMapTilesProfile.OSM_SOURCE, null, 0),
SimpleFeature.create(newPoint(1, 0), Map.of(
"highway", "bus_stop",
"name", "station",
"name:es", "test 2",
"uic_ref", "1"
), OpenMapTilesProfile.OSM_SOURCE, null, 1),
SimpleFeature.create(newPoint(2, 0), Map.of(
"highway", "bus_stop",
"name", "station",
"name:es", "test 3",
"uic_ref", "1"
), OpenMapTilesProfile.OSM_SOURCE, null, 2)
));
assertFeatures(14, List.of(
Map.of(
"_layer", "poi",
"name:es", "test 1",
"class", "bus",
"subclass", "bus_stop",
"agg_stop", "<null>",
"_minzoom", 14
),
Map.of(
"_layer", "poi",
"name:es", "test 2",
"class", "bus",
"subclass", "bus_stop",
"agg_stop", 1,
"_minzoom", 14
),
Map.of(
"_layer", "poi",
"name:es", "test 3",
"class", "bus",
"subclass", "bus_stop",
"agg_stop", "<null>",
"_minzoom", 14
)
), result);
}
@ParameterizedTest @ParameterizedTest
@ValueSource(booleans = {false, true}) @ValueSource(booleans = {false, true})
void testPlaceOfWorshipFromReligionTag(boolean area) { void testPlaceOfWorshipFromReligionTag(boolean area) {
@@ -185,7 +352,7 @@ class PoiTest extends AbstractLayerTest {
void testEmbassy() { void testEmbassy() {
assertFeatures(7, List.of(Map.of( assertFeatures(7, List.of(Map.of(
"_layer", "poi", "_layer", "poi",
"class", "diplomatic", "class", "office",
"subclass", "diplomatic", "subclass", "diplomatic",
"name", "The Embassy" "name", "The Embassy"
)), process(pointFeature(Map.of( )), process(pointFeature(Map.of(
@@ -274,4 +441,28 @@ class PoiTest extends AbstractLayerTest {
"ref", "Corner Case" "ref", "Corner Case"
)))); ))));
} }
@Test
void testChargingStation() {
List<Map<String, Object>> expected = List.of(Map.of(
"_layer", "poi",
"class", "fuel",
"subclass", "charging_station",
"name", "Some Charging Station Operator"
));
assertFeatures(14, expected, process(pointFeature(Map.of(
"amenity", "charging_station",
"brand", "Some Charging Station Operator"
))));
assertFeatures(14, expected, process(pointFeature(Map.of(
"amenity", "charging_station",
"operator", "Some Charging Station Operator"
))));
assertFeatures(14, expected, process(pointFeature(Map.of(
"amenity", "charging_station",
"operator", "Some Charging Station",
"ref", "Operator"
))));
}
} }

View File

@@ -3,6 +3,7 @@ package org.openmaptiles.layers;
import static com.onthegomap.planetiler.TestUtils.newLineString; import static com.onthegomap.planetiler.TestUtils.newLineString;
import static com.onthegomap.planetiler.TestUtils.newPoint; import static com.onthegomap.planetiler.TestUtils.newPoint;
import static com.onthegomap.planetiler.TestUtils.rectangle; import static com.onthegomap.planetiler.TestUtils.rectangle;
import static org.junit.jupiter.api.Assertions.assertFalse;
import com.onthegomap.planetiler.FeatureCollector; import com.onthegomap.planetiler.FeatureCollector;
import com.onthegomap.planetiler.config.Arguments; import com.onthegomap.planetiler.config.Arguments;
@@ -17,6 +18,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Stream; import java.util.stream.Stream;
import java.util.stream.StreamSupport;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource; import org.junit.jupiter.params.provider.ValueSource;
@@ -267,31 +269,6 @@ class TransportationTest extends AbstractLayerTest {
"bridge", "yes" "bridge", "yes"
))); )));
assertFeatures(13, List.of(mapOf(
"_layer", "transportation",
"class", "motorway",
"surface", "paved",
"oneway", 1,
"ramp", "<null>",
"bicycle", "no",
"foot", "no",
"horse", "no",
"brunnel", "bridge",
"network", "us-interstate",
"_minzoom", 4
), Map.of(
"_layer", "transportation_name",
"class", "motorway",
"name", "Massachusetts Turnpike",
"name_en", "Massachusetts Turnpike",
"ref", "90",
"ref_length", 2,
"network", "us-interstate",
"brunnel", "<null>",
"route_1", "US:I=90",
"_minzoom", 6
)), features);
assertFeatures(13, List.of(Map.of( assertFeatures(13, List.of(Map.of(
"_layer", "transportation", "_layer", "transportation",
"class", "motorway", "class", "motorway",
@@ -341,6 +318,51 @@ class TransportationTest extends AbstractLayerTest {
)), features); )), features);
} }
@Test
void testDuplicateRoute() {
var rel1 = new OsmElement.Relation(1);
rel1.setTag("type", "route");
rel1.setTag("route", "road");
rel1.setTag("network", "US:OK");
rel1.setTag("ref", "104");
rel1.setTag("direction", "north");
var rel2 = new OsmElement.Relation(2);
rel2.setTag("type", "route");
rel2.setTag("route", "road");
rel2.setTag("network", "US:OK");
rel2.setTag("ref", "104");
rel2.setTag("direction", "south");
FeatureCollector features = process(lineFeatureWithRelation(
Stream.concat(
profile.preprocessOsmRelation(rel2).stream(),
profile.preprocessOsmRelation(rel1).stream()
).toList(),
Map.of(
"highway", "trunk",
"ref", "US 23;SR 104",
"lanes", 5,
"maxspeed", "55 mph",
"expressway", "no"
)));
assertFeatures(13, List.of(mapOf(
"_layer", "transportation",
"class", "trunk",
"network", "us-state",
"_minzoom", 5
), Map.of(
"_layer", "transportation_name",
"class", "trunk",
"ref", "104",
"ref_length", 3,
"network", "us-state",
"route_1", "US:OK=104",
"route_2", "<null>",
"_minzoom", 8
)), features);
}
@Test @Test
void testRouteWithoutNetworkType() { void testRouteWithoutNetworkType() {
var rel1 = new OsmElement.Relation(1); var rel1 = new OsmElement.Relation(1);
@@ -951,6 +973,316 @@ class TransportationTest extends AbstractLayerTest {
)), features); )), features);
} }
@Test
void testTransCanadaTrunk() {
var rel = new OsmElement.Relation(1);
rel.setTag("type", "route");
rel.setTag("route", "road");
rel.setTag("network", "CA:transcanada:namedRoute");
FeatureCollector features = process(lineFeatureWithRelation(
profile.preprocessOsmRelation(rel),
Map.of(
"highway", "trunk"
)));
assertFeatures(13, List.of(Map.of(
"_layer", "transportation",
"class", "trunk",
"_minzoom", 4
)), features);
}
@Test
void testTransCanadaProvincialCaQcA() {
var rel = new OsmElement.Relation(1);
rel.setTag("type", "route");
rel.setTag("route", "road");
rel.setTag("network", "CA:QC:A");
FeatureCollector features = process(lineFeatureWithRelation(
profile.preprocessOsmRelation(rel),
Map.of(
"highway", "trunk"
)));
assertFeatures(13, List.of(Map.of(
"_layer", "transportation",
"class", "trunk",
"network", "ca-provincial-arterial",
"_minzoom", 4
)), features);
}
@Test
void testTransCanadaProvincialCaOnPrimaryRef4xx() {
var rel = new OsmElement.Relation(1);
rel.setTag("type", "route");
rel.setTag("route", "road");
rel.setTag("network", "CA:ON:primary");
rel.setTag("ref", "420");
FeatureCollector features = process(lineFeatureWithRelation(
profile.preprocessOsmRelation(rel),
Map.of(
"highway", "trunk"
)));
assertFeatures(13, List.of(Map.of(
"_layer", "transportation",
"class", "trunk",
"network", "ca-provincial-arterial",
"_minzoom", 4
), Map.of(
"_layer", "transportation_name",
"class", "trunk",
"ref", "420",
"network", "ca-provincial-arterial"
)), features);
}
@Test
void testTransCanadaProvincialCaOnPrimaryRefQew() {
var rel = new OsmElement.Relation(1);
rel.setTag("type", "route");
rel.setTag("route", "road");
rel.setTag("network", "CA:ON:primary");
rel.setTag("ref", "QEW");
FeatureCollector features = process(lineFeatureWithRelation(
profile.preprocessOsmRelation(rel),
Map.of(
"highway", "trunk"
)));
assertFeatures(13, List.of(Map.of(
"_layer", "transportation",
"class", "trunk",
"network", "ca-provincial-arterial",
"_minzoom", 4
), Map.of(
"_layer", "transportation_name",
"class", "trunk",
"ref", "QEW",
"network", "ca-provincial-arterial"
)), features);
}
@Test
void testTransCanadaProvincialCaOnPrimaryRefOther() {
var rel = new OsmElement.Relation(1);
rel.setTag("type", "route");
rel.setTag("route", "road");
rel.setTag("network", "CA:ON:primary");
rel.setTag("ref", "85");
FeatureCollector features = process(lineFeatureWithRelation(
profile.preprocessOsmRelation(rel),
Map.of(
"highway", "trunk"
)));
assertFeatures(13, List.of(Map.of(
"_layer", "transportation",
"class", "trunk",
"network", "ca-provincial",
"_minzoom", 5
), Map.of(
"_layer", "transportation_name",
"class", "trunk",
"ref", "85",
"network", "ca-provincial"
)), features);
}
@Test
void testTransCanadaProvincialCaMbPthRef75() {
var rel = new OsmElement.Relation(1);
rel.setTag("type", "route");
rel.setTag("route", "road");
rel.setTag("network", "CA:MB:PTH");
rel.setTag("ref", "75");
FeatureCollector features = process(lineFeatureWithRelation(
profile.preprocessOsmRelation(rel),
Map.of(
"highway", "trunk"
)));
assertFeatures(13, List.of(Map.of(
"_layer", "transportation",
"class", "trunk",
"network", "ca-provincial-arterial",
"_minzoom", 4
), Map.of(
"_layer", "transportation_name",
"class", "trunk",
"ref", "75",
"network", "ca-provincial-arterial"
)), features);
}
@Test
void testTransCanadaProvincialCaMbPthRefOther() {
var rel = new OsmElement.Relation(1);
rel.setTag("type", "route");
rel.setTag("route", "road");
rel.setTag("network", "CA:MB:PTH");
rel.setTag("ref", "77");
FeatureCollector features = process(lineFeatureWithRelation(
profile.preprocessOsmRelation(rel),
Map.of(
"highway", "trunk"
)));
assertFeatures(13, List.of(Map.of(
"_layer", "transportation",
"class", "trunk",
"network", "ca-provincial",
"_minzoom", 5
), Map.of(
"_layer", "transportation_name",
"class", "trunk",
"ref", "77",
"network", "ca-provincial"
)), features);
}
@Test
void testTransCanadaProvincialCaAbPrimaryRef3() {
var rel = new OsmElement.Relation(1);
rel.setTag("type", "route");
rel.setTag("route", "road");
rel.setTag("network", "CA:AB:primary");
rel.setTag("ref", "3");
FeatureCollector features = process(lineFeatureWithRelation(
profile.preprocessOsmRelation(rel),
Map.of(
"highway", "trunk"
)));
assertFeatures(13, List.of(Map.of(
"_layer", "transportation",
"class", "trunk",
"network", "ca-provincial-arterial",
"_minzoom", 4
), Map.of(
"_layer", "transportation_name",
"class", "trunk",
"ref", "3",
"network", "ca-provincial-arterial"
)), features);
}
@Test
void testTransCanadaProvincialCaAbPrimaryRefOther() {
var rel = new OsmElement.Relation(1);
rel.setTag("type", "route");
rel.setTag("route", "road");
rel.setTag("network", "CA:AB:primary");
rel.setTag("ref", "10");
FeatureCollector features = process(lineFeatureWithRelation(
profile.preprocessOsmRelation(rel),
Map.of(
"highway", "trunk"
)));
assertFeatures(13, List.of(Map.of(
"_layer", "transportation",
"class", "trunk",
"network", "ca-provincial",
"_minzoom", 5
), Map.of(
"_layer", "transportation_name",
"class", "trunk",
"ref", "10",
"network", "ca-provincial"
)), features);
}
@Test
void testTransCanadaProvincialCaBcRef3() {
var rel = new OsmElement.Relation(1);
rel.setTag("type", "route");
rel.setTag("route", "road");
rel.setTag("network", "CA:BC");
rel.setTag("ref", "3");
FeatureCollector features = process(lineFeatureWithRelation(
profile.preprocessOsmRelation(rel),
Map.of(
"highway", "trunk"
)));
assertFeatures(13, List.of(Map.of(
"_layer", "transportation",
"class", "trunk",
"network", "ca-provincial-arterial",
"_minzoom", 4
), Map.of(
"_layer", "transportation_name",
"class", "trunk",
"ref", "3",
"network", "ca-provincial-arterial"
)), features);
}
@Test
void testTransCanadaProvincialCaBcRefOther() {
var rel = new OsmElement.Relation(1);
rel.setTag("type", "route");
rel.setTag("route", "road");
rel.setTag("network", "CA:BC");
rel.setTag("ref", "10");
FeatureCollector features = process(lineFeatureWithRelation(
profile.preprocessOsmRelation(rel),
Map.of(
"highway", "trunk"
)));
assertFeatures(13, List.of(Map.of(
"_layer", "transportation",
"class", "trunk",
"network", "ca-provincial",
"_minzoom", 5
), Map.of(
"_layer", "transportation_name",
"class", "trunk",
"ref", "10",
"network", "ca-provincial"
)), features);
}
@Test
void testTransCanadaProvincialCaOther() {
var rel = new OsmElement.Relation(1);
rel.setTag("type", "route");
rel.setTag("route", "road");
rel.setTag("network", "CA:yellowhead");
FeatureCollector features = process(lineFeatureWithRelation(
profile.preprocessOsmRelation(rel),
Map.of(
"highway", "trunk"
)));
assertFeatures(13, List.of(Map.of(
"_layer", "transportation",
"class", "trunk",
"_minzoom", 5
)), features);
boolean caProvPresent = StreamSupport.stream(features.spliterator(), false)
.flatMap(f -> f.getAttrsAtZoom(13).entrySet().stream())
.filter(e -> "network".equals(e.getKey()))
.map(Map.Entry::getValue)
.anyMatch(v -> "ca-provincial".equals(v) || "ca-provincial-arterial".equals(v));
assertFalse(caProvPresent, "ca-provincial present");
}
@Test @Test
void testGreatBritainHighway() { void testGreatBritainHighway() {
process(SimpleFeature.create( process(SimpleFeature.create(
@@ -1014,6 +1346,307 @@ class TransportationTest extends AbstractLayerTest {
))); )));
} }
@Test
void testGreatBritainTrunk() {
process(SimpleFeature.create(
rectangle(0, 0.1),
Map.of("iso_a2", "GB"),
OpenMapTilesProfile.NATURAL_EARTH_SOURCE,
"ne_10m_admin_0_countries",
0
));
// in GB
assertFeatures(13, List.of(Map.of(
"_layer", "transportation",
"class", "trunk",
"_minzoom", 5
), Map.of(
"_layer", "transportation_name",
"class", "trunk",
"ref", "A272",
"ref_length", 4,
"network", "gb-trunk",
"_minzoom", 8
)), process(SimpleFeature.create(
newLineString(0, 0, 1, 1),
Map.of(
"highway", "trunk",
"ref", "A272"
),
OpenMapTilesProfile.OSM_SOURCE,
null,
0
)));
}
@Test
void testGreatBritainPrimary() {
process(SimpleFeature.create(
rectangle(0, 0.1),
Map.of("iso_a2", "GB"),
OpenMapTilesProfile.NATURAL_EARTH_SOURCE,
"ne_10m_admin_0_countries",
0
));
// in GB
assertFeatures(13, List.of(Map.of(
"_layer", "transportation",
"class", "primary",
"_minzoom", 7
), Map.of(
"_layer", "transportation_name",
"class", "primary",
"ref", "A598",
"ref_length", 4,
"network", "gb-primary",
"_minzoom", 12
)), process(SimpleFeature.create(
newLineString(0, 0, 1, 1),
Map.of(
"highway", "primary",
"ref", "A598"
),
OpenMapTilesProfile.OSM_SOURCE,
null,
0
)));
}
@Test
void testGreatBritainSecondary() {
process(SimpleFeature.create(
rectangle(0, 0.1),
Map.of("iso_a2", "GB"),
OpenMapTilesProfile.NATURAL_EARTH_SOURCE,
"ne_10m_admin_0_countries",
0
));
// in GB
assertFeatures(13, List.of(Map.of(
"_layer", "transportation",
"class", "secondary",
"_minzoom", 9
), Map.of(
"_layer", "transportation_name",
"class", "secondary",
"ref", "B4558",
"ref_length", 5,
"network", "gb-primary",
"_minzoom", 12
)), process(SimpleFeature.create(
newLineString(0, 0, 1, 1),
Map.of(
"highway", "secondary",
"ref", "B4558"
),
OpenMapTilesProfile.OSM_SOURCE,
null,
0
)));
}
@Test
void testGreatBritainTertiary() {
process(SimpleFeature.create(
rectangle(0, 0.1),
Map.of("iso_a2", "GB"),
OpenMapTilesProfile.NATURAL_EARTH_SOURCE,
"ne_10m_admin_0_countries",
0
));
// in GB
assertFeatures(13, List.of(Map.of(
"_layer", "transportation",
"class", "tertiary",
"_minzoom", 11
), Map.of(
"_layer", "transportation_name",
"class", "tertiary",
"ref", "B4086",
"ref_length", 5,
"network", "road",
"_minzoom", 12
)), process(SimpleFeature.create(
newLineString(0, 0, 1, 1),
Map.of(
"highway", "tertiary",
"ref", "B4086"
),
OpenMapTilesProfile.OSM_SOURCE,
null,
0
)));
}
@Test
void testIrelandHighway() {
process(SimpleFeature.create(
rectangle(0, 0.1),
Map.of("iso_a2", "IE"),
OpenMapTilesProfile.NATURAL_EARTH_SOURCE,
"ne_10m_admin_0_countries",
0
));
// in IE
assertFeatures(13, List.of(Map.of(
"_layer", "transportation",
"class", "motorway",
"oneway", 1,
"ramp", "<null>",
"_minzoom", 4
), Map.of(
"_layer", "transportation_name",
"class", "motorway",
"ref", "M18",
"ref_length", 3,
"network", "ie-motorway",
"_minzoom", 6
)), process(SimpleFeature.create(
newLineString(0, 0, 1, 1),
Map.of(
"highway", "motorway",
"oneway", "yes",
"ref", "M18"
),
OpenMapTilesProfile.OSM_SOURCE,
null,
0
)));
// not in IE
assertFeatures(13, List.of(Map.of(
"_layer", "transportation",
"class", "motorway",
"oneway", 1,
"ramp", "<null>",
"_minzoom", 4
), Map.of(
"_layer", "transportation_name",
"class", "motorway",
"ref", "M18",
"ref_length", 3,
"network", "road",
"_minzoom", 6
)), process(SimpleFeature.create(
newLineString(1, 0, 0, 1),
Map.of(
"highway", "motorway",
"oneway", "yes",
"ref", "M18"
),
OpenMapTilesProfile.OSM_SOURCE,
null,
0
)));
}
@Test
void testIrelandTrunk() {
process(SimpleFeature.create(
rectangle(0, 0.1),
Map.of("iso_a2", "IE"),
OpenMapTilesProfile.NATURAL_EARTH_SOURCE,
"ne_10m_admin_0_countries",
0
));
// in IE
assertFeatures(13, List.of(Map.of(
"_layer", "transportation",
"class", "trunk",
"_minzoom", 5
), Map.of(
"_layer", "transportation_name",
"class", "trunk",
"ref", "N8",
"ref_length", 2,
"network", "ie-national",
"_minzoom", 8
)), process(SimpleFeature.create(
newLineString(0, 0, 1, 1),
Map.of(
"highway", "trunk",
"ref", "N8"
),
OpenMapTilesProfile.OSM_SOURCE,
null,
0
)));
}
@Test
void testIrelandPrimary() {
process(SimpleFeature.create(
rectangle(0, 0.1),
Map.of("iso_a2", "IE"),
OpenMapTilesProfile.NATURAL_EARTH_SOURCE,
"ne_10m_admin_0_countries",
0
));
// in IE
assertFeatures(13, List.of(Map.of(
"_layer", "transportation",
"class", "primary",
"_minzoom", 7
), Map.of(
"_layer", "transportation_name",
"class", "primary",
"ref", "N59",
"ref_length", 3,
"network", "ie-national",
"_minzoom", 12
)), process(SimpleFeature.create(
newLineString(0, 0, 1, 1),
Map.of(
"highway", "primary",
"ref", "N59"
),
OpenMapTilesProfile.OSM_SOURCE,
null,
0
)));
}
@Test
void testIrelandSecondary() {
process(SimpleFeature.create(
rectangle(0, 0.1),
Map.of("iso_a2", "IE"),
OpenMapTilesProfile.NATURAL_EARTH_SOURCE,
"ne_10m_admin_0_countries",
0
));
// in IE
assertFeatures(13, List.of(Map.of(
"_layer", "transportation",
"class", "secondary",
"_minzoom", 9
), Map.of(
"_layer", "transportation_name",
"class", "secondary",
"ref", "R813",
"ref_length", 4,
"network", "ie-regional",
"_minzoom", 12
)), process(SimpleFeature.create(
newLineString(0, 0, 1, 1),
Map.of(
"highway", "secondary",
"ref", "R813"
),
OpenMapTilesProfile.OSM_SOURCE,
null,
0
)));
}
@Test @Test
void testMergesDisconnectedRoadNameFeatures() throws GeometryException { void testMergesDisconnectedRoadNameFeatures() throws GeometryException {
testMergesLinestrings(Map.of("class", "motorway"), TransportationName.LAYER_NAME, 10, 14); testMergesLinestrings(Map.of("class", "motorway"), TransportationName.LAYER_NAME, 10, 14);
@@ -1176,8 +1809,9 @@ class TransportationTest extends AbstractLayerTest {
"_layer", "transportation", "_layer", "transportation",
"class", "ferry", "class", "ferry",
"_minzoom", 11, "_minzoom", 4,
"_maxzoom", 14, "_maxzoom", 14,
"_minpixelsize", 32d,
"_type", "line" "_type", "line"
), Map.of( ), Map.of(
"_layer", "transportation_name", "_layer", "transportation_name",
@@ -1358,6 +1992,30 @@ class TransportationTest extends AbstractLayerTest {
)))); ))));
} }
@Test
void testGrade1SurfacePath() {
assertFeatures(14, List.of(Map.of(
"_layer", "transportation",
"class", "track",
"surface", "paved"
)), process(lineFeature(Map.of(
"surface", "grade1",
"highway", "track"
))));
}
@Test
void testGrade1TracktypePath() {
assertFeatures(14, List.of(Map.of(
"_layer", "transportation",
"class", "track",
"surface", "paved"
)), process(lineFeature(Map.of(
"tracktype", "grade1",
"highway", "track"
))));
}
@Test @Test
void testIssue58() { void testIssue58() {
// test subject: https://www.openstreetmap.org/way/222564359 // test subject: https://www.openstreetmap.org/way/222564359

View File

@@ -27,7 +27,7 @@ class WaterNameTest extends AbstractLayerTest {
"_layer", "water_name", "_layer", "water_name",
"_type", "point", "_type", "point",
"_minzoom", 9, "_minzoom", 3,
"_maxzoom", 14 "_maxzoom", 14
)), process(polygonFeatureWithArea(1, Map.of( )), process(polygonFeatureWithArea(1, Map.of(
"name", "waterway", "name", "waterway",
@@ -36,19 +36,6 @@ class WaterNameTest extends AbstractLayerTest {
"water", "pond", "water", "pond",
"intermittent", "1" "intermittent", "1"
)))); ))));
double z11area = Math.pow((GeoUtils.metersToPixelAtEquator(0, Math.sqrt(70_000)) / 256d), 2) * Math.pow(2, 20 - 11);
assertFeatures(10, List.of(Map.of(
"_layer", "water"
), Map.of(
"_layer", "water_name",
"_type", "point",
"_minzoom", 11,
"_maxzoom", 14
)), process(polygonFeatureWithArea(z11area, Map.of(
"name", "waterway",
"natural", "water",
"water", "pond"
))));
} }
@Test @Test
@@ -71,7 +58,7 @@ class WaterNameTest extends AbstractLayerTest {
"_layer", "water_name", "_layer", "water_name",
"_type", "line", "_type", "line",
"_geom", new TestUtils.NormGeometry(GeoUtils.latLonToWorldCoords(newLineString(0, 0, 1, 1))), "_geom", new TestUtils.NormGeometry(GeoUtils.latLonToWorldCoords(newLineString(0, 0, 1, 1))),
"_minzoom", 9, "_minzoom", 3,
"_maxzoom", 14, "_maxzoom", 14,
"_minpixelsize", "waterway".length() * 6d "_minpixelsize", "waterway".length() * 6d
)), process(SimpleFeature.create( )), process(SimpleFeature.create(
@@ -121,7 +108,7 @@ class WaterNameTest extends AbstractLayerTest {
newLineString(0, 0, 1, 1), newLineString(0, 0, 1, 1),
newLineString(2, 2, 3, 3) newLineString(2, 2, 3, 3)
}))), }))),
"_minzoom", 9, "_minzoom", 3,
"_maxzoom", 14, "_maxzoom", 14,
"_minpixelsize", "waterway".length() * 6d "_minpixelsize", "waterway".length() * 6d
)), process(SimpleFeature.create( )), process(SimpleFeature.create(
@@ -138,6 +125,40 @@ class WaterNameTest extends AbstractLayerTest {
))); )));
} }
@Test
void testWaterNameBay() {
assertFeatures(11, List.of(), process(SimpleFeature.create(
newLineString(0, 0, 1, 1),
new HashMap<>(Map.<String, Object>of(
"OSM_ID", -10
)),
OpenMapTilesProfile.LAKE_CENTERLINE_SOURCE,
null,
0
)));
assertFeatures(10, List.of(Map.of(
"name", "bay",
"name:es", "bay es",
"_layer", "water_name",
"_type", "line",
"_geom", new TestUtils.NormGeometry(GeoUtils.latLonToWorldCoords(newLineString(0, 0, 1, 1))),
"_minzoom", 9,
"_maxzoom", 14,
"_minpixelsize", "bay".length() * 6d
)), process(SimpleFeature.create(
GeoUtils.worldToLatLonCoords(rectangle(0, Math.sqrt(1))),
new HashMap<>(Map.<String, Object>of(
"name", "bay",
"name:es", "bay es",
"natural", "bay"
)),
OpenMapTilesProfile.OSM_SOURCE,
null,
10
)));
}
@Test @Test
void testMarinePoint() { void testMarinePoint() {
assertFeatures(11, List.of(), process(SimpleFeature.create( assertFeatures(11, List.of(), process(SimpleFeature.create(