-
Notifications
You must be signed in to change notification settings - Fork 88
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
Structured road names, codes, destinations #91
Merged
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d46b1da
Structured road names, codes, destinations
1ec5 4192690
Clarified comments about API versions
1ec5 09b6300
Clarified purpose of ref/destination capturing
1ec5 7c4491a
100% less destination munging
1ec5 1ff4054
Step name is required but may be empty
1ec5 ce32527
Merge branch 'master' into 1ec5-ref-67
1ec5 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -388,17 +388,17 @@ struct Road { | |
|
||
init(name: String?, ref: String?, destination: String?) { | ||
var codes: [String]? | ||
if let names = name, let ref = ref ?? destination { | ||
// Mapbox Directions API v5 encodes the ref separately from the name but redundantly includes the ref in the name for backwards compatibility. Remove the ref from the name. | ||
let parenthetical = "(\(ref))" | ||
if names == ref { | ||
if let names = name, let gloss = ref ?? destination { | ||
// Mapbox Directions API v5 encodes the ref separately from the name but redundantly includes the ref or destination in the name for backwards compatibility. Remove the ref or destination from the name. | ||
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. To clarify: This is not true, the |
||
let parenthetical = "(\(gloss))" | ||
if names == gloss { | ||
self.names = nil | ||
} else { | ||
self.names = names.stringByReplacingOccurrencesOfString(parenthetical, withString: "").tagValuesSeparatedByString(";") | ||
} | ||
codes = ref.tagValuesSeparatedByString(";") | ||
codes = gloss.tagValuesSeparatedByString(";") | ||
} else if let names = name, let codesRange = names.rangeOfString("\\(.+?\\)$", options: .RegularExpressionSearch, range: names.startIndex..<names.endIndex) { | ||
// Mapbox Directions API v4 encodes the ref inside a parenthetical. Remove the ref from the name. | ||
// Mapbox Directions API v4 encodes the ref or destination inside a parenthetical. Remove the ref or destination from the name. | ||
let parenthetical = names.substringWithRange(codesRange) | ||
if names == ref ?? destination { | ||
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. same as above, remove |
||
self.names = nil | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 don't understand the semantic meaning of
gloss
and the dictionary did not help me understand. The case that in Mapbox Directions v5destination
is mixed intoname
can not exist. Likewise it makes no sense to me thatcodes
would ever have the contents ofdestination
in them.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.
Turns out Directions API v5 used to conflate
destination
withref
in the parenthetical, but it no longer does so, much to my relief. I’ll gladly remove the fallbacks.