AtlisInc / Nominatim-API

Java library for reverse geocoding for Nominatim
http://nominatim.openstreetmap.org
GNU Lesser General Public License v3.0
14 stars 3 forks source link

MapPoint is null for some reason #10

Open reachomk opened 4 years ago

reachomk commented 4 years ago

Here is my method:

private void showContacts() {
    String endpointUrl = "https://nominatim.openstreetmap.org/";
    for(Contact c: contactList) {
        Address address = c.getAddress();
        if(address != null) {
            MapPoint mapPoint = NominatimAPI.with(endpointUrl).getMapPointFromAddress(address, 5);
            Log.e(c.getName(), mapPoint.getLatitude() + ", " + mapPoint.getLongitude());
        }
        else Log.e("Error", "address null");
    }
}

Error:

java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Double com.atlis.location.model.impl.MapPoint.getLatitude()' on a null object reference at com.reachomk.contacthome.MapsActivity.showContacts(MapsActivity.java:234) at com.reachomk.contacthome.MapsActivity.getContacts(MapsActivity.java:225) at com.reachomk.contacthome.MapsActivity.onMapReady(MapsActivity.java:95) at com.google.android.gms.maps.zzak.zza(Unknown Source:2) at com.google.android.gms.maps.internal.zzaq.dispatchTransaction(Unknown Source:12) at com.google.android.gms.internal.maps.zzb.onTransact(Unknown Source:12) at android.os.Binder.transact(Binder.java:667) at dc.b(:com.google.android.gms.dynamite_mapsdynamite@202117068@20.21.17 (100700-0):2) at com.google.maps.api.android.lib6.impl.be.run(:com.google.android.gms.dynamite_mapsdynamite@202117068@20.21.17 (100700-0):2) at android.os.Handler.handleCallback(Handler.java:873) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:6669) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

eckad158 commented 4 years ago

I do have the same problem. The MapPoint is always null, the log4j output always gives me the following Message: NominatimAPI:160 - geocoding response wasn't good enoungh null

I used it with the following (randomly chosen) input adress:

Address newOne = new Address(); newOne.setCountryCode("de"); newOne.setPostcode("28195"); newOne.setCity("Bremen"); newOne.setStreet("Teerhof"); newOne.setHousenumber("59");

Could it be that the API is somehow broken ?