diff --git a/README.md b/README.md index 639bfef..82a3b20 100644 --- a/README.md +++ b/README.md @@ -23,9 +23,9 @@ Download `NetworkLocation.apk`, copy it to `/system/priv-app/NetworkLocation.apk Usage ----- -UnifiedNlp as it does not provide any location provider features, but acts as a middleware for multiple backends. +UnifiedNlp as it does not provide any features, but acts as a middleware for multiple backends. -Here is an open list of backends known to me: +Here is an open list of backends for geolocation known to me: - [AppleWifiNlpBackend](https://github.com/microg/AppleWifiNlpBackend) - backend that uses Apple's service to resolve wifi locations - [OpenWlanMapNlpBackend](https://github.com/microg/OpenWlanMapNlpBackend) - backend that uses OpenWlanMap.org to resolve user location. @@ -34,6 +34,10 @@ Here is an open list of backends known to me: - [PersonalWifiBackend](https://github.com/n76/wifi_backend) - Local location provider for WiFi APs using on-phone generated database. - (...) Create issue or pull request to extend this list :) +The following is an open list of backends for (reverse) geocoding: + +- [NominatimGeocoderBackend](https://github.com/microg/NominatimGeocoderService) + As part of a custom ROM ----------------------- UnifiedNlp can be build as part of Android when building an Android ROM from source. diff --git a/api/README.md b/api/README.md index a13aa86..2dc3628 100644 --- a/api/README.md +++ b/api/README.md @@ -4,7 +4,7 @@ This library contains anything needed to build a backend for UnifiedNlp. Writing the service ------------------- -### The easy way +### The easy way (Location) Writing a service is fairly easy. Just create a class that extends `org.microg.nlp.api.LocationBackendService`, it provides several methods: #### `update()`-method @@ -23,6 +23,10 @@ This is a good place to initialize or respectively destroy whatever you need dur #### `report(Location)`-method You can call this method every time to report the given location as soon as possible. +### The easy way (Geocoding) +Providing a Geocoder is even simpler than a LocationProvider. Extend `org.microg.nlp.api.GeocoderBackendService` and implement the methods `getFromLocation` and `getFromLocationName`. +Both methods reflect a call to the corresponding method in `android.location.Geocoder`. + ### The flexible way Instead of using the `LocationBackendService` helper class you can do it by hand. It's important that your service overrides the `onBind()` method and responds with a `Binder` to the `LocationBackend` interface. diff --git a/api/src/org/microg/nlp/api/GeocoderBackendService.java b/api/src/org/microg/nlp/api/GeocoderBackendService.java index 661885d..7273f4d 100644 --- a/api/src/org/microg/nlp/api/GeocoderBackendService.java +++ b/api/src/org/microg/nlp/api/GeocoderBackendService.java @@ -20,21 +20,17 @@ public abstract class GeocoderBackendService extends AbstractBackendService { * address should be localized in * @see android.location.Geocoder#getFromLocation(double, double, int) */ - protected List
getFromLocation(double latitude, double longitude, int maxResults, - String locale) { - return null; - } + protected abstract List
getFromLocation(double latitude, double longitude, + int maxResults, String locale); /** * @param locale The locale, formatted as a String with underscore (eg. en_US) the resulting * address should be localized in * @see android.location.Geocoder#getFromLocationName(String, int, double, double, double, double) */ - protected List
getFromLocationName(String locationName, int maxResults, + protected abstract List
getFromLocationName(String locationName, int maxResults, double lowerLeftLatitude, double lowerLeftLongitude, double upperRightLatitude, - double upperRightLongitude, String locale) { - return null; - } + double upperRightLongitude, String locale); private class Backend extends GeocoderBackend.Stub {