Don't merge transportation segments with oneway tag (#40)

This commit is contained in:
Michael Barry
2022-10-05 06:18:28 -04:00
committed by GitHub
parent 7c46c776e7
commit 5c5704eb7c
3 changed files with 66 additions and 45 deletions

View File

@@ -176,20 +176,20 @@ public abstract class AbstractLayerTest {
);
}
protected void testMergesLinestrings(Map<String, Object> attrs, String layer,
double length, int zoom) throws GeometryException {
protected void testMergesLinestrings(Map<String, Object> attrs, String layer, double length, int zoom)
throws GeometryException {
var line1 = new VectorTile.Feature(
layer,
1,
VectorTile.encodeGeometry(newLineString(0, 0, length / 2, 0)),
attrs,
new HashMap<>(attrs),
0
);
var line2 = new VectorTile.Feature(
layer,
1,
VectorTile.encodeGeometry(newLineString(length / 2, 0, length, 0)),
attrs,
new HashMap<>(attrs),
0
);
var connected = new VectorTile.Feature(
@@ -206,20 +206,20 @@ public abstract class AbstractLayerTest {
);
}
protected void testDoesNotMergeLinestrings(Map<String, Object> attrs, String layer,
double length, int zoom) throws GeometryException {
protected void testDoesNotMergeLinestrings(Map<String, Object> attrs, String layer, double length, int zoom)
throws GeometryException {
var line1 = new VectorTile.Feature(
layer,
1,
VectorTile.encodeGeometry(newLineString(0, 0, length / 2, 0)),
attrs,
new HashMap<>(attrs),
0
);
var line2 = new VectorTile.Feature(
layer,
1,
VectorTile.encodeGeometry(newLineString(length / 2, 0, length, 0)),
attrs,
new HashMap<>(attrs),
0
);

View File

@@ -950,13 +950,17 @@ class TransportationTest extends AbstractLayerTest {
}
@Test
void testMergesDisconnectedRoadFeatures() throws GeometryException {
testMergesLinestrings(Map.of("class", "motorway"), Transportation.LAYER_NAME, 10, 14);
void testMergesDisconnectedRoadNameFeatures() throws GeometryException {
testMergesLinestrings(Map.of("class", "motorway"), TransportationName.LAYER_NAME, 10, 14);
}
@Test
void testMergesDisconnectedRoadNameFeatures() throws GeometryException {
testMergesLinestrings(Map.of("class", "motorway"), TransportationName.LAYER_NAME, 10, 14);
void testMergesDisconnectedRoadFeaturesUnlessOneway() throws GeometryException {
String layer = Transportation.LAYER_NAME;
testMergesLinestrings(Map.of("class", "motorway", "oneway", 0), layer, 10, 14);
testMergesLinestrings(Map.of("class", "motorway"), layer, 10, 14);
testDoesNotMergeLinestrings(Map.of("class", "motorway", "oneway", 1), layer, 10, 14);
testDoesNotMergeLinestrings(Map.of("class", "motorway", "oneway", -1), layer, 10, 14);
}
@Test