Fix pedestrian area multipolygons (#63)

This commit is contained in:
Michael Barry
2022-01-27 06:14:37 -05:00
committed by GitHub
parent 57323485ce
commit 650f68455e
3 changed files with 40 additions and 5 deletions

View File

@@ -513,8 +513,9 @@ public class Transportation implements
public void process(Tables.OsmHighwayPolygon element, FeatureCollector features) {
String manMade = element.manMade();
if (isBridgeOrPier(manMade) ||
// ignore underground pedestrian areas
(element.isArea() && element.layer() >= 0)) {
// only allow closed ways where area=yes, and multipolygons
// and ignore underground pedestrian areas
(!element.source().canBeLine() && element.layer() >= 0)) {
String highwayClass = highwayClass(element.highway(), element.publicTransport(), null, element.manMade());
if (highwayClass != null) {
features.polygon(LAYER_NAME).setBufferPixels(BUFFER_SIZE)

View File

@@ -131,6 +131,17 @@ public abstract class AbstractLayerTest {
);
}
SourceFeature closedWayFeature(Map<String, Object> props) {
return SimpleFeature.createFakeOsmFeature(
newLineString(0, 0, 1, 0, 1, 1, 0, 1, 0, 0),
new HashMap<>(props),
OSM_SOURCE,
null,
0,
null
);
}
SourceFeature polygonFeatureWithArea(double area, Map<String, Object> props) {
return SimpleFeature.create(
GeoUtils.worldToLatLonCoords(rectangle(0, Math.sqrt(area))),

View File

@@ -990,7 +990,7 @@ public class TransportationTest extends AbstractLayerTest {
@Test
public void testPedestrianArea() {
assertFeatures(10, List.of(Map.of(
Map<String, Object> pedestrianArea = Map.of(
"_layer", "transportation",
"class", "path",
"subclass", "pedestrian",
@@ -998,13 +998,36 @@ public class TransportationTest extends AbstractLayerTest {
"_minzoom", 13,
"_maxzoom", 14,
"_type", "polygon"
)), process(polygonFeature(Map.of(
);
Map<String, Object> circularPath = Map.of(
"_layer", "transportation",
"class", "path",
"subclass", "pedestrian",
"_minzoom", 14,
"_maxzoom", 14,
"_type", "line"
);
assertFeatures(14, List.of(pedestrianArea), process(closedWayFeature(Map.of(
"highway", "pedestrian",
"area", "yes",
"foot", "yes"
))));
assertFeatures(14, List.of(pedestrianArea), process(polygonFeature(Map.of(
"highway", "pedestrian",
"foot", "yes"
))));
assertFeatures(14, List.of(circularPath), process(closedWayFeature(Map.of(
"highway", "pedestrian",
"foot", "yes"
))));
assertFeatures(14, List.of(circularPath), process(closedWayFeature(Map.of(
"highway", "pedestrian",
"foot", "yes",
"area", "no"
))));
// ignore underground pedestrian areas
assertFeatures(10, List.of(),
assertFeatures(14, List.of(),
process(polygonFeature(Map.of(
"highway", "pedestrian",
"area", "yes",