44import android .location .Address ;
55import android .os .Build ;
66import android .util .Log ;
7+
78import org .json .JSONException ;
89import org .json .JSONObject ;
910import org .microg .nlp .api .GeocoderBackendService ;
2021
2122public class BackendService extends GeocoderBackendService {
2223 private static final String TAG = BackendService .class .getName ();
24+ private static final String SERVICE_URL_MAPQUEST = "http://open.mapquestapi.com/nominatim/v1/" ;
25+ private static final String SERVICE_URL_OSM = " http://nominatim.openstreetmap.org/" ;
2326 private static final String REVERSE_GEOCODE_URL =
24- "http://open.mapquestapi.com/nominatim/v1/reverse ?format=json&accept-language=%s&lat=%f&lon=%f" ;
27+ "%sreverse ?format=json&accept-language=%s&lat=%f&lon=%f" ;
2528 private static final String WIRE_LATITUDE = "lat" ;
2629 private static final String WIRE_LONGITUDE = "lon" ;
2730 private static final String WIRE_ADDRESS = "address" ;
@@ -38,8 +41,9 @@ public class BackendService extends GeocoderBackendService {
3841
3942 @ Override
4043 protected List <Address > getFromLocation (double latitude , double longitude , int maxResults ,
41- String locale ) {
42- String url = String .format (REVERSE_GEOCODE_URL , locale .split ("_" )[0 ], latitude , longitude );
44+ String locale ) {
45+ String url = String .format (Locale .US , REVERSE_GEOCODE_URL , SERVICE_URL_MAPQUEST ,
46+ locale .split ("_" )[0 ], latitude , longitude );
4347 try {
4448 HttpURLConnection connection = (HttpURLConnection ) new URL (url ).openConnection ();
4549 setUserAgentOnConnection (connection );
@@ -52,9 +56,7 @@ protected List<Address> getFromLocation(double latitude, double longitude, int m
5256 addresses .add (address );
5357 return addresses ;
5458 }
55- } catch (IOException e ) {
56- Log .w (TAG , e );
57- } catch (JSONException e ) {
59+ } catch (IOException | JSONException e ) {
5860 Log .w (TAG , e );
5961 }
6062 return null ;
@@ -102,8 +104,8 @@ private static Locale localeFromLocaleString(String localeString) {
102104
103105 @ Override
104106 protected List <Address > getFromLocationName (String locationName , int maxResults ,
105- double lowerLeftLatitude , double lowerLeftLongitude , double upperRightLatitude ,
106- double upperRightLongitude , String locale ) {
107+ double lowerLeftLatitude , double lowerLeftLongitude , double upperRightLatitude ,
108+ double upperRightLongitude , String locale ) {
107109 return null ;
108110 }
109111
0 commit comments