Repository navigation
Add GeocodingProvider for forward and reverse geocoding - #26
Open
gurmeherchawla wants to merge 3 commits into
Open
gurmeherchawla wants to merge 3 commits into
gurmeherchawla wants to merge 3 commits into
Conversation
Adds GeocodingProvider with reverseGeocode(latitude:longitude:) and geocode(address:maxResults:), returning [GeocodedPlace]. - Darwin: MKReverseGeocodingRequest/MKGeocodingRequest on OS 26+, falling back to CLGeocoder on earlier versions. - Android: Geocoder's listener API on API 33+, and the blocking API on Dispatchers.IO below that. isAvailable reflects Geocoder.isPresent(). - Empty results return [] rather than throwing; lookup failures throw GeocodingError. MapKit's OS 26 types do not expose subLocality, administrativeArea or postalCode separately, so those fields are nil on that path.
Covers blank-field normalisation, joining address parts, blank queries, and mapping an android.location.Address into GeocodedPlace. A live lookup test runs only when SKIP_DEVICE_LIVE_GEOCODING is set, so CI does not depend on the network or geocoder rate limits.
Adds a Geocoding section with usage examples, a GeocodedPlace property table showing per-platform field coverage, and the INTERNET permission requirement, plus entries in the permissions summary and API reference.
Author
|
Kindly review @marcprux |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Adds
GeocodingProvider, which converts between coordinates and places:reverseGeocode(latitude:longitude:) async throws -> [GeocodedPlace]geocode(address:maxResults:) async throws -> [GeocodedPlace]isAvailable(alwaystrueon Darwin;Geocoder.isPresent()on Android)No matches return
[]. Failed lookups throwGeocodingError.Platform implementation
MKReverseGeocodingRequest/MKGeocodingRequestCLGeocoderGeocoderlistener API (onGeocodeandonErrorboth handled, so a failed lookup can't hang)GeocoderAPI onDispatchers.IOOpen question: field coverage on iOS 26+
MapKit's OS 26 types (
MKAddress,MKAddressRepresentations) don't exposesubLocality,administrativeArea, orpostalCodeas separate fields, sothose are
nilon that path.CLGeocoderand Android'sGeocoderprovide allof them. The README has a per-platform table. If you'd rather keep
CLGeocoderas the only Darwin path until MapKit covers these fields, I'm happy to change it.
Testing
swift test: passes on macOS and on Robolectric (13 passed, 2 skipped).skip android build(bridged / Skip Fuse): builds.xcodebuildbuilds for iOS and watchOS.SKIP_DEVICE_LIVE_GEOCODING=1) passes on macOS 27 (MapKit path).CLGeocoderfallback (iOS < 26) and a real Android geocoder.Note: tvOS doesn't build on
maineither (AccelerometerProviderimports CoreMotion), so that failure isn't from this change.