-
Notifications
You must be signed in to change notification settings - Fork 312
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve performance of Wayname calculation #2635
Conversation
…repeated recalculation of sliced current step line shape.
@@ -706,7 +714,6 @@ extension RouteMapViewController: NavigationViewDelegate { | |||
guard line.pointCount > 0 else { continue } | |||
let featureCoordinates = Array(UnsafeBufferPointer(start: line.coordinates, count: Int(line.pointCount))) | |||
let featurePolyline = LineString(featureCoordinates) | |||
let slicedLine = stepShape.sliced(from: closestCoordinate)! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, moving the slicing out of the loop should have a measurable impact on areas where there are lots of overlapping lines.
…the predicate filter for walking or cycling profiles.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -684,6 +684,15 @@ extension RouteMapViewController: NavigationViewDelegate { | |||
streetLabelLayer.lineOpacity = NSExpression(forConstantValue: 1) | |||
streetLabelLayer.lineWidth = NSExpression(forConstantValue: 20) | |||
streetLabelLayer.lineColor = NSExpression(forConstantValue: UIColor.white) | |||
|
|||
if ![DirectionsProfileIdentifier.walking, DirectionsProfileIdentifier.cycling].contains( router.routeProgress.routeOptions.profileIdentifier) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw, I think it’s possible to shorten this line based on the type of profileIdentifier
:
if ![DirectionsProfileIdentifier.walking, DirectionsProfileIdentifier.cycling].contains( router.routeProgress.routeOptions.profileIdentifier) { | |
if ![.walking, .cycling].contains(router.routeProgress.routeOptions.profileIdentifier) { |
let roadPredicates = ["motorway", "motorway_link", "trunk", "trunk_link", "primary", "primary_link", "secondary", "secondary_link", "tertiary", "tertiary_link", "street", "street_limited", "roundabout", "mini_roundabout"].compactMap { roadClass -> NSPredicate? in | ||
return NSPredicate(format: "%K == %@", "class", roadClass) | ||
} | ||
let compoundPredicate = NSCompoundPredicate(orPredicateWithSubpredicates: roadPredicates) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something along these lines should work and would probably perform slightly better:
let roadPredicates = ["motorway", "motorway_link", "trunk", "trunk_link", "primary", "primary_link", "secondary", "secondary_link", "tertiary", "tertiary_link", "street", "street_limited", "roundabout", "mini_roundabout"].compactMap { roadClass -> NSPredicate? in | |
return NSPredicate(format: "%K == %@", "class", roadClass) | |
} | |
let compoundPredicate = NSCompoundPredicate(orPredicateWithSubpredicates: roadPredicates) | |
let roadPredicates = ["motorway", "motorway_link", "trunk", "trunk_link", "primary", "primary_link", "secondary", "secondary_link", "tertiary", "tertiary_link", "street", "street_limited", "roundabout", "mini_roundabout"] | |
let compoundPredicate = NSPredicate(format: "class IN %@", roadPredicates) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll adopt these changes. Worth getting the best performance.
|
||
if ![DirectionsProfileIdentifier.walking, DirectionsProfileIdentifier.cycling].contains( router.routeProgress.routeOptions.profileIdentifier) { | ||
// filter out to road classes valid for motor transport | ||
let roadPredicates = ["motorway", "motorway_link", "trunk", "trunk_link", "primary", "primary_link", "secondary", "secondary_link", "tertiary", "tertiary_link", "street", "street_limited", "roundabout", "mini_roundabout"].compactMap { roadClass -> NSPredicate? in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m not sure about mini_roundabout
being necessary, since it’s tagged as a node in OpenStreetMap and would thus be a point feature in the Streets source. We’re only querying for polyline features.
Add a predicate filter for the road label MGLLineStyleLayer. Prevent the repeated recalculation of sliced current step line shape.
Fixes #2259.