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

Revamp API to be more idiomatic in Swift #41

Merged
merged 13 commits into from
May 22, 2016
Merged

Revamp API to be more idiomatic in Swift #41

merged 13 commits into from
May 22, 2016

Commits on May 20, 2016

  1. Revamped API to be more idiomatic in Swift

    Rewrote the library to more closely parallel mapbox/MapboxStatic.swift#19. Removed the class prefix from Swift but kept it for Objective-C. The goal is no longer to be a (poor) drop-in replacement for MapKit’s MKDirections API but rather to be as idiomatic as possible in Swift and Objective-C, with a priority on Swift. Symbols conform to platform naming conventions but in some cases eschew MapKit terminology in favor of Geocoding API terminology, so that api-documentation makes sense in the context of this library.
    
    Removed the dependency on RequestKit. This library chooses reasonable default networking behavior; if you need anything more sophisticated, you can access the URL request information to use with a custom NSURLSession. Geocoder no longer needs to be strongly held in order for the request to finish. Instead, the request is made against the shared URL session; to use a custom URL session, make the request yourself using the URL returned by the URLForGeocoding(options:) property. Removed the cancelGeocode() method; instead, directly cancel the NSURLSessionDataTask returned by geocode(options:completionHandler:).
    
    Added a shared (singleton) Geocoder object. Use the shared object if you’ve set your Mapbox access token in the MGLMapboxAccessToken key of your application’s Info.plist file. Otherwise, create a Geocoder object with the access token explicitly. A single geocoder object can handle multiple requests concurrently (since it just passes the requests off to the shared URL session).
    
    Unified geocodeAddressString(_:completionHandler:) and reverseGeocodeLocation(_:completionHandler:) into a single geocode(options:completionHandler:) method that takes a GeocodeOptions object. There are two subclasses of GeocodeOptions, ForwardGeocodeOptions and ReverseGeocodeOptions, that support all the options exposed by the Geocoding API. Effectively, this change adds support for the Geocoding API’s autocomplete and bbox options. Added an attribution parameter to the completion handler that contains required legal notices. The access_token parameter is now the last URL parameter instead of the first.
    
    Replaced the Placemark.Scope enum with the PlacemarkScope bitmask, which is implemented in Objective-C so that Objective-C code can use it too. Using a bitmask prevents client code from specifying a scope multiple times. Renamed AdministrativeArea to Region, reflecting the Geocoding API result type.
    
    For Placemark objects representing addresses and points of interest, the name property is no longer fully qualified; that is, it no longer contains the full administrative hierarchy. For the fully-qualified name, use the qualifiedName property. Properties such as country and postalCode return Placemark objects instead of strings; to get the name of e.g. the surrounding country, use the returned placemark object’s name property. A new qualifiers property returns the entire placemark hierarchy in indexer order, in case there’s any overlap between containing placemarks. Renamed ISOcountryCode to code; this property may be included in subnational placemarks, such as placemarks representing regions. Replaced the administrativeArea and subAdministrativeArea properties with administrativeRegion and district, respectively. Unlike the old subAdministrativeRegion property, district may be nil if it isn’t applicable. Renamed locality to place, and subLocality to neighborhood. Added a wikidataEntityIdentifier property corresponding to the Geocoding API’s wikidata property.
    
    Removed the CLLocationCoordinate2D equality operator to avoid conflicts with client code that may define the same.
    
    Upgraded Podfile to CocoaPods 1.0 format. Enabled code coverage gathering. Updated text fixtures and expectations.
    
    Fixes #39, fixes #40.
    1ec5 committed May 20, 2016
    Configuration menu
    Copy the full SHA
    bc1ba74 View commit details
    Browse the repository at this point in the history

Commits on May 21, 2016

  1. Cleaned up class prefixes

    Added class prefix to Placemark in Objective-C. Removed class prefix from MBRectangularRegion in Swift.
    
    Renamed autocompletionEnabled to autocompletesQuery and moved it to ForwardGeocodeOptions, since it doesn’t make sense in ReverseGeocodeOptions.
    1ec5 committed May 21, 2016
    Configuration menu
    Copy the full SHA
    877e3cd View commit details
    Browse the repository at this point in the history
  2. Replaced focalCoordinate with focalLocation

    It’s less awkward to work with an optional (nullable) object than a struct that has a magic value.
    1ec5 committed May 21, 2016
    Configuration menu
    Copy the full SHA
    8a37eae View commit details
    Browse the repository at this point in the history
  3. Renamed wikidataEntityIdentifier to wikidataItemIdentifier

    Wikidata tends to call them “items” these days.
    1ec5 committed May 21, 2016
    Configuration menu
    Copy the full SHA
    f75f70d View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    487ef96 View commit details
    Browse the repository at this point in the history
  5. Added postalAddress

    Took formattedAddressLines private like it used to be. Added postalAddress to return a CNPostalAddress on iOS 9.0 and above. A CNPostalAddress from the Contacts framework is easier to work with than a full Address Book framework–style addressDictionary.
    1ec5 committed May 21, 2016
    Configuration menu
    Copy the full SHA
    fa169d4 View commit details
    Browse the repository at this point in the history
  6. Added RectangularRegion.contains(coordinate:)

    CLRegion.containsCoordinate(_:) is marked unavailable, the return type is marked implicitly unwrapped as a workaround.
    1ec5 committed May 21, 2016
    Configuration menu
    Copy the full SHA
    1bf9e2c View commit details
    Browse the repository at this point in the history
  7. Documented the rest of the API

    1ec5 committed May 21, 2016
    Configuration menu
    Copy the full SHA
    a1c3892 View commit details
    Browse the repository at this point in the history
  8. Took the shared geocoder public

    1ec5 committed May 21, 2016
    Configuration menu
    Copy the full SHA
    13f3e10 View commit details
    Browse the repository at this point in the history

Commits on May 22, 2016

  1. Updated readme

    Added examples in both Swift and Objective-C to the readme and updated the pod description to deemphasize the API’s similarity to CLGeocoder.
    1ec5 committed May 22, 2016
    Configuration menu
    Copy the full SHA
    a13caa5 View commit details
    Browse the repository at this point in the history
  2. Provide more details about API errors

    Include a failure reason from the response body in a failed request’s error. Include a hint when the error is due to rate-limiting. Split raw request and response logic into a separate method.
    
    Fixes #26.
    1ec5 committed May 22, 2016
    Configuration menu
    Copy the full SHA
    ea922a7 View commit details
    Browse the repository at this point in the history
  3. Factored out batch geocoding

    Batch geocoding uses a separate method on Geocoder and separate ForwardBatchGeocodeOptions and ReverseBatchGeocodeOptions objects. The batch geocoding completion handler accepts more deeply nested data.
    1ec5 committed May 22, 2016
    Configuration menu
    Copy the full SHA
    65c5d6e View commit details
    Browse the repository at this point in the history
  4. Documented batch geocoding

    Also point to the Mapbox Geocoding website.
    1ec5 committed May 22, 2016
    Configuration menu
    Copy the full SHA
    405e790 View commit details
    Browse the repository at this point in the history