MapboxGeocoder.swift icon indicating copy to clipboard operation
MapboxGeocoder.swift copied to clipboard

adding convenience streetAddress property

Open Skoti opened this issue 5 years ago • 5 comments

Hi

I would like to add a convenience streetAddress property for MBPlacemark.

I have noticed that for .address features name property contains only a street name and the house number is contained in address property. The formattedName property already does it correctly (as it is defined as a street address for .address features), and also handles house number correctly putting it before or after a street name. So I have just extracted this logic into a separate method. For non-address features I use the logic from addressDictionary which looks for an address first in properties?.address and then address property.

Skoti avatar Feb 13 '20 12:02 Skoti

Thank you for your contributions. I added @1ec5 as a reviewer as I believe he has more context.

frederoni avatar Feb 21 '20 12:02 frederoni

Any chance to start a review?

Skoti avatar Apr 14 '20 05:04 Skoti

I'd love to see this get reviewed and merged. As it stands now, if I want to create an address with custom formatting, I have 2 options (neither are great):

  1. Parse MBPlacemark.qualifiedName
  2. Use the address and name properties for street address and dig into postalAddress to get city, state, zip info. It doesn't make sense to have to use bits of data from both objects to build an address.

This PR solves this problem in one way. Another option would be to add the address number to MBPlacemark.postalAddress.street. Then, an address could be pieced together using the postalAddress (CNPostalAddress) property alone.

JLZ avatar Aug 13 '20 16:08 JLZ

@1ec5 This look ok to me although we need new tests to cover this functionality

S2Ler avatar Jun 24 '21 15:06 S2Ler

I've rebased the PR and added, in existing tests, a simple check for street address. Let me know if you have more sample data to test against.

Skoti avatar Jul 10 '21 09:07 Skoti