Upgrade planetiler-basemap to be compatible with OpenMapTiles 3.13 (#49)

Applying changes to layers from [OpenMapTiles 3.13 release](https://github.com/openmaptiles/openmaptiles/releases/tag/v3.13) (https://github.com/openmaptiles/openmaptiles/compare/v3.12.2...v3.13), minus transportation network connectivity improvements - those will be a separate change.
This commit is contained in:
Michael Barry
2022-01-19 05:36:44 -05:00
committed by GitHub
parent 8e49c0831c
commit 0baaf8d886
37 changed files with 1690 additions and 464 deletions

View File

@@ -211,7 +211,8 @@ public class GenerateTest {
List.of(),
null,
null,
props
props,
List.of()
));
assertEquals(or(
and(

View File

@@ -211,4 +211,15 @@ public abstract class AbstractLayerTest {
profile.postProcessLayerFeatures(layer, zoom, List.of(line1, line2))
);
}
public static Map<String, Object> mapOf(Object... args) {
assert args.length % 2 == 0;
Map<String, Object> result = new HashMap<>();
for (int i = 0; i < args.length; i += 2) {
String key = args[i].toString();
Object value = args[i + 1];
result.put(key, value == null ? "<null>" : value);
}
return result;
}
}

View File

@@ -13,7 +13,7 @@ public class AerodromeLabelTest extends AbstractLayerTest {
}
@Test
public void testHappyPathPoint() {
public void testIntlWithIata() {
assertFeatures(14, List.of(Map.of(
"class", "international",
"ele", 100,
@@ -23,7 +23,7 @@ public class AerodromeLabelTest extends AbstractLayerTest {
"_layer", "aerodrome_label",
"_type", "point",
"_minzoom", 10,
"_minzoom", 8,
"_maxzoom", 14,
"_buffer", 64d
)), process(pointFeature(Map.of(
@@ -41,7 +41,8 @@ public class AerodromeLabelTest extends AbstractLayerTest {
public void testInternational() {
assertFeatures(14, List.of(Map.of(
"class", "international",
"_layer", "aerodrome_label"
"_layer", "aerodrome_label",
"_minzoom", 10 // no IATA
)), process(pointFeature(Map.of(
"aeroway", "aerodrome",
"aerodrome_type", "international"
@@ -52,7 +53,8 @@ public class AerodromeLabelTest extends AbstractLayerTest {
public void testPublic() {
assertFeatures(14, List.of(Map.of(
"class", "public",
"_layer", "aerodrome_label"
"_layer", "aerodrome_label",
"_minzoom", 10
)), process(pointFeature(Map.of(
"aeroway", "aerodrome",
"aerodrome_type", "public airport"
@@ -70,7 +72,8 @@ public class AerodromeLabelTest extends AbstractLayerTest {
public void testMilitary() {
assertFeatures(14, List.of(Map.of(
"class", "military",
"_layer", "aerodrome_label"
"_layer", "aerodrome_label",
"_minzoom", 10
)), process(pointFeature(Map.of(
"aeroway", "aerodrome",
"aerodrome_type", "military airport"
@@ -88,7 +91,8 @@ public class AerodromeLabelTest extends AbstractLayerTest {
public void testPrivate() {
assertFeatures(14, List.of(Map.of(
"class", "private",
"_layer", "aerodrome_label"
"_layer", "aerodrome_label",
"_minzoom", 10
)), process(pointFeature(Map.of(
"aeroway", "aerodrome",
"aerodrome_type", "private"
@@ -106,7 +110,8 @@ public class AerodromeLabelTest extends AbstractLayerTest {
public void testOther() {
assertFeatures(14, List.of(Map.of(
"class", "other",
"_layer", "aerodrome_label"
"_layer", "aerodrome_label",
"_minzoom", 10
)), process(pointFeature(Map.of(
"aeroway", "aerodrome"
))));

View File

@@ -144,11 +144,30 @@ public class BoundaryTest extends AbstractLayerTest {
"ne_10m_admin_1_states_provinces_lines",
0
)));
assertFeatures(0, List.of(Map.of(
"_layer", "boundary",
"_type", "line",
"disputed", 0,
"maritime", 0,
"admin_level", 4,
"_minzoom", 4,
"_maxzoom", 4,
"_buffer", 4d
)), process(SimpleFeature.create(
newLineString(0, 0, 1, 1),
Map.of(
"min_zoom", 7.6d
),
NATURAL_EARTH_SOURCE,
"ne_10m_admin_1_states_provinces_lines",
0
)));
assertFeatures(0, List.of(), process(SimpleFeature.create(
newLineString(0, 0, 1, 1),
Map.of(
"min_zoom", 7.1d
"min_zoom", 7.9d
),
NATURAL_EARTH_SOURCE,
"ne_10m_admin_1_states_provinces_lines",

View File

@@ -41,6 +41,14 @@ public class BuildingTest extends AbstractLayerTest {
))));
}
@Test
public void testIgnoreUndergroundBuilding() {
assertFeatures(14, List.of(), process(polygonFeature(Map.of(
"building", "yes",
"location", "underground"
))));
}
@Test
public void testAirportBuildings() {
assertFeatures(13, List.of(Map.of(

View File

@@ -130,6 +130,9 @@ public class LandcoverTest extends AbstractLayerTest {
)), process(polygonFeature(Map.of(
"natural", "dune"
))));
assertFeatures(10, List.of(), process(polygonFeature(Map.of(
"landuse", "park"
))));
}
@Test
@@ -137,6 +140,7 @@ public class LandcoverTest extends AbstractLayerTest {
Map<String, Object> map = Map.of("subclass", "wood");
assertMerges(List.of(map, map, map, map, map, map), List.of(
// don't merge any
feature(rectangle(10, 20), Map.of("_numpoints", 48, "subclass", "wood")),
feature(rectangle(10, 20), Map.of("_numpoints", 49, "subclass", "wood")),
feature(rectangle(12, 18), Map.of("_numpoints", 50, "subclass", "wood")),
@@ -144,19 +148,23 @@ public class LandcoverTest extends AbstractLayerTest {
feature(rectangle(12, 18), Map.of("_numpoints", 300, "subclass", "wood")),
feature(rectangle(12, 18), Map.of("_numpoints", 301, "subclass", "wood"))
), 14);
assertMerges(List.of(map, map, map, map), List.of(
assertMerges(List.of(map, map, map), List.of(
// < 300 - merge
feature(rectangle(10, 20), Map.of("_numpoints", 48, "subclass", "wood")),
feature(rectangle(10, 20), Map.of("_numpoints", 49, "subclass", "wood")),
feature(rectangle(12, 18), Map.of("_numpoints", 50, "subclass", "wood")),
feature(rectangle(12, 18), Map.of("_numpoints", 299, "subclass", "wood")),
// >= 300 - don't merge
feature(rectangle(12, 18), Map.of("_numpoints", 300, "subclass", "wood")),
feature(rectangle(12, 18), Map.of("_numpoints", 301, "subclass", "wood"))
), 13);
assertMerges(List.of(map, map, map), List.of(
assertMerges(List.of(map, map), List.of(
// < 300 - merge
feature(rectangle(10, 20), Map.of("_numpoints", 48, "subclass", "wood")),
feature(rectangle(10, 20), Map.of("_numpoints", 49, "subclass", "wood")),
feature(rectangle(12, 18), Map.of("_numpoints", 50, "subclass", "wood")),
feature(rectangle(12, 18), Map.of("_numpoints", 299, "subclass", "wood")),
// >= 300 - merge
feature(rectangle(12, 18), Map.of("_numpoints", 300, "subclass", "wood")),
feature(rectangle(12, 18), Map.of("_numpoints", 301, "subclass", "wood"))
), 9);

View File

@@ -58,6 +58,18 @@ public class LanduseTest extends AbstractLayerTest {
))));
}
@Test
public void testGraveYardBecomesCemetery() {
assertFeatures(14, List.of(
Map.of("_layer", "poi"),
Map.of(
"_layer", "landuse",
"class", "cemetery"
)), process(polygonFeature(Map.of(
"amenity", "grave_yard"
))));
}
@Test
public void testOsmLanduseLowerZoom() {
assertFeatures(6, List.of(Map.of(

View File

@@ -1,11 +1,15 @@
package com.onthegomap.planetiler.basemap.layers;
import static com.onthegomap.planetiler.TestUtils.newPoint;
import static com.onthegomap.planetiler.TestUtils.rectangle;
import static com.onthegomap.planetiler.basemap.BasemapProfile.NATURAL_EARTH_SOURCE;
import static com.onthegomap.planetiler.basemap.BasemapProfile.OSM_SOURCE;
import static org.junit.jupiter.api.Assertions.assertEquals;
import com.google.common.collect.Lists;
import com.onthegomap.planetiler.VectorTile;
import com.onthegomap.planetiler.geo.GeometryException;
import com.onthegomap.planetiler.reader.SimpleFeature;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -31,6 +35,7 @@ public class MountainPeakTest extends AbstractLayerTest {
"class", "peak",
"ele", 100,
"ele_ft", 328,
"customary_ft", "<null>",
"_layer", "mountain_peak",
"_type", "point",
@@ -70,6 +75,17 @@ public class MountainPeakTest extends AbstractLayerTest {
))));
}
@Test
public void testSaddle() {
assertFeatures(14, List.of(Map.of(
"class", "saddle"
)), process(pointFeature(Map.of(
"natural", "saddle",
"ele", "100"
))));
}
@Test
public void testNoElevation() {
assertFeatures(14, List.of(), process(pointFeature(Map.of(
@@ -86,7 +102,7 @@ public class MountainPeakTest extends AbstractLayerTest {
}
@Test
public void testIgnoreLines() {
public void testIgnorePeakLines() {
assertFeatures(14, List.of(), process(lineFeature(Map.of(
"natural", "peak",
"name", "name",
@@ -94,6 +110,68 @@ public class MountainPeakTest extends AbstractLayerTest {
))));
}
@Test
public void testMountainLinestring() {
assertFeatures(14, List.of(Map.of(
"class", "ridge",
"name", "Ridge",
"_layer", "mountain_peak",
"_type", "line",
"_minzoom", 13,
"_maxzoom", 14,
"_buffer", 100d
)), process(lineFeature(Map.of(
"natural", "ridge",
"name", "Ridge"
))));
}
@Test
public void testCustomaryFt() {
process(SimpleFeature.create(
rectangle(0, 0.1),
Map.of("iso_a2", "US"),
NATURAL_EARTH_SOURCE,
"ne_10m_admin_0_countries",
0
));
// inside US - customary_ft=1
assertFeatures(14, List.of(Map.of(
"class", "volcano",
"customary_ft", 1,
"ele", 100,
"ele_ft", 328
)), process(SimpleFeature.create(
newPoint(0, 0),
new HashMap<>(Map.<String, Object>of(
"natural", "volcano",
"ele", "100"
)),
OSM_SOURCE,
null,
0
)));
// outside US - customary_ft omitted
assertFeatures(14, List.of(Map.of(
"class", "volcano",
"customary_ft", "<null>",
"ele", 100,
"ele_ft", 328
)), process(SimpleFeature.create(
newPoint(1, 1),
new HashMap<>(Map.<String, Object>of(
"natural", "volcano",
"ele", "100"
)),
OSM_SOURCE,
null,
0
)));
}
private int getSortKey(Map<String, Object> tags) {
return process(pointFeature(Map.of(
"natural", "peak",

View File

@@ -13,9 +13,9 @@ public class ParkTest extends AbstractLayerTest {
"_layer", "park",
"_type", "polygon",
"class", "national_park",
"name", "<null>",
"name", "Grand Canyon National Park",
"_minpixelsize", 2d,
"_minzoom", 6,
"_minzoom", 4,
"_maxzoom", 14
), Map.of(
"_layer", "park",
@@ -24,8 +24,8 @@ public class ParkTest extends AbstractLayerTest {
"name", "Grand Canyon National Park",
"name_int", "Grand Canyon National Park",
"name:latin", "Grand Canyon National Park",
"name:es", "es name",
"_minzoom", 6,
// "name:es", "es name", // don't include all translations
"_minzoom", 5,
"_maxzoom", 14
)), process(polygonFeature(Map.of(
"boundary", "national_park",
@@ -52,9 +52,9 @@ public class ParkTest extends AbstractLayerTest {
"_layer", "park",
"_type", "polygon",
"class", "protected_area",
"name", "<null>",
"name", "Small park",
"_minpixelsize", 2d,
"_minzoom", 6,
"_minzoom", 4,
"_maxzoom", 14
), Map.of(
"_layer", "park",
@@ -75,7 +75,7 @@ public class ParkTest extends AbstractLayerTest {
), Map.of(
"_layer", "park",
"_type", "point",
"_minzoom", 6,
"_minzoom", 5,
"_maxzoom", 14
)), process(polygonFeatureWithArea(1, Map.of(
"boundary", "protected_area",

View File

@@ -131,8 +131,8 @@ public class PlaceTest extends AbstractLayerTest {
rectangle(0.4, 0.6),
Map.of(
"name", "Massachusetts - not important",
"scalerank", 4,
"labelrank", 4,
"scalerank", 8,
"labelrank", 8,
"datarank", 1
),
NATURAL_EARTH_SOURCE,
@@ -194,6 +194,44 @@ public class PlaceTest extends AbstractLayerTest {
)));
}
@Test
public void testProvince() {
wikidataTranslations.put(95027, "es", "provincia de Lugo");
process(SimpleFeature.create(
rectangle(0, 0.25),
Map.of(
"name", "Nova Scotia",
"scalerank", 3,
"labelrank", 3,
"datarank", 3
),
NATURAL_EARTH_SOURCE,
"ne_10m_admin_1_states_provinces",
0
));
assertFeatures(4, List.of(Map.of(
"_layer", "place",
"class", "province",
"name", "Lugo",
"name:es", "provincia de Lugo",
"rank", 3,
"_type", "point",
"_minzoom", 2
)), process(SimpleFeature.create(
newPoint(0.1, 0.1),
Map.of(
"place", "province",
"wikidata", "Q95027",
"name", "Lugo"
),
OSM_SOURCE,
null,
0
)));
}
@Test
public void testIslandPoint() {
assertFeatures(0, List.of(Map.of(

View File

@@ -181,4 +181,30 @@ public class PoiTest extends AbstractLayerTest {
)
)));
}
@Test
public void testEmbassy() {
assertFeatures(7, List.of(Map.of(
"_layer", "poi",
"class", "diplomatic",
"subclass", "diplomatic",
"name", "The Embassy"
)), process(pointFeature(Map.of(
"office", "diplomatic",
"name", "The Embassy"
))));
}
@Test
public void testLocksmith() {
assertFeatures(7, List.of(Map.of(
"_layer", "poi",
"class", "shop",
"subclass", "locksmith",
"name", "The Locksmith"
)), process(pointFeature(Map.of(
"shop", "locksmith",
"name", "The Locksmith"
))));
}
}

View File

@@ -1,14 +1,20 @@
package com.onthegomap.planetiler.basemap.layers;
import static com.onthegomap.planetiler.TestUtils.newLineString;
import static com.onthegomap.planetiler.TestUtils.newPoint;
import static com.onthegomap.planetiler.TestUtils.rectangle;
import static com.onthegomap.planetiler.basemap.BasemapProfile.NATURAL_EARTH_SOURCE;
import static com.onthegomap.planetiler.basemap.BasemapProfile.OSM_SOURCE;
import com.onthegomap.planetiler.FeatureCollector;
import com.onthegomap.planetiler.basemap.BasemapProfile;
import com.onthegomap.planetiler.config.Arguments;
import com.onthegomap.planetiler.config.PlanetilerConfig;
import com.onthegomap.planetiler.geo.GeometryException;
import com.onthegomap.planetiler.reader.SimpleFeature;
import com.onthegomap.planetiler.reader.SourceFeature;
import com.onthegomap.planetiler.reader.osm.OsmElement;
import com.onthegomap.planetiler.stats.Stats;
import java.util.List;
import java.util.Map;
import java.util.stream.Stream;
@@ -33,12 +39,12 @@ public class TransportationTest extends AbstractLayerTest {
"_type", "line",
"class", "path",
"subclass", "footway",
"oneway", 0,
"oneway", "<null>",
"name", "<null>",
"layer", "<null>",
"_buffer", 4d,
"_minpixelsize", 0d,
"_minzoom", 13,
"_maxzoom", 14
"_minzoom", 13
), Map.of(
"_layer", "transportation_name",
"_type", "line",
@@ -54,9 +60,10 @@ public class TransportationTest extends AbstractLayerTest {
assertFeatures(13, List.of(Map.of(
"_layer", "transportation",
"surface", "paved",
"oneway", 0,
"oneway", "<null>",
"layer", "<null>",
"level", 0L,
"ramp", 0,
"ramp", "<null>",
"bicycle", "dismount",
"foot", "designated"
), Map.of(
@@ -70,20 +77,154 @@ public class TransportationTest extends AbstractLayerTest {
)), result);
}
@Test
public void testImportantPath() {
var rel = new OsmElement.Relation(1);
rel.setTag("colour", "white");
rel.setTag("name", "Appalachian Trail - 11 MA");
rel.setTag("network", "nwn");
rel.setTag("osmc", "symbol white::white_stripe");
rel.setTag("ref", "AT");
rel.setTag("route", "hiking");
rel.setTag("short_name", "AT 11 MA");
rel.setTag("symbol", "white-paint blazes");
rel.setTag("type", "route");
rel.setTag("wikidata", "Q620648");
rel.setTag("wikipedia", "en:Appalachian Trail");
FeatureCollector features = process(lineFeatureWithRelation(
profile.preprocessOsmRelation(rel),
Map.of(
"bicycle", "no",
"highway", "path",
"horse", "no",
"name", "Appalachian Trail",
"ref", "AT",
"surface", "ground"
)));
assertFeatures(12, List.of(Map.of(
"_layer", "transportation",
"_type", "line",
"class", "path",
"subclass", "path",
"oneway", "<null>",
"name", "<null>",
"layer", "<null>",
"_buffer", 4d,
"_minpixelsize", 0d,
"_minzoom", 12
), Map.of(
"_layer", "transportation_name",
"_type", "line",
"class", "path",
"subclass", "path",
"name", "Appalachian Trail",
"name_int", "Appalachian Trail",
"name:latin", "Appalachian Trail",
"_minpixelsize", 0d,
"_minzoom", 12
)), features);
}
@Test
public void testUnnamedPath() {
assertFeatures(13, List.of(Map.of(
assertFeatures(14, List.of(Map.of(
"_layer", "transportation",
"class", "path",
"subclass", "path",
"surface", "unpaved",
"oneway", 0
"oneway", "<null>",
"_minzoom", 14
)), process(lineFeature(Map.of(
"surface", "dirt",
"highway", "path"
))));
}
@Test
public void testPrivatePath() {
assertFeatures(9, List.of(Map.of(
"_layer", "transportation",
"class", "path",
"access", "no"
)), process(lineFeature(Map.of(
"access", "private",
"highway", "path"
))));
assertFeatures(9, List.of(Map.of(
"_layer", "transportation",
"class", "path",
"access", "no"
)), process(lineFeature(Map.of(
"access", "no",
"highway", "path"
))));
assertFeatures(8, List.of(Map.of(
"_layer", "transportation",
"class", "path",
"access", "<null>"
)), process(lineFeature(Map.of(
"access", "no",
"highway", "path"
))));
}
@Test
public void testExpressway() {
assertFeatures(8, List.of(Map.of(
"_layer", "transportation",
"class", "motorway",
"expressway", "<null>"
)), process(lineFeature(Map.of(
"highway", "motorway",
"expressway", "yes"
))));
assertFeatures(8, List.of(Map.of(
"_layer", "transportation",
"class", "primary",
"expressway", 1
)), process(lineFeature(Map.of(
"highway", "primary",
"expressway", "yes"
))));
assertFeatures(7, List.of(Map.of(
"_layer", "transportation",
"class", "primary",
"expressway", "<null>"
)), process(lineFeature(Map.of(
"highway", "primary",
"expressway", "yes"
))));
}
@Test
public void testToll() {
assertFeatures(9, List.of(Map.of(
"_layer", "transportation",
"class", "motorway",
"toll", "<null>"
)), process(lineFeature(Map.of(
"highway", "motorway"
))));
assertFeatures(9, List.of(Map.of(
"_layer", "transportation",
"class", "motorway",
"toll", 1
)), process(lineFeature(Map.of(
"highway", "motorway",
"toll", "yes"
))));
assertFeatures(8, List.of(Map.of(
"_layer", "transportation",
"class", "motorway",
"toll", "<null>"
)), process(lineFeature(Map.of(
"highway", "motorway",
"toll", "yes"
))));
}
@Test
public void testIndoorTunnelSteps() {
assertFeatures(13, List.of(Map.of(
@@ -93,7 +234,7 @@ public class TransportationTest extends AbstractLayerTest {
"brunnel", "tunnel",
"indoor", 1,
"oneway", 1,
"ramp", 1
"ramp", "<null>"
)), process(lineFeature(Map.of(
"highway", "steps",
"tunnel", "building_passage",
@@ -124,12 +265,37 @@ public class TransportationTest extends AbstractLayerTest {
"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(
"_layer", "transportation",
"class", "motorway",
"surface", "paved",
"oneway", 1,
"ramp", 0,
"ramp", "<null>",
"bicycle", "no",
"foot", "no",
"horse", "no",
@@ -143,6 +309,7 @@ public class TransportationTest extends AbstractLayerTest {
"ref", "90",
"ref_length", 2,
"network", "us-interstate",
"route_1", "US:I=90",
"brunnel", "<null>",
"_minzoom", 6
)), features);
@@ -166,11 +333,92 @@ public class TransportationTest extends AbstractLayerTest {
"ref", "90",
"ref_length", 2,
"network", "us-interstate",
"route_1", "US:I=90",
"brunnel", "<null>",
"_minzoom", 6
)), features);
}
@Test
public void testMotorwayJunction() {
var otherNode1 = new OsmElement.Node(1, 1, 1);
var junctionNode = new OsmElement.Node(2, 1, 2);
var otherNode2 = new OsmElement.Node(3, 1, 3);
var otherNode3 = new OsmElement.Node(4, 2, 3);
junctionNode.setTag("highway", "motorway_junction");
junctionNode.setTag("name", "exit 1");
junctionNode.setTag("layer", "1");
junctionNode.setTag("ref", "12");
// 2 ways meet at junctionNode (id=2) - use most important class of a highway intersecting it (motorway)
var way1 = new OsmElement.Way(5);
way1.setTag("highway", "motorway");
way1.nodes().add(otherNode1.id(), junctionNode.id(), otherNode2.id());
var way2 = new OsmElement.Way(6);
way2.setTag("highway", "primary");
way2.nodes().add(junctionNode.id(), otherNode3.id());
profile.preprocessOsmNode(otherNode1);
profile.preprocessOsmNode(junctionNode);
profile.preprocessOsmNode(otherNode2);
profile.preprocessOsmNode(otherNode3);
profile.preprocessOsmWay(way1);
profile.preprocessOsmWay(way2);
FeatureCollector features = process(SimpleFeature.create(
newPoint(1, 2),
junctionNode.tags(),
OSM_SOURCE,
null,
junctionNode.id()
));
assertFeatures(13, List.of(mapOf(
"_layer", "transportation_name",
"class", "motorway",
"subclass", "junction",
"name", "exit 1",
"ref", "12",
"ref_length", 2,
"layer", 1L,
"_type", "point",
"_minzoom", 10
)), features);
}
@Test
public void testInterstateMotorwayWithoutWayInfo() {
var rel = new OsmElement.Relation(1);
rel.setTag("type", "route");
rel.setTag("route", "road");
rel.setTag("network", "US:I");
rel.setTag("ref", "90");
FeatureCollector features = process(lineFeatureWithRelation(
profile.preprocessOsmRelation(rel),
Map.of(
"highway", "motorway"
)));
assertFeatures(13, List.of(mapOf(
"_layer", "transportation",
"class", "motorway",
"network", "us-interstate",
"_minzoom", 4
), Map.of(
"_layer", "transportation_name",
"class", "motorway",
"ref", "90",
"ref_length", 2,
"network", "us-interstate",
"brunnel", "<null>",
"route_1", "US:I=90",
"_minzoom", 6
)), features);
}
@Test
public void testPrimaryRoadConstruction() {
assertFeatures(13, List.of(Map.of(
@@ -223,7 +471,7 @@ public class TransportationTest extends AbstractLayerTest {
"_layer", "transportation",
"class", "service",
"service", "driveway",
"_minzoom", 12
"_minzoom", 14
)), process(lineFeature(Map.of(
"highway", "service",
"service", "driveway"
@@ -256,7 +504,28 @@ public class TransportationTest extends AbstractLayerTest {
}
@Test
public void testTrack() {
public void testNamedTrack() {
assertFeatures(13, List.of(Map.of(
"_layer", "transportation",
"class", "track",
"surface", "unpaved",
"horse", "yes",
"_minzoom", 13
), Map.of(
"_layer", "transportation_name",
"class", "track",
"name", "name",
"_minzoom", 13
)), process(lineFeature(Map.of(
"highway", "track",
"surface", "dirt",
"horse", "yes",
"name", "name"
))));
}
@Test
public void testUnnamedTrack() {
assertFeatures(13, List.of(Map.of(
"_layer", "transportation",
"class", "track",
@@ -270,6 +539,29 @@ public class TransportationTest extends AbstractLayerTest {
))));
}
@Test
public void testBusway() {
assertFeatures(13, List.of(Map.of(
"_layer", "transportation",
"class", "busway",
"brunnel", "tunnel",
"_minzoom", 11
), Map.of(
"_layer", "transportation_name",
"class", "busway",
"name", "Silver Line",
"_minzoom", 12
)), process(lineFeature(Map.of(
"access", "no",
"bus", "yes",
"highway", "busway",
"layer", "-1",
"name", "Silver Line",
"trolley_wire", "yes",
"tunnel", "yes"
))));
}
final OsmElement.Relation relUS = new OsmElement.Relation(1);
{
@@ -294,8 +586,9 @@ public class TransportationTest extends AbstractLayerTest {
"_layer", "transportation",
"class", "primary",
"surface", "paved",
"oneway", 0,
"ramp", 0,
"oneway", "<null>",
"ramp", "<null>",
"network", "us-highway",
"_minzoom", 7
), Map.of(
"_layer", "transportation_name",
@@ -305,6 +598,8 @@ public class TransportationTest extends AbstractLayerTest {
"ref", "3",
"ref_length", 1,
"network", "us-highway",
"route_1", "US:US=3",
"route_2", "US:MA=2",
"_minzoom", 12
)), process(lineFeatureWithRelation(
Stream.concat(
@@ -325,12 +620,17 @@ public class TransportationTest extends AbstractLayerTest {
), Map.of(
"_layer", "transportation_name",
"class", "primary",
"route_1", "US:US=3",
"route_2", "US:MA=2",
"ref", "3",
"network", "us-highway"
)), process(lineFeatureWithRelation(
Stream.concat(
profile.preprocessOsmRelation(relMA).stream(),
profile.preprocessOsmRelation(relUS).stream()
Stream.concat( // ignore duplicates
profile.preprocessOsmRelation(relUS).stream(),
profile.preprocessOsmRelation(relUS).stream()
)
).toList(),
Map.of(
"highway", "primary",
@@ -368,7 +668,8 @@ public class TransportationTest extends AbstractLayerTest {
public void testCompoundRef() {
assertFeatures(13, List.of(Map.of(
"_layer", "transportation",
"class", "primary"
"class", "primary",
"network", "<null>"
), Map.of(
"_layer", "transportation_name",
"class", "primary",
@@ -409,7 +710,7 @@ public class TransportationTest extends AbstractLayerTest {
"class", "motorway",
"surface", "paved",
"oneway", 1,
"ramp", 0,
"ramp", "<null>",
"_minzoom", 4
), Map.of(
"_layer", "transportation_name",
@@ -438,7 +739,7 @@ public class TransportationTest extends AbstractLayerTest {
"_layer", "transportation",
"class", "motorway",
"oneway", 1,
"ramp", 0,
"ramp", "<null>",
"_minzoom", 4
), Map.of(
"_layer", "transportation_name",
@@ -464,7 +765,7 @@ public class TransportationTest extends AbstractLayerTest {
"_layer", "transportation",
"class", "motorway",
"oneway", 1,
"ramp", 0,
"ramp", "<null>",
"_minzoom", 4
), Map.of(
"_layer", "transportation_name",
@@ -504,8 +805,8 @@ public class TransportationTest extends AbstractLayerTest {
"subclass", "light_rail",
"brunnel", "tunnel",
"layer", -1L,
"oneway", 0,
"ramp", 0,
"oneway", "<null>",
"ramp", "<null>",
"_minzoom", 11,
"_maxzoom", 14,
@@ -526,8 +827,8 @@ public class TransportationTest extends AbstractLayerTest {
"subclass", "subway",
"brunnel", "tunnel",
"layer", -2L,
"oneway", 0,
"ramp", 0,
"oneway", "<null>",
"ramp", "<null>",
"_minzoom", 14,
"_maxzoom", 14,
@@ -561,6 +862,7 @@ public class TransportationTest extends AbstractLayerTest {
"layer", "-2"
))));
assertFeatures(13, List.of(Map.of(
"layer", "<null>",
"_minzoom", 10
)), process(lineFeature(Map.of(
"railway", "rail",
@@ -599,11 +901,20 @@ public class TransportationTest extends AbstractLayerTest {
@Test
public void testAerialway() {
assertFeatures(10, List.of(Map.of(
assertFeatures(12, List.of(Map.of(
"_layer", "transportation",
"class", "aerialway",
"subclass", "gondola",
"_minzoom", 12,
"_maxzoom", 14,
"_type", "line"
), Map.of(
"_layer", "transportation_name",
"class", "aerialway",
"subclass", "gondola",
"name", "Summit Gondola",
"_minzoom", 12,
"_maxzoom", 14,
"_type", "line"
@@ -627,6 +938,14 @@ public class TransportationTest extends AbstractLayerTest {
"_minzoom", 11,
"_maxzoom", 14,
"_type", "line"
), Map.of(
"_layer", "transportation_name",
"class", "ferry",
"name", "Boston - Provincetown Ferry",
"_minzoom", 12,
"_maxzoom", 14,
"_type", "line"
)), process(lineFeature(Map.of(
"route", "ferry",
"name", "Boston - Provincetown Ferry",
@@ -718,4 +1037,25 @@ public class TransportationTest extends AbstractLayerTest {
getWaySortKey(Map.of("highway", "motorway", "layer", "-2"))
);
}
@Test
public void testTransportationNameLayerRequiresTransportationLayer() {
var profile = new BasemapProfile(translations, PlanetilerConfig.from(Arguments.of(
"only_layers", "transportation_name"
)), Stats.inMemory());
SourceFeature feature = lineFeature(Map.of(
"highway", "path",
"name", "test"
));
var collector = featureCollectorFactory.get(feature);
profile.processFeature(feature, collector);
assertFeatures(14, List.of(Map.of(
"_layer", "transportation_name",
"class", "path",
"name", "test"
), Map.of(
"_layer", "transportation",
"class", "path"
)), collector);
}
}

View File

@@ -132,7 +132,7 @@ public class WaterTest extends AbstractLayerTest {
"_minzoom", 6,
"_maxzoom", 14
)), process(polygonFeature(Map.of(
"waterway", "stream",
"waterway", "riverbank",
"bridge", "1",
"intermittent", "1"
))));
@@ -152,6 +152,39 @@ public class WaterTest extends AbstractLayerTest {
))));
}
@Test
public void testRiverbank() {
assertFeatures(11, List.of(Map.of(
"class", "river",
"_layer", "water",
"_type", "polygon"
)), process(polygonFeature(Map.of(
"waterway", "riverbank"
))));
}
@Test
public void testRiverk() {
assertFeatures(11, List.of(Map.of(
"class", "river",
"_layer", "water",
"_type", "polygon"
)), process(polygonFeature(Map.of(
"water", "river"
))));
}
@Test
public void testSpring() {
assertFeatures(11, List.of(Map.of(
"class", "lake",
"_layer", "water",
"_type", "polygon"
)), process(polygonFeature(Map.of(
"natural", "spring"
))));
}
@Test
public void testOceanZoomLevels() {
assertCoversZoomRange(0, 14, "water",

View File

@@ -2,17 +2,86 @@ package com.onthegomap.planetiler.basemap.layers;
import static com.onthegomap.planetiler.TestUtils.newLineString;
import static com.onthegomap.planetiler.basemap.BasemapProfile.NATURAL_EARTH_SOURCE;
import static com.onthegomap.planetiler.basemap.BasemapProfile.OSM_SOURCE;
import static org.junit.jupiter.api.Assertions.assertEquals;
import com.onthegomap.planetiler.FeatureCollector;
import com.onthegomap.planetiler.VectorTile;
import com.onthegomap.planetiler.geo.GeometryException;
import com.onthegomap.planetiler.reader.SimpleFeature;
import com.onthegomap.planetiler.reader.osm.OsmElement;
import com.onthegomap.planetiler.reader.osm.OsmReader;
import com.onthegomap.planetiler.reader.osm.OsmRelationInfo;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
public class WaterwayTest extends AbstractLayerTest {
@ParameterizedTest
@ValueSource(booleans = {false, true})
public void testOsmWaterwayRelation(boolean isLongEnough) throws GeometryException {
var rel = new OsmElement.Relation(1);
rel.setTag("name", "River Relation");
rel.setTag("name:es", "ES name");
rel.setTag("waterway", "river");
List<OsmRelationInfo> relationInfos = profile.preprocessOsmRelation(rel);
FeatureCollector features = process(SimpleFeature.createFakeOsmFeature(
newLineString(0, 0, 0, isLongEnough ? 3 : 1),
Map.of(),
OSM_SOURCE,
null,
0,
(relationInfos == null ? List.<OsmRelationInfo>of() : relationInfos).stream()
.map(r -> new OsmReader.RelationMember<>("", r)).toList()
));
assertFeatures(14, List.of(Map.of(
"class", "river",
"name", "River Relation",
"name:es", "ES name",
"_relid", 1L,
"_layer", "waterway",
"_type", "line",
"_minzoom", 6,
"_maxzoom", 8,
"_buffer", 4d
)), features);
// ensure that post-processing combines waterways, and filters out ones that
// belong to rivers that are not long enough to be shown
var line1 = new VectorTile.Feature(
Waterway.LAYER_NAME,
1,
VectorTile.encodeGeometry(newLineString(0, 0, 10, 0)),
mapOf("name", "river", "_relid", 1L),
0
);
var line2 = new VectorTile.Feature(
Waterway.LAYER_NAME,
1,
VectorTile.encodeGeometry(newLineString(10, 0, 20, 0)),
mapOf("name", "river", "_relid", 1L),
0
);
var connected = new VectorTile.Feature(
Waterway.LAYER_NAME,
1,
VectorTile.encodeGeometry(newLineString(0, 0, 20, 0)),
mapOf("name", "river"),
0
);
assertEquals(
isLongEnough ? List.of(connected) : List.of(),
profile.postProcessLayerFeatures(Waterway.LAYER_NAME, 8, new ArrayList<>(List.of(line1, line2)))
);
}
@Test
public void testWaterwayImportantRiverProcess() {
var charlesRiver = process(lineFeature(Map.of(
@@ -163,24 +232,5 @@ public class WaterwayTest extends AbstractLayerTest {
"ne_50m_rivers_lake_centerlines",
0
)));
assertFeatures(6, List.of(Map.of(
"class", "river",
"intermittent", "<null>",
"_layer", "waterway",
"_type", "line",
"_minzoom", 6,
"_maxzoom", 8
)), process(SimpleFeature.create(
newLineString(0, 0, 1, 1),
Map.of(
"featurecla", "River",
"name", "name"
),
NATURAL_EARTH_SOURCE,
"ne_10m_rivers_lake_centerlines",
0
)));
}
}