Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/main/java/io/sharedstreets/data/SharedStreetsOSMMetadata.java
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,17 @@ public Way.ROAD_CLASS getRoadClass() {
for(WaySectionMetadata waySection : this.waySections) {
if(roadClass == null || roadClass == waySection.roadClass)
roadClass = waySection.roadClass;
else {
roadClass = Way.ROAD_CLASS.ClassOther;

// if mixed segment make segment class equal lowest class
// per https://github.com/sharedstreets/sharedstreets-ref-system/issues/20#issuecomment-378079937
// [excluded road]
// |
// [highway=primary] | [highway=secondary]
// ====================*=====================
// [roadClass=secondary]

else if(waySection.roadClass.getValue() > roadClass.getValue()){
roadClass = waySection.roadClass;
Comment on lines +172 to +173
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, higher road class number is the "lowest grade" of road, and here we are ensuring that if a segment contains multiple road classes, we use the "lowest grade"?

break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ else if(roadClass.intValue() == Way.ROAD_CLASS.ClassTrunk.getValue())
filteredClasses.add(Way.ROAD_CLASS.ClassTrunk);

else if(roadClass.intValue() == Way.ROAD_CLASS.ClassMotorway.getValue())
filteredClasses.add(Way.ROAD_CLASS.ClassUnclassified);
filteredClasses.add(Way.ROAD_CLASS.ClassMotorway);

else if(roadClass.intValue() == Way.ROAD_CLASS.ClassResidential.getValue())
filteredClasses.add(Way.ROAD_CLASS.ClassResidential);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,20 @@ public static boolean canMerge(BaseSegment baseSegment1, BaseSegment baseSegment
return false;
}

// can't merge primary road classes with other road classes
//
// Motivation:
// We're merging aggressively, and creating mixed roadClass references to prevent poorly mapped OSM ways getting
// split up when they should be a contiguous reference. However, primary roads are often mapped with better quality
// and it makes sense to handle start/end of motorway/trunk roads properly.

int baseSegment1RoadClass = baseSegment1.getRoadClass().getValue();
int baseSegment2RoadClass = baseSegment2.getRoadClass().getValue();
int roadClassMergeThreshold = Way.ROAD_CLASS.ClassPrimary.getValue();
if(baseSegment1RoadClass != baseSegment2RoadClass && (baseSegment1RoadClass <= roadClassMergeThreshold || baseSegment2RoadClass <= roadClassMergeThreshold))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if both are below the threshold? I think in this case they should be mergeable, but I don't think they are with this logic.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest:

if(baseSegment1RoadClass != baseSegment2RoadClass) {
  if ((baseSegment1RoadClass < roadClassMergeThreshold && baseSegment2RoadClass >= roadClassMergeThreshold) || 
      (baseSegment2RoadClass < roadClassMergeThreshold && baseSegment1RoadClass >= roadClassMergeThreshold)) {
    return false;
  }
}

return false;


// check for duplicates-- need to catch circular segments (they appear mergable)
if(baseSegment1.waySections.length == baseSegment2.waySections.length) {
boolean duplicate = true;
Expand Down