// Path: app/src/main/java/com/gisgraphy/domain/valueobject/StreetSearchResultsDto.java
// public class StreetSearchResultsDto {
// 
//     /**
//      * {"numFound":50,"QTime":252,"result":[{"name":"Newton Street","distance":36.3294330748716,"gid":106603218,"openstreetmapId":16978709,"streetType":"RESIDENTIAL","oneWay":false,"countryCode":"US","length":601.901637459321,"lat":39.83543539626998,"lng":-105.03742540092145,"isIn":"Westminster"},
//      */
// 
//     public int numFound;
//     public Street[] result;
// 
// 
//     public Street[] getResult() {
//         return result;
//     }
// }
// 
// Path: app/src/main/java/com/gisgraphy/gishraphoid/JTSHelper.java
// public static boolean checkLatitude(double latitude) {
//     if (latitude < -90 || latitude > 90) {
//         throw new IllegalArgumentException("latitude is out of bound");
//     }
//     return true;
// }
// 
// Path: app/src/main/java/com/gisgraphy/gishraphoid/JTSHelper.java
// public static boolean checkLongitude(double longitude) {
//     if (longitude < -180 || longitude > 180) {
//         throw new IllegalArgumentException("longitude is out of bound");
//     }
//     return true;
// }


import android.content.Context;
import android.location.Address;
import android.location.Geocoder;
import android.util.Log;
import com.gisgraphy.domain.valueobject.StreetSearchResultsDto;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import static com.gisgraphy.gishraphoid.JTSHelper.checkLatitude;
import static com.gisgraphy.gishraphoid.JTSHelper.checkLongitude;
        log_d("getFromLocation: lat=" + latitude + ",longitude=" + longitude + ",maxResults=" + maxResults);
        if (!checkLatitude(latitude) || !checkLongitude(longitude)) {
            throw new IllegalArgumentException(
                    "lattitude should be > -90 and < 90 and longitude should be >-180 and < 180");
        }
        if (maxResults < 0) {
            throw new IllegalArgumentException("maxResults should be positive");
        }
        if (maxResults == 0) {
            // shortcut filtering
            return new ArrayList<Address>();
        }
        List<Address> androidAddresses = new ArrayList<Address>();
        try {
            RestClient webService = createRestClient();

            // Pass the parameters if needed , if not then pass dummy one as
            // follows
            Map<String, String> params = new HashMap<String, String>();
            log_d("lat=" + latitude + ", long=" + longitude);
            // params.put(COUNTRY_PARAMETER_NAME, iso2countryCode);
            params.put(LATITUDE_PARAMETER_NAME, latitude + "");
            params.put(LONGITUDE_PARAMETER_NAME, longitude + "");
            params.put("radius", 500 + "");
            params.put(FORMAT_PARAMETER_NAME, DEFAULT_FORMAT);
            params.put("from", "1");
            params.put("to", "1");
            if (apiKey != null) {
                params.put(APIKEY_PARAMETER_NAME, apiKey + "");
            }
// Path: app/src/main/java/com/gisgraphy/domain/valueobject/StreetSearchResultsDto.java
// public class StreetSearchResultsDto {
// 
//     /**
//      * {"numFound":50,"QTime":252,"result":[{"name":"Newton Street","distance":36.3294330748716,"gid":106603218,"openstreetmapId":16978709,"streetType":"RESIDENTIAL","oneWay":false,"countryCode":"US","length":601.901637459321,"lat":39.83543539626998,"lng":-105.03742540092145,"isIn":"Westminster"},
//      */
// 
//     public int numFound;
//     public Street[] result;
// 
// 
//     public Street[] getResult() {
//         return result;
//     }
// }
// 
// Path: app/src/main/java/com/gisgraphy/gishraphoid/JTSHelper.java
// public static boolean checkLatitude(double latitude) {
//     if (latitude < -90 || latitude > 90) {
//         throw new IllegalArgumentException("latitude is out of bound");
//     }
//     return true;
// }
// 
// Path: app/src/main/java/com/gisgraphy/gishraphoid/JTSHelper.java
// public static boolean checkLongitude(double longitude) {
//     if (longitude < -180 || longitude > 180) {
//         throw new IllegalArgumentException("longitude is out of bound");
//     }
//     return true;
// }


// Path: app/src/main/java/com/gisgraphy/gishraphoid/GisgraphyGeocoder.java
import android.content.Context;
import android.location.Address;
import android.location.Geocoder;
import android.util.Log;
import com.gisgraphy.domain.valueobject.StreetSearchResultsDto;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import static com.gisgraphy.gishraphoid.JTSHelper.checkLatitude;
import static com.gisgraphy.gishraphoid.JTSHelper.checkLongitude;

        log_d("getFromLocation: lat=" + latitude + ",longitude=" + longitude + ",maxResults=" + maxResults);
        if (!checkLatitude(latitude) || !checkLongitude(longitude)) {
            throw new IllegalArgumentException(
                    "lattitude should be > -90 and < 90 and longitude should be >-180 and < 180");
        }
        if (maxResults < 0) {
            throw new IllegalArgumentException("maxResults should be positive");
        }
        if (maxResults == 0) {
            // shortcut filtering
            return new ArrayList<Address>();
        }
        List<Address> androidAddresses = new ArrayList<Address>();
        try {
            RestClient webService = createRestClient();

            // Pass the parameters if needed , if not then pass dummy one as
            // follows
            Map<String, String> params = new HashMap<String, String>();
            log_d("lat=" + latitude + ", long=" + longitude);
            // params.put(COUNTRY_PARAMETER_NAME, iso2countryCode);
            params.put(LATITUDE_PARAMETER_NAME, latitude + "");
            params.put(LONGITUDE_PARAMETER_NAME, longitude + "");
            params.put("radius", 500 + "");
            params.put(FORMAT_PARAMETER_NAME, DEFAULT_FORMAT);
            params.put("from", "1");
            params.put("to", "1");
            if (apiKey != null) {
                params.put(APIKEY_PARAMETER_NAME, apiKey + "");
            }
            StreetSearchResultsDto response = webService.get(REVERSE_GEOCODING_URI, StreetSearchResultsDto.class,