2021-12-23 10:42:24 +00:00
|
|
|
package com.onthegomap.planetiler.basemap.layers;
|
2021-06-23 01:46:42 +00:00
|
|
|
|
2021-12-23 10:42:24 +00:00
|
|
|
import static com.onthegomap.planetiler.TestUtils.newLineString;
|
|
|
|
import static com.onthegomap.planetiler.TestUtils.rectangle;
|
|
|
|
import static com.onthegomap.planetiler.basemap.BasemapProfile.LAKE_CENTERLINE_SOURCE;
|
|
|
|
import static com.onthegomap.planetiler.basemap.BasemapProfile.NATURAL_EARTH_SOURCE;
|
|
|
|
import static com.onthegomap.planetiler.basemap.BasemapProfile.OSM_SOURCE;
|
2021-06-23 01:46:42 +00:00
|
|
|
|
2021-12-23 10:42:24 +00:00
|
|
|
import com.onthegomap.planetiler.TestUtils;
|
|
|
|
import com.onthegomap.planetiler.geo.GeoUtils;
|
|
|
|
import com.onthegomap.planetiler.reader.SimpleFeature;
|
2021-06-23 01:46:42 +00:00
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
import org.junit.jupiter.api.Test;
|
2022-03-19 19:16:11 +00:00
|
|
|
import org.locationtech.jts.geom.Geometry;
|
2021-06-23 01:46:42 +00:00
|
|
|
|
2021-06-24 01:06:22 +00:00
|
|
|
public class WaterNameTest extends AbstractLayerTest {
|
2021-06-23 01:46:42 +00:00
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testWaterNamePoint() {
|
|
|
|
assertFeatures(11, List.of(Map.of(
|
|
|
|
"_layer", "water"
|
|
|
|
), Map.of(
|
|
|
|
"class", "lake",
|
|
|
|
"name", "waterway",
|
|
|
|
"name:es", "waterway es",
|
|
|
|
"intermittent", 1,
|
|
|
|
|
|
|
|
"_layer", "water_name",
|
|
|
|
"_type", "point",
|
|
|
|
"_minzoom", 9,
|
|
|
|
"_maxzoom", 14
|
|
|
|
)), process(polygonFeatureWithArea(1, Map.of(
|
|
|
|
"name", "waterway",
|
|
|
|
"name:es", "waterway es",
|
|
|
|
"natural", "water",
|
|
|
|
"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
|
|
|
|
public void testWaterNameLakeline() {
|
2021-09-10 00:46:20 +00:00
|
|
|
assertFeatures(11, List.of(), process(SimpleFeature.create(
|
2021-06-23 01:46:42 +00:00
|
|
|
newLineString(0, 0, 1, 1),
|
|
|
|
new HashMap<>(Map.<String, Object>of(
|
|
|
|
"OSM_ID", -10
|
|
|
|
)),
|
|
|
|
LAKE_CENTERLINE_SOURCE,
|
|
|
|
null,
|
|
|
|
0
|
|
|
|
)));
|
|
|
|
assertFeatures(10, List.of(Map.of(
|
|
|
|
"_layer", "water"
|
|
|
|
), Map.of(
|
|
|
|
"name", "waterway",
|
|
|
|
"name:es", "waterway es",
|
|
|
|
|
|
|
|
"_layer", "water_name",
|
|
|
|
"_type", "line",
|
|
|
|
"_geom", new TestUtils.NormGeometry(GeoUtils.latLonToWorldCoords(newLineString(0, 0, 1, 1))),
|
|
|
|
"_minzoom", 9,
|
|
|
|
"_maxzoom", 14,
|
|
|
|
"_minpixelsize", "waterway".length() * 6d
|
2021-09-10 00:46:20 +00:00
|
|
|
)), process(SimpleFeature.create(
|
2021-06-23 01:46:42 +00:00
|
|
|
GeoUtils.worldToLatLonCoords(rectangle(0, Math.sqrt(1))),
|
|
|
|
new HashMap<>(Map.<String, Object>of(
|
|
|
|
"name", "waterway",
|
|
|
|
"name:es", "waterway es",
|
|
|
|
"natural", "water",
|
|
|
|
"water", "pond"
|
|
|
|
)),
|
|
|
|
OSM_SOURCE,
|
|
|
|
null,
|
|
|
|
10
|
|
|
|
)));
|
|
|
|
}
|
|
|
|
|
2022-03-19 19:16:11 +00:00
|
|
|
@Test
|
|
|
|
public void testWaterNameMultipleLakelines() {
|
|
|
|
assertFeatures(11, List.of(), process(SimpleFeature.create(
|
|
|
|
newLineString(0, 0, 1, 1),
|
|
|
|
new HashMap<>(Map.<String, Object>of(
|
|
|
|
"OSM_ID", -10
|
|
|
|
)),
|
|
|
|
LAKE_CENTERLINE_SOURCE,
|
|
|
|
null,
|
|
|
|
0
|
|
|
|
)));
|
|
|
|
assertFeatures(11, List.of(), process(SimpleFeature.create(
|
|
|
|
newLineString(2, 2, 3, 3),
|
|
|
|
new HashMap<>(Map.<String, Object>of(
|
|
|
|
"OSM_ID", -10
|
|
|
|
)),
|
|
|
|
LAKE_CENTERLINE_SOURCE,
|
|
|
|
null,
|
|
|
|
0
|
|
|
|
)));
|
|
|
|
assertFeatures(10, List.of(Map.of(
|
|
|
|
"_layer", "water"
|
|
|
|
), Map.of(
|
|
|
|
"name", "waterway",
|
|
|
|
"name:es", "waterway es",
|
|
|
|
|
|
|
|
"_layer", "water_name",
|
|
|
|
"_geom",
|
|
|
|
new TestUtils.NormGeometry(
|
|
|
|
GeoUtils.latLonToWorldCoords(GeoUtils.JTS_FACTORY.createGeometryCollection(new Geometry[]{
|
|
|
|
newLineString(0, 0, 1, 1),
|
|
|
|
newLineString(2, 2, 3, 3)
|
|
|
|
}))),
|
|
|
|
"_minzoom", 9,
|
|
|
|
"_maxzoom", 14,
|
|
|
|
"_minpixelsize", "waterway".length() * 6d
|
|
|
|
)), process(SimpleFeature.create(
|
|
|
|
GeoUtils.worldToLatLonCoords(rectangle(0, Math.sqrt(1))),
|
|
|
|
new HashMap<>(Map.<String, Object>of(
|
|
|
|
"name", "waterway",
|
|
|
|
"name:es", "waterway es",
|
|
|
|
"natural", "water",
|
|
|
|
"water", "pond"
|
|
|
|
)),
|
|
|
|
OSM_SOURCE,
|
|
|
|
null,
|
|
|
|
10
|
|
|
|
)));
|
|
|
|
}
|
|
|
|
|
2021-06-23 01:46:42 +00:00
|
|
|
@Test
|
|
|
|
public void testMarinePoint() {
|
2021-09-10 00:46:20 +00:00
|
|
|
assertFeatures(11, List.of(), process(SimpleFeature.create(
|
2021-06-23 01:46:42 +00:00
|
|
|
newLineString(0, 0, 1, 1),
|
|
|
|
new HashMap<>(Map.<String, Object>of(
|
2021-06-23 10:17:00 +00:00
|
|
|
"scalerank", 1,
|
|
|
|
"name", "Black sea"
|
2021-06-23 01:46:42 +00:00
|
|
|
)),
|
|
|
|
NATURAL_EARTH_SOURCE,
|
|
|
|
"ne_10m_geography_marine_polys",
|
|
|
|
0
|
|
|
|
)));
|
|
|
|
|
|
|
|
// name match - use scale rank from NE
|
|
|
|
assertFeatures(10, List.of(Map.of(
|
2021-06-23 10:17:00 +00:00
|
|
|
"name", "Black Sea",
|
|
|
|
"name:es", "Mar Negro",
|
2021-06-23 01:46:42 +00:00
|
|
|
"_layer", "water_name",
|
|
|
|
"_type", "point",
|
2021-06-23 10:17:00 +00:00
|
|
|
"_minzoom", 1,
|
2021-06-23 01:46:42 +00:00
|
|
|
"_maxzoom", 14
|
|
|
|
)), process(pointFeature(Map.of(
|
|
|
|
"rank", 9,
|
2021-06-23 10:17:00 +00:00
|
|
|
"name", "Black Sea",
|
|
|
|
"name:es", "Mar Negro",
|
2021-06-23 01:46:42 +00:00
|
|
|
"place", "sea"
|
|
|
|
))));
|
|
|
|
|
|
|
|
// name match but ocean - use min zoom=0
|
|
|
|
assertFeatures(10, List.of(Map.of(
|
|
|
|
"_layer", "water_name",
|
|
|
|
"_type", "point",
|
|
|
|
"_minzoom", 0,
|
|
|
|
"_maxzoom", 14
|
|
|
|
)), process(pointFeature(Map.of(
|
|
|
|
"rank", 9,
|
2021-06-23 10:17:00 +00:00
|
|
|
"name", "Black Sea",
|
2021-06-23 01:46:42 +00:00
|
|
|
"place", "ocean"
|
|
|
|
))));
|
|
|
|
|
|
|
|
// no name match - use OSM rank
|
|
|
|
assertFeatures(10, List.of(Map.of(
|
|
|
|
"_layer", "water_name",
|
|
|
|
"_type", "point",
|
|
|
|
"_minzoom", 9,
|
|
|
|
"_maxzoom", 14
|
|
|
|
)), process(pointFeature(Map.of(
|
|
|
|
"rank", 9,
|
|
|
|
"name", "Atlantic",
|
|
|
|
"place", "sea"
|
|
|
|
))));
|
|
|
|
|
|
|
|
// no rank at all, default to 8
|
|
|
|
assertFeatures(10, List.of(Map.of(
|
|
|
|
"_layer", "water_name",
|
|
|
|
"_type", "point",
|
|
|
|
"_minzoom", 8,
|
|
|
|
"_maxzoom", 14
|
|
|
|
)), process(pointFeature(Map.of(
|
|
|
|
"name", "Atlantic",
|
|
|
|
"place", "sea"
|
|
|
|
))));
|
|
|
|
}
|
|
|
|
}
|