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

@@ -137,7 +137,7 @@ class OpenMapTilesTest {
assertFeatureNear(mbtiles, "housenumber", Map.of(
"housenumber", "27"
), 7.42117, 43.73652, 14, 14);
assertNumFeatures("housenumber", Map.of(), 14, 274, Point.class);
assertNumFeatures("housenumber", Map.of(), 14, 231, Point.class);
}
@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) {
return SimpleFeature.createFakeOsmFeature(
newLineString(0, 0, 1, 0, 1, 1, 0, 1, 0, 0),

View File

@@ -1,8 +1,14 @@
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.Map;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
class HousenumberTest extends AbstractLayerTest {
@@ -27,4 +33,127 @@ class HousenumberTest extends AbstractLayerTest {
"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
void testSmallerPark() {
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;
import static com.onthegomap.planetiler.TestUtils.newPoint;
import com.onthegomap.planetiler.FeatureCollector;
import com.onthegomap.planetiler.geo.GeometryException;
import com.onthegomap.planetiler.reader.SimpleFeature;
import com.onthegomap.planetiler.reader.SourceFeature;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import org.openmaptiles.OpenMapTilesProfile;
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
@ValueSource(booleans = {false, true})
void testPlaceOfWorshipFromReligionTag(boolean area) {
@@ -185,7 +352,7 @@ class PoiTest extends AbstractLayerTest {
void testEmbassy() {
assertFeatures(7, List.of(Map.of(
"_layer", "poi",
"class", "diplomatic",
"class", "office",
"subclass", "diplomatic",
"name", "The Embassy"
)), process(pointFeature(Map.of(
@@ -274,4 +441,28 @@ class PoiTest extends AbstractLayerTest {
"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.newPoint;
import static com.onthegomap.planetiler.TestUtils.rectangle;
import static org.junit.jupiter.api.Assertions.assertFalse;
import com.onthegomap.planetiler.FeatureCollector;
import com.onthegomap.planetiler.config.Arguments;
@@ -17,6 +18,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
@@ -267,31 +269,6 @@ 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",
@@ -341,6 +318,51 @@ class TransportationTest extends AbstractLayerTest {
)), 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
void testRouteWithoutNetworkType() {
var rel1 = new OsmElement.Relation(1);
@@ -951,6 +973,316 @@ class TransportationTest extends AbstractLayerTest {
)), 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
void testGreatBritainHighway() {
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
void testMergesDisconnectedRoadNameFeatures() throws GeometryException {
testMergesLinestrings(Map.of("class", "motorway"), TransportationName.LAYER_NAME, 10, 14);
@@ -1176,8 +1809,9 @@ class TransportationTest extends AbstractLayerTest {
"_layer", "transportation",
"class", "ferry",
"_minzoom", 11,
"_minzoom", 4,
"_maxzoom", 14,
"_minpixelsize", 32d,
"_type", "line"
), Map.of(
"_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
void testIssue58() {
// test subject: https://www.openstreetmap.org/way/222564359

View File

@@ -27,7 +27,7 @@ class WaterNameTest extends AbstractLayerTest {
"_layer", "water_name",
"_type", "point",
"_minzoom", 9,
"_minzoom", 3,
"_maxzoom", 14
)), process(polygonFeatureWithArea(1, Map.of(
"name", "waterway",
@@ -36,19 +36,6 @@ class WaterNameTest extends AbstractLayerTest {
"water", "pond",
"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
@@ -71,7 +58,7 @@ class WaterNameTest extends AbstractLayerTest {
"_layer", "water_name",
"_type", "line",
"_geom", new TestUtils.NormGeometry(GeoUtils.latLonToWorldCoords(newLineString(0, 0, 1, 1))),
"_minzoom", 9,
"_minzoom", 3,
"_maxzoom", 14,
"_minpixelsize", "waterway".length() * 6d
)), process(SimpleFeature.create(
@@ -121,7 +108,7 @@ class WaterNameTest extends AbstractLayerTest {
newLineString(0, 0, 1, 1),
newLineString(2, 2, 3, 3)
}))),
"_minzoom", 9,
"_minzoom", 3,
"_maxzoom", 14,
"_minpixelsize", "waterway".length() * 6d
)), 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
void testMarinePoint() {
assertFeatures(11, List.of(), process(SimpleFeature.create(