Skip to content
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

Add abbreviations #1169

Merged
merged 11 commits into from
Mar 13, 2018
Merged

Add abbreviations #1169

merged 11 commits into from
Mar 13, 2018

Conversation

bsudekum
Copy link
Contributor

@bsudekum bsudekum commented Feb 28, 2018

Relies on: mapbox/mapbox-directions-swift#244

This adds abbreviations from the server.

todo:

  • Figure out how to use the abbr_priority key. Right now, we're just abbreviating in order they are given depending on if the text can fit.
  • Add tests

/cc @mapbox/navigation-ios @danpaz

@@ -73,7 +73,7 @@ open class BaseInstructionsBannerView: UIControl {

func set(_ instruction: VisualInstruction?) {
let secondaryInstruction = instruction?.secondaryTextComponents
primaryLabel.numberOfLines = secondaryInstruction == nil ? 2 : 1
primaryLabel.numberOfLines = 1
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm sort of digging this change. This means we will abbreviate more, but will only use one line ever per primary/secondary instruction.

Copy link
Contributor

@frederoni frederoni Mar 1, 2018

Choose a reason for hiding this comment

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

It would simplify the layout and snapshot tests. Note that this method

func baselineAlignInstructions() {
_separatorView.isHidden = true
centerYConstraints.forEach { $0.isActive = false }
baselineConstraints.forEach { $0.isActive = true }
}

and accompanying arrays of constraints would be obsolete if we decide to make this change persistent.

if let text = component.text {
string.append(NSAttributedString(string: joinChar + text, attributes: attributesForLabel(label)))
if let text = joinCharPlusText {
string.append(NSAttributedString(string: (text).abbreviated(toFit: label.availableBounds(), font: label.font, possibleAbbreviation: joinCharPlusAbbreviation), attributes: attributesForLabel(label)))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was thinking about adding some sort of counter that tracks the current abbreviation priority level. We'd then pass it into this function and then it'd tell us if the priority level impacted whether a abbreviation was used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Another option is to first sort all the components, then try and fit them, then un-sort them.

Copy link

Choose a reason for hiding this comment

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

I was thinking you would need at most two nested loops, one to iterate over priority level i and one to iterate over components j. The inner loop would join strings together, using component[j].abbreviation if component[j].abbreviationPriority <= i, else using component[j].text. Does that make sense?

@bsudekum
Copy link
Contributor Author

Attempted to use priority level here: 1de9000

It's pretty unperformant, gist of what is happening:

  1. create an array of components index tuples. This allows us to keep track of the original order
  2. sort on priority level so we fit higher priority first. As I'm writing this, I realize that a lower number should be fitted last.
  3. Once things are fitted based on priority, we need to sort them according to their original order.

All in all, there are quite a few loops here. Open to ideas.

/// Returns the string abbreviated only as much as necessary to fit the given width and font.
func abbreviated(toFit bounds: CGRect, font: UIFont) -> String {
func abbreviated(toFit bounds: CGRect, font: UIFont, possibleAbbreviation: String?) -> String {
Copy link
Contributor

@frederoni frederoni Mar 1, 2018

Choose a reason for hiding this comment

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

It could be clearer and more decoupled if this method took a [VisualInstructionsComponent] with
abbreviations and priorities and we would leave the InstructionPresenter class intact.

@frederoni
Copy link
Contributor

@bsudekum I think there’s too much space left here to truncate it onto one line:

I'll switch back to two lines on the primary label.

@frederoni
Copy link
Contributor

Also added a snapshot test:

let totalWidth = attrComponents.map { $0.size() }.reduce(.zero, +).width
let stringFits = totalWidth <= availableBounds.width

if stringFits {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nit, a guard might be easier to read here.

@bsudekum
Copy link
Contributor Author

bsudekum commented Mar 8, 2018

Adding a test that abbreviates one but not all possible abbreviations would be another good test to add.

@bsudekum
Copy link
Contributor Author

bsudekum commented Mar 8, 2018

Getting a crash when running locally:
image

@bsudekum
Copy link
Contributor Author

bsudekum commented Mar 8, 2018

@frederoni do you think there is a way we could try and abbreviate first before using two lines?

In my opinion, a single line that readsW Fremont Avenue or West Fremont Ave is preferable to two lines here:

image

@willwhite
Copy link

@bsudekum would this type of abbreviation happen on the server or in the client?

/cc @mcwhittemore @danpaz

@bsudekum
Copy link
Contributor Author

bsudekum commented Mar 8, 2018

@willwhite on the client, given the abbreviations the server has given us. The switch statement that would occur:

if string.width < labelWithOneLine.width
  do nothing, it fits well
else if try harder with one abbreviation
  use one abbreviation
else if try harder with x more abbreviations
  use x abbreviations
else if we're out of abbreviations and we're still truncating
  use two lines

@bsudekum bsudekum added this to the v0.16.0 milestone Mar 8, 2018
@frederoni
Copy link
Contributor

frederoni commented Mar 9, 2018

do you think there is a way we could try and abbreviate first before using two lines?

@bsudekum that should be the case already. Added another snapshot test for iPhone X that renders like this with artificial abbreviations and priorities:

Could it be that there are no provided abbreviations in your response through West Fremont Avenue?

@frederoni
Copy link
Contributor

@bsudekum is this the route you took?


{
  "routes": [
    {
      "geometry": {
        "coordinates": [
          [
            -119.849759,
            36.835214
          ],
          [
            -119.850113,
            36.83497
          ],
          [
            -119.850654,
            36.834578
          ],
          [
            -119.851126,
            36.834434
          ],
          [
            -119.851572,
            36.83429
          ],
          [
            -119.852173,
            36.833987
          ],
          [
            -119.852439,
            36.833816
          ],
          [
            -119.8528,
            36.833713
          ],
          [
            -119.853375,
            36.833713
          ],
          [
            -119.853375,
            36.83317
          ],
          [
            -119.854671,
            36.8332
          ],
          [
            -119.854846,
            36.833181
          ],
          [
            -119.855009,
            36.833135
          ],
          [
            -119.855287,
            36.833012
          ],
          [
            -119.855355,
            36.832963
          ],
          [
            -119.855355,
            36.832915
          ],
          [
            -119.855316,
            36.832812
          ]
        ],
        "type": "LineString"
      },
      "legs": [
        {
          "summary": "West Fremont Avenue, West Palo Alto Avenue",
          "weight": 145.7,
          "duration": 99,
          "steps": [
            {
              "intersections": [
                {
                  "out": 0,
                  "entry": [
                    true
                  ],
                  "bearings": [
                    229
                  ],
                  "location": [
                    -119.849759,
                    36.835214
                  ]
                },
                {
                  "out": 1,
                  "in": 0,
                  "entry": [
                    false,
                    true,
                    true
                  ],
                  "bearings": [
                    45,
                    225,
                    315
                  ],
                  "location": [
                    -119.850113,
                    36.83497
                  ]
                },
                {
                  "out": 2,
                  "in": 0,
                  "entry": [
                    false,
                    true,
                    true
                  ],
                  "bearings": [
                    45,
                    150,
                    255
                  ],
                  "location": [
                    -119.850654,
                    36.834578
                  ]
                },
                {
                  "out": 1,
                  "in": 0,
                  "entry": [
                    false,
                    true,
                    true
                  ],
                  "bearings": [
                    75,
                    255,
                    345
                  ],
                  "location": [
                    -119.851126,
                    36.834434
                  ]
                },
                {
                  "out": 1,
                  "in": 0,
                  "entry": [
                    false,
                    true,
                    true
                  ],
                  "bearings": [
                    60,
                    225,
                    330
                  ],
                  "location": [
                    -119.852173,
                    36.833987
                  ]
                }
              ],
              "driving_side": "right",
              "geometry": {
                "coordinates": [
                  [
                    -119.849759,
                    36.835214
                  ],
                  [
                    -119.850113,
                    36.83497
                  ],
                  [
                    -119.850654,
                    36.834578
                  ],
                  [
                    -119.851126,
                    36.834434
                  ],
                  [
                    -119.851572,
                    36.83429
                  ],
                  [
                    -119.852173,
                    36.833987
                  ],
                  [
                    -119.852439,
                    36.833816
                  ],
                  [
                    -119.8528,
                    36.833713
                  ],
                  [
                    -119.853375,
                    36.833713
                  ]
                ],
                "type": "LineString"
              },
              "mode": "driving",
              "maneuver": {
                "bearing_after": 229,
                "bearing_before": 0,
                "location": [
                  -119.849759,
                  36.835214
                ],
                "modifier": "right",
                "type": "depart",
                "instruction": "Head southwest on West Fremont Avenue"
              },
              "weight": 87.2,
              "duration": 54.2,
              "name": "West Fremont Avenue",
              "distance": 373.2,
              "bannerInstructions": [
                {
                  "distanceAlongGeometry": 373.2,
                  "primary": {
                    "type": "turn",
                    "modifier": "left",
                    "components": [
                      {
                        "text": "North",
                        "type": "text",
                        "abbr": "N",
                        "abbr_priority": 1
                      },
                      {
                        "text": "Valentine Avenue",
                        "type": "text",
                        "abbr": "Valentine Ave",
                        "abbr_priority": 0
                      }
                    ],
                    "text": "North Valentine Avenue"
                  },
                  "secondary": null
                }
              ]
            },
            {
              "intersections": [
                {
                  "out": 2,
                  "in": 1,
                  "entry": [
                    true,
                    false,
                    true
                  ],
                  "bearings": [
                    0,
                    90,
                    180
                  ],
                  "location": [
                    -119.853375,
                    36.833713
                  ]
                }
              ],
              "driving_side": "right",
              "geometry": {
                "coordinates": [
                  [
                    -119.853375,
                    36.833713
                  ],
                  [
                    -119.853375,
                    36.83317
                  ]
                ],
                "type": "LineString"
              },
              "mode": "driving",
              "maneuver": {
                "bearing_after": 180,
                "bearing_before": 268,
                "location": [
                  -119.853375,
                  36.833713
                ],
                "modifier": "left",
                "type": "end of road",
                "instruction": "Turn left onto North Valentine Avenue"
              },
              "weight": 22.3,
              "duration": 8.6,
              "name": "North Valentine Avenue",
              "distance": 60.4,
              "bannerInstructions": [
                {
                  "distanceAlongGeometry": 60.4,
                  "primary": {
                    "type": "turn",
                    "modifier": "right",
                    "components": [
                      {
                        "text": "West",
                        "type": "text",
                        "abbr": "W",
                        "abbr_priority": 1
                      },
                      {
                        "text": "Palo Alto Avenue",
                        "type": "text",
                        "abbr": "Palo Alto Ave",
                        "abbr_priority": 0
                      }
                    ],
                    "text": "West Palo Alto Avenue"
                  },
                  "secondary": null
                }
              ]
            },
            {
              "intersections": [
                {
                  "out": 2,
                  "in": 0,
                  "entry": [
                    false,
                    true,
                    true
                  ],
                  "bearings": [
                    0,
                    180,
                    270
                  ],
                  "location": [
                    -119.853375,
                    36.83317
                  ]
                },
                {
                  "out": 1,
                  "in": 0,
                  "entry": [
                    false,
                    true
                  ],
                  "bearings": [
                    45,
                    180
                  ],
                  "location": [
                    -119.855355,
                    36.832963
                  ]
                }
              ],
              "driving_side": "right",
              "geometry": {
                "coordinates": [
                  [
                    -119.853375,
                    36.83317
                  ],
                  [
                    -119.854671,
                    36.8332
                  ],
                  [
                    -119.854846,
                    36.833181
                  ],
                  [
                    -119.855009,
                    36.833135
                  ],
                  [
                    -119.855287,
                    36.833012
                  ],
                  [
                    -119.855355,
                    36.832963
                  ],
                  [
                    -119.855355,
                    36.832915
                  ],
                  [
                    -119.855316,
                    36.832812
                  ]
                ],
                "type": "LineString"
              },
              "mode": "driving",
              "maneuver": {
                "bearing_after": 271,
                "bearing_before": 180,
                "location": [
                  -119.853375,
                  36.83317
                ],
                "modifier": "right",
                "type": "turn",
                "instruction": "Turn right onto West Palo Alto Avenue"
              },
              "weight": 36.2,
              "duration": 36.2,
              "name": "West Palo Alto Avenue",
              "distance": 200.3,
              "bannerInstructions": [
                {
                  "distanceAlongGeometry": 200.3,
                  "primary": {
                    "type": "arrive",
                    "modifier": "straight",
                    "components": [
                      {
                        "text": "You will arrive",
                        "type": "text"
                      }
                    ],
                    "text": "You will arrive"
                  },
                  "secondary": {
                    "type": "arrive",
                    "modifier": "straight",
                    "components": [
                      {
                        "text": "North Rafael Avenue",
                        "type": "text",
                        "abbr": "N Rafael Ave",
                        "abbr_priority": 0
                      }
                    ],
                    "text": "North Rafael Avenue"
                  }
                },
                {
                  "distanceAlongGeometry": 15,
                  "primary": {
                    "type": "arrive",
                    "modifier": "straight",
                    "components": [
                      {
                        "text": "You have arrived",
                        "type": "text"
                      }
                    ],
                    "text": "You have arrived"
                  },
                  "secondary": {
                    "type": "arrive",
                    "modifier": "straight",
                    "components": [
                      {
                        "text": "North Rafael Avenue",
                        "type": "text",
                        "abbr": "N Rafael Ave",
                        "abbr_priority": 0
                      }
                    ],
                    "text": "North Rafael Avenue"
                  }
                }
              ]
            },
            {
              "intersections": [
                {
                  "in": 0,
                  "entry": [
                    true
                  ],
                  "bearings": [
                    343
                  ],
                  "location": [
                    -119.855316,
                    36.832812
                  ]
                }
              ],
              "driving_side": "right",
              "geometry": {
                "coordinates": [
                  [
                    -119.855316,
                    36.832812
                  ],
                  [
                    -119.855316,
                    36.832812
                  ]
                ],
                "type": "LineString"
              },
              "mode": "driving",
              "maneuver": {
                "bearing_after": 0,
                "bearing_before": 163,
                "location": [
                  -119.855316,
                  36.832812
                ],
                "type": "arrive",
                "instruction": "You have arrived at your destination"
              },
              "weight": 0,
              "duration": 0,
              "name": "North Rafael Avenue",
              "distance": 0,
              "bannerInstructions": []
            }
          ],
          "distance": 633.9
        }
      ],
      "weight_name": "routability",
      "weight": 145.7,
      "duration": 99,
      "distance": 633.9
    }
  ],
  "waypoints": [
    {
      "name": "West Fremont Avenue",
      "location": [
        -119.849759,
        36.835214
      ]
    },
    {
      "name": "North Rafael Avenue",
      "location": [
        -119.855316,
        36.832812
      ]
    }
  ],
  "code": "Ok",
  "uuid": "cjejbgwc300np7hk1golllmra"
}

Doesn't seem to be any abbreviations for "West Fremont Avenue". 🤔

guard component.component.type == .text else { continue }
guard let abbreviation = component.component.abbreviation else { continue }

attributedComponents[component.index] = NSAttributedString(string: joinChar + abbreviation, attributes: attributesForLabel(label))
Copy link
Contributor

@vincethecoder vincethecoder Mar 9, 2018

Choose a reason for hiding this comment

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

NSAttributedString(string: "\(joinChar)\(abbreviation)", attributes: attributesForLabel(label))

} else {
// Display road code while shield is downloaded
if let text = component.text {
string.append(NSAttributedString(string: joinChar + text, attributes: attributesForLabel(label)))
strings.append(NSAttributedString(string: joinChar + text, attributes: attributesForLabel(label)))
Copy link
Contributor

Choose a reason for hiding this comment

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

strings.append(NSAttributedString(string: "\(joinChar)\(text)", attributes: attributesForLabel(label)))

Copy link
Contributor

@vincethecoder vincethecoder Mar 9, 2018

Choose a reason for hiding this comment

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

Reason: As we continuously concatenate the strings in a for-loop, we creating multiple strings to get to the final string. I see we also map the results as well. Just an observation as I reviewed the scope of the function attributedComponents() and its callee(s).

Copy link
Contributor

@frederoni frederoni Mar 9, 2018

Choose a reason for hiding this comment

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

I fail to see the distinction. It's just another syntax for concatenating using the string concat operator(+) or string interpolation but the reason indicates that it's more than just the code style?

We do one full iteration first to stringify all components including shields.
"[I-280] West Fremont Avenue"
then one more iteration until the instruction fits on the screen
"[I-280] W Fremont Avenue"
if West had the highest priority.

Copy link
Contributor

Choose a reason for hiding this comment

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

@frederoni difference is negligible with simple code. However, as we iterate, a larger data set it may affect performance. Interpolation does make good use of memory as stated in the abstract. Apple offers this as a given, so why not use it 😄 -- just like how we prefer to use functional programming 🤷‍♂️

cc @bsudekum

Copy link
Contributor

@frederoni frederoni Mar 9, 2018

Choose a reason for hiding this comment

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

A quick performance test indicated that using the + operator for concatenating strings is 19 × faster than concatenating using string interpolation so I'm going to leave this intact.

Copy link
Contributor

Choose a reason for hiding this comment

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

@frederoni I believe this was more about good use of memory. However, I see how my last mention of performance could have stirred us towards performance measurement.

@@ -48,11 +80,11 @@ class InstructionPresenter {
if component.type == .delimiter && instructionHasDownloadedAllShields() {
continue
}
string.append(NSAttributedString(string: (joinChar + text).abbreviated(toFit: label.availableBounds(), font: label.font), attributes: attributesForLabel(label)))
strings.append(NSAttributedString(string: (joinChar + text), attributes: attributesForLabel(label)))
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto ☝️ comment on line 68

@@ -103,3 +135,17 @@ class ShieldAttachment: NSTextAttachment {
return CGRect(x: 0, y: font.descender - image.size.height / 2 + mid + 2, width: image.size.width, height: image.size.height).integral
}
}

extension CGSize {
fileprivate static var greatestFiniteSize = CGSize(width: CGFloat.greatestFiniteMagnitude, height: CGFloat.greatestFiniteMagnitude)
Copy link
Contributor

Choose a reason for hiding this comment

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

@bsudekum should we consider an MB (or whatever) prefix to specific vars we add to extensions. This can prevent any future variable conflicts or overrides with Apple iOS specific classes, structs, enum etc. It would also help developers identify MB specific should we exposed certain variables in the future.

Copy link
Contributor

@frederoni frederoni Mar 9, 2018

Choose a reason for hiding this comment

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

Not necessary for private or fileprivate where we don't expose anything to ObjC or even outside this file to prevent conflicts and polluted namespaces.

@@ -79,8 +79,7 @@ open class BaseInstructionsBannerView: UIControl {
override open func prepareForInterfaceBuilder() {
super.prepareForInterfaceBuilder()
maneuverView.isStart = true

primaryLabel.instruction = [VisualInstructionComponent(type: .destination, text: "Primary text label", imageURL: nil, maneuverType: .none, maneuverDirection: .none)]
primaryLabel.instruction = [VisualInstructionComponent(type: .text, text: "Primary text label", imageURL: nil, maneuverType: .none, maneuverDirection: .none, abbreviation: nil, abbreviationPriority: NSNotFound)]
Copy link
Contributor

Choose a reason for hiding this comment

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

This is another observation as well. Should we consider wrapping our strings in NSLocalizedString to aid future translation work?

Copy link
Contributor

Choose a reason for hiding this comment

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

Abbreviations will be localized server-side starting from this PR.

@@ -53,7 +53,7 @@ open class NextBannerView: UIView {
override open func prepareForInterfaceBuilder() {
super.prepareForInterfaceBuilder()
maneuverView.isEnd = true
instructionLabel.instruction = [VisualInstructionComponent(type: .destination, text: "Next step", imageURL: nil, maneuverType: .none, maneuverDirection: .none)]
instructionLabel.instruction = [VisualInstructionComponent(type: .text, text: "Next step", imageURL: nil, maneuverType: .none, maneuverDirection: .none, abbreviation: nil, abbreviationPriority: NSNotFound)]
Copy link
Contributor

@vincethecoder vincethecoder Mar 9, 2018

Choose a reason for hiding this comment

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

NSLocalizedString on Next step?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a placeholder.

Copy link
Contributor

Choose a reason for hiding this comment

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

This placeholder is never shown on the UI, I reckon.

(@frederoni mentioned that localization will be done at server-side... so cool 👍)

Copy link
Contributor

@vincethecoder vincethecoder left a comment

Choose a reason for hiding this comment

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

Aside minor suggested changes, LGTM 👍

@bsudekum
Copy link
Contributor Author

bsudekum commented Mar 9, 2018

@frederoni that looks about right to me. Unsure why, but most times I run this branch it crashes at the same spot each time.

I investigated it for a second on one crash, component.index was 4 and attrComponent was also 4 (out of bounds).

Copy link
Contributor

@vincethecoder vincethecoder left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@frederoni
Copy link
Contributor

frederoni commented Mar 12, 2018

@akitchen would you mind 👀 the changes in a0dfee1?
I changed it to hide a delimiter if an adjacent component is a shield image compared to hiding all delimiters after all shields are downloaded.

Before this change:
"[I280] / 10 / 15 / 20 West"
became
"[I280(shield)] 10 15 20 West"

After this change:
"[I280] / 10 / 15 / 20 West"
becomes
"[I280(shield)] 10 / 15 / 20 West"

@@ -101,12 +101,12 @@ class InstructionsBannerViewIntegrationTests: XCTestCase {
let view = instructionsView()
view.set(makeVisualInstruction(primaryInstruction: instructions, secondaryInstruction: nil))

//Slash should be present until an adjacent shield is downloaded
Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, with two shields next to each other, one exit and one destination shield, we should probably show the delimiter? However, exit types are yet to be added to MapboxDirections, IIRC? /cc @bsudekum

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah the case you mentioned in this comment makes sense to me.

@akitchen
Copy link
Contributor

akitchen commented Mar 12, 2018

@akitchen would you mind 👀 the changes in a0dfee1?
I changed it to hide a delimiter if an adjacent component is a shield image compared to hiding all delimiters when all shields were downloaded.

It seems fine to me, but ultimately this should be a design decision. Is there a separate ticket which calls for this change?

@frederoni
Copy link
Contributor

@1ec5 any thoughts about #1169 (comment)?

@bsudekum bsudekum modified the milestone: v0.16.x Mar 12, 2018
@bsudekum
Copy link
Contributor Author

@frederoni Visually, I think this change looks good.

guard component.component.type == .text else { continue }
guard let abbreviation = component.component.abbreviation else { continue }

attributedPairs.attributedStrings[component.index] = NSAttributedString(string: joinChar + abbreviation, attributes: attributesForLabel(label))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would it make sense to check we're within bounds here? I'm just slightly weary of bracket lookups like this and how fragile they are.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree about the fragility, but this could cover up an unwanted bug where we could abbreviate
"West Fremont Avenue" as "West W Ave" or crash due to out of bounds.

So instead, I added an assertion to make sure we would catch such a bug early in a8d8faf

@frederoni
Copy link
Contributor

It seems fine to me, but ultimately this should be a design decision. Is there a separate ticket which calls for this change?

@akitchen Hiding all delimiters when all shields are downloaded exacerbates the unwanted effect captured in #1190

@akitchen
Copy link
Contributor

@akitchen Hiding all delimiters when all shields are downloaded exacerbates the unwanted effect captured in #1190

I do agree, this change is an improvement.

👍

@bsudekum bsudekum merged commit 69a3402 into master Mar 13, 2018
@bsudekum bsudekum deleted the abbreviations branch March 13, 2018 17:13
@1ec5 1ec5 mentioned this pull request Apr 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants