mirror of
https://github.com/cfpwastaken/planetiler-openmaptiles.git
synced 2026-02-04 12:31:10 +00:00
Handle more than one centerline for a lake (#139)
This commit is contained in:
@@ -111,7 +111,13 @@ public class WaterName implements
|
||||
try {
|
||||
// multiple threads call this concurrently
|
||||
synchronized (this) {
|
||||
lakeCenterlines.put(osmId, feature.worldGeometry());
|
||||
// if we already have a centerline for this OSM_ID, then merge the existing one with this one
|
||||
var newGeometry = feature.worldGeometry();
|
||||
var oldGeometry = lakeCenterlines.get(osmId);
|
||||
if (oldGeometry != null) {
|
||||
newGeometry = GeoUtils.combine(oldGeometry, newGeometry);
|
||||
}
|
||||
lakeCenterlines.put(osmId, newGeometry);
|
||||
}
|
||||
} catch (GeometryException e) {
|
||||
e.log(stats, "omt_water_name_lakeline", "Bad lake centerline: " + feature);
|
||||
|
||||
@@ -13,6 +13,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.locationtech.jts.geom.Geometry;
|
||||
|
||||
public class WaterNameTest extends AbstractLayerTest {
|
||||
|
||||
@@ -89,6 +90,56 @@ public class WaterNameTest extends AbstractLayerTest {
|
||||
)));
|
||||
}
|
||||
|
||||
@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
|
||||
)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMarinePoint() {
|
||||
assertFeatures(11, List.of(), process(SimpleFeature.create(
|
||||
|
||||
Reference in New Issue
Block a user