// 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;
     * @param url     the base url (scheme,host,port). see
     *                {@link #setBaseUrl(String)}
     */
    public GisgraphyGeocoder(Context context, String url) {
        this.locale = Locale.getDefault();
        addressBuilder = new AndroidAddressBuilder(locale);
        setBaseUrl(url);
    }

    /**
     * Returns a list of Addresses that are known to describe the area
     * immediately surrounding the given latitude and longitude.
     * <p/>
     * The returned values may be obtained by means of a network lookup. The
     * results are a best guess and are not guaranteed to be meaningful or
     * correct. It may be useful to call this method from a thread separate from
     * your primary UI thread.
     *
     * @param latitude   the latitude a point for the search
     * @param longitude  the longitude a point for the search
     * @param maxResults max number of addresses to return. Smaller numbers (1 to 5)
     *                   are recommended
     * @return a list of Address objects. Returns empty list if no matches were
     * found or there is no backend service available.
     * @throws IllegalArgumentException if latitude is less than -90 or greater than 90
     * @throws IllegalArgumentException if longitude is less than -180 or greater than 180
     * @throws IOException              if the network is unavailable or any other I/O problem occurs
     */
    public List<Address> getFromLocation(double latitude, double longitude, int maxResults) throws IOException {
        log_d("getFromLocation: lat=" + latitude + ",longitude=" + longitude + ",maxResults=" + maxResults);
// 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;

     * @param url     the base url (scheme,host,port). see
     *                {@link #setBaseUrl(String)}
     */
    public GisgraphyGeocoder(Context context, String url) {
        this.locale = Locale.getDefault();
        addressBuilder = new AndroidAddressBuilder(locale);
        setBaseUrl(url);
    }

    /**
     * Returns a list of Addresses that are known to describe the area
     * immediately surrounding the given latitude and longitude.
     * <p/>
     * The returned values may be obtained by means of a network lookup. The
     * results are a best guess and are not guaranteed to be meaningful or
     * correct. It may be useful to call this method from a thread separate from
     * your primary UI thread.
     *
     * @param latitude   the latitude a point for the search
     * @param longitude  the longitude a point for the search
     * @param maxResults max number of addresses to return. Smaller numbers (1 to 5)
     *                   are recommended
     * @return a list of Address objects. Returns empty list if no matches were
     * found or there is no backend service available.
     * @throws IllegalArgumentException if latitude is less than -90 or greater than 90
     * @throws IllegalArgumentException if longitude is less than -180 or greater than 180
     * @throws IOException              if the network is unavailable or any other I/O problem occurs
     */
    public List<Address> getFromLocation(double latitude, double longitude, int maxResults) throws IOException {
        log_d("getFromLocation: lat=" + latitude + ",longitude=" + longitude + ",maxResults=" + maxResults);
        if (!checkLatitude(latitude) || !checkLongitude(longitude)) {