Geocoder

open class Geocoder

Class to ease geocoding tasks. Primarily designed to retrieve current location, e.g. to obtain a ZIP code.

If you use the geocoder you must include a short description of why you’re accessing the user’s location under the key NSLocationWhenInUseUsageDescription in the app’s Info.plist. Otherwise you will never receive the location callback. The user will see this string in an alert window the first time the geocoder is used.

You probably want to use one of these methods for geocoding:

  • currentAddress(): Returning the current Address
  • hipaaCompliantCurrentAddress(): Returning the current Address to HIPAA specs
  • geocodeCurrentLocation(): A CLPlacemark of the current location
  • currentLocation(): A CLLocation of the current location

For conversions from one thing to another:

  • hipaaCompliantAddress(): Make the given Address HIPAA-compliant
  • address(from:): Convert CLPlacemark to Address
  • reverseGeocode(location:): Retrieve a CLPlacemark from CLLocation
  • Designated initializer.

    Declaration

    Swift

    public init()
  • A bool indicating whether the receiver is currently geocoding

    Declaration

    Swift

    open var isGeocoding: Bool
  • Determines the current location and, on success, presents a CLLocation instance in the callback.

    Declaration

    Swift

    open func currentLocation(callback inCallback: @escaping GeocoderLocationCallback)

    Parameters

    callback

    The callback to call after geocoding, supplies either a CLLocation instance, an error or neither (on abort)

  • Determines and reverse-geocodes the phone’s current location. Calls currentLocation(), then geocodes that location.

    Declaration

    Swift

    open func geocodeCurrentLocation(callback: @escaping GeocoderPlacemarkCallback)

    Parameters

    callback

    The callback to call when done, supplies either a CLPlacemark or an error or neither (on abort)

  • Reverse geocodes the given location.

    Declaration

    Swift

    open func reverseGeocode(location: CLLocation, callback: @escaping GeocoderPlacemarkCallback)

    Parameters

    location

    The location to look up

    callback

    The callback to call when done, supplies either a CLPlacemark or an error or neither (on abort)

  • In the callback returns a FHIR Address instance of the current location, populated with country and state if possible. Calls geocodeCurrentLocation() to determine the current location, then reverse-geocodes that location/placemark.

    Declaration

    Swift

    open func currentAddress(callback: @escaping GeocoderAddressCallback)

    Parameters

    callback

    The callback to call after geocoding, supplies either an Address element, an error or neither (on abort)

  • Populate an Address element representing the given placemark, including country (ISO representation preferred), state and ZIP.

    Declaration

    Swift

    open func addressFrom(placemark: CLPlacemark) -> Address

    Return Value

    A populated FHIR “Address” element

  • In the callback returns a FHIR Address instance of the current location, populated according to HIPAA Safe Harbor guidelines. Calls geocodeCurrentLocation() to determine the current location, then reverse-geocodes and de-identifies that location/placemark.

    Declaration

    Swift

    open func hipaaCompliantCurrentAddress(callback: @escaping GeocoderAddressCallback)

    Parameters

    callback

    The callback to call after geocoding, supplies either an Address element, an error or neither (on abort)

  • In the callback returns a FHIR Address instance of the given location, populated according to HIPAA Safe Harbor guidelines.

    Declaration

    Swift

    open func hipaaCompliantAddress(from location: CLLocation, callback: @escaping GeocoderAddressCallback)

    Parameters

    callback

    The callback to call after geocoding, supplies either an Address element, an error or neither (on abort)

  • Populate an Address element representing the given placemark according to HIPAA’s Safe Harbor guidelines. This means Address will contain the ISO country code, the first three digits of the ZIP if the country code is US (with exceptions, as defined in restrictedThreeDigitZIPs()) and the state.

    Declaration

    Swift

    open func hipaaCompliantAddress(_ address: Address) -> Address

    Return Value

    A sparsely populated FHIR “Address” element

  • Returns an array of 3-digit US ZIP codes that can not be used in a HIPAA compliant fashion for reporting de-identified data. See: http://www.hhs.gov/ocr/privacy/hipaa/understanding/coveredentities/De-identification/guidance.html#zip

    Declaration

    Swift

    open class func restrictedThreeDigitZIPs() -> [String]