Don't get transportation_name ref values from minor networks (#148)

This commit is contained in:
Michael Barry
2022-03-25 05:42:45 -04:00
committed by GitHub
parent c7ee23e8aa
commit b14b4775e9
2 changed files with 126 additions and 16 deletions

View File

@@ -121,6 +121,7 @@ public class TransportationName implements
private final boolean sizeForShield;
private final boolean limitMerge;
private final PlanetilerConfig config;
private final boolean minorRefs;
private Transportation transportation;
private final LongByteMap motorwayJunctionHighwayClasses = Hppc.newLongByteHashMap();
@@ -141,6 +142,11 @@ public class TransportationName implements
"transportation_name layer: limit merge so we don't combine different relations to help merge long highways",
false
);
this.minorRefs = config.arguments().getBoolean(
"transportation_name_minor_refs",
"transportation_name layer: include name and refs from minor road networks if not present on a way",
false
);
}
public void needsTransportationLayer(Transportation transportation) {
@@ -208,9 +214,22 @@ public class TransportationName implements
public void process(Tables.OsmHighwayLinestring element, FeatureCollector features) {
String ref = element.ref();
List<Transportation.RouteRelation> relations = transportation.getRouteRelations(element);
Transportation.RouteRelation relation = relations.isEmpty() ? null : relations.get(0);
if (relation != null && nullIfEmpty(relation.ref()) != null) {
ref = relation.ref();
Transportation.RouteRelation firstRelationWithNetwork = relations.stream()
.filter(rel -> rel.networkType() != null)
.findFirst()
.orElse(null);
if (firstRelationWithNetwork != null && !nullOrEmpty(firstRelationWithNetwork.ref())) {
ref = firstRelationWithNetwork.ref();
}
// if transportation_name_minor_refs flag set and we don't have a ref yet, then pull it from any network
if (nullOrEmpty(ref) && minorRefs && !relations.isEmpty()) {
ref = relations.stream()
.map(r -> r.ref())
.filter(r -> !nullOrEmpty(r))
.findFirst()
.orElse(null);
}
String name = nullIfEmpty(element.name());
@@ -240,8 +259,8 @@ public class TransportationName implements
.setAttr(Fields.REF, ref)
.setAttr(Fields.REF_LENGTH, ref != null ? ref.length() : null)
.setAttr(Fields.NETWORK,
(relation != null && relation.networkType() != null) ? relation.networkType().name :
!nullOrEmpty(ref) ? "road" : null)
firstRelationWithNetwork != null ? firstRelationWithNetwork.networkType().name : !nullOrEmpty(ref) ? "road" :
null)
.setAttr(Fields.CLASS, highwayClass)
.setAttr(Fields.SUBCLASS, highwaySubclass(highwayClass, null, highway))
.setMinPixelSize(0)
@@ -267,7 +286,7 @@ public class TransportationName implements
if (limitMerge) {
feature
.setAttr(LINK_TEMP_KEY, isLink ? 1 : 0)
.setAttr(RELATION_ID_TEMP_KEY, relation == null ? null : relation.id());
.setAttr(RELATION_ID_TEMP_KEY, firstRelationWithNetwork == null ? null : firstRelationWithNetwork.id());
}
if (isFootwayOrSteps(highway)) {