-
Notifications
You must be signed in to change notification settings - Fork 318
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
Move to constants, make a public #1124
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import Foundation | ||
|
||
extension Dictionary where Key == Int, Value: MGLStyleValue<NSNumber> { | ||
/** | ||
Returns a copy of the stop dictionary with each value multiplied by the given factor. | ||
*/ | ||
public func multiplied(by factor: Double) -> Dictionary { | ||
var newCameraStop: [Int: MGLStyleValue<NSNumber>] = [:] | ||
for stop in MBRouteLineWidthByZoomLevel { | ||
let f = stop.value as! MGLConstantStyleValue | ||
let newValue = f.rawValue.doubleValue * factor | ||
newCameraStop[stop.key] = MGLStyleValue<NSNumber>(rawValue: NSNumber(value:newValue)) | ||
} | ||
return newCameraStop as! Dictionary<Key, Value> | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,30 @@ | ||
import Foundation | ||
import MapboxDirections | ||
|
||
typealias CongestionSegment = ([CLLocationCoordinate2D], CongestionLevel) | ||
|
||
/** | ||
Line width base values used at zoom levels. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
*/ | ||
public let MBRouteLineWidthByZoomLevel: [Int: MGLStyleValue<NSNumber>] = [ | ||
10: MGLStyleValue(rawValue: 8), | ||
13: MGLStyleValue(rawValue: 9), | ||
16: MGLStyleValue(rawValue: 11), | ||
19: MGLStyleValue(rawValue: 22), | ||
22: MGLStyleValue(rawValue: 28) | ||
] | ||
|
||
/** | ||
The minium distance remaining on a route before overhead zooming is stopped. | ||
*/ | ||
public var NavigationMapViewMinimumDistanceForOverheadZooming: CLLocationDistance = 200 | ||
|
||
/** | ||
Attribute name for the route line that is used for identifying whether a RouteLeg is the current active leg. | ||
*/ | ||
public let MBCurrentLegAttribute = "isCurrentLeg" | ||
|
||
/** | ||
Attribute name for the route line that is used for identifying different `CongestionLevel` along the route. | ||
*/ | ||
public let MBCongestionAttribute = "congestion" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import Foundation | ||
|
||
extension Dictionary where Key == Int, Value: MGLStyleValue<NSNumber> { | ||
/** | ||
Returns a proportional `Dictionary` of `lineWidthAtZoomLevels` at a specific factor. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As written, this method could just as well operate on circle size stops, not just line width stops:
|
||
*/ | ||
public func multiplied(by factor: Double) -> Dictionary { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This method will also go away as part of the migration to expressions in #1076. |
||
var newCameraStop: [Int: MGLStyleValue<NSNumber>] = [:] | ||
for stop in lineWidthAtZoomLevels { | ||
let f = stop.value as! MGLConstantStyleValue | ||
let newValue = f.rawValue.doubleValue * factor | ||
newCameraStop[stop.key] = MGLStyleValue<NSNumber>(rawValue: NSNumber(value:newValue)) | ||
} | ||
return newCameraStop as! Dictionary<Key, Value> | ||
} | ||
} | ||
|
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.
Because this line refers to
MBRouteLineWidthByZoomLevel
instead ofself
, this code:magically produces a dictionary equivalent to
MBRouteLineWidthByZoomLevel
, even thoughMBRouteLineWidthByZoomLevel
was never used explicitly.