@Override public LatLng getLatLngPointsByAddress(String address) throws IOException { GeocoderResult result = getAddress(address); if (result == null) return null; return result.getGeometry().getLocation(); }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; GeocoderResult that = (GeocoderResult) o; if (partialMatch != that.partialMatch) return false; if (addressComponents != null ? !addressComponents.equals(that.addressComponents) : that.addressComponents != null) return false; if (formattedAddress != null ? !formattedAddress.equals(that.formattedAddress) : that.formattedAddress != null) return false; if (geometry != null ? !geometry.equals(that.geometry) : that.geometry != null) return false; if (types != null ? !types.equals(that.types) : that.types != null) return false; return true; }
/** * Returns the geo location type. Should be one of: ROOFTOP, RANGE_INTERPOLATED, GEOMETRIC_CENTE, APPROXIMATE. * * @param geocoderResult * @return */ private GeocoderLocationType getGeometryLocationType(GeocoderResult geocoderResult) { GeocoderLocationType locationType = null; GeocoderGeometry geometry = geocoderResult.getGeometry(); if (geometry != null && geometry.getLocationType() != null) { locationType = geometry.getLocationType(); } return locationType; }
private GeocodeResponse arretToGeocodeResponse(Arret arret) { GeocodeResponse response = new GeocodeResponse(); response.setStatus(GeocoderStatus.OK); response.setResults(new ArrayList<GeocoderResult>()); GeocoderResult result = new GeocoderResult(); result.setGeometry(new GeocoderGeometry()); result.getGeometry().setLocation( new LatLng(BigDecimal.valueOf(arret.getLatitude()), BigDecimal.valueOf(arret.getLongitude()))); response.getResults().add(result); return response; }
@Override public int hashCode() { int result = types != null ? types.hashCode() : 0; result = 31 * result + (formattedAddress != null ? formattedAddress.hashCode() : 0); result = 31 * result + (addressComponents != null ? addressComponents.hashCode() : 0); result = 31 * result + (geometry != null ? geometry.hashCode() : 0); result = 31 * result + (partialMatch ? 1 : 0); return result; }
private GeocodeResponse arretToGeocodeResponse(Arret arret) { GeocodeResponse response = new GeocodeResponse(); response.setStatus(GeocoderStatus.OK); response.setResults(new ArrayList<GeocoderResult>()); GeocoderResult result = new GeocoderResult(); result.setGeometry(new GeocoderGeometry()); result.getGeometry().setLocation( new LatLng(BigDecimal.valueOf(arret.getLatitude()), BigDecimal.valueOf(arret.getLongitude()))); response.getResults().add(result); return response; }
public GoogleCoordinates(final GeocoderResult result) throws GeocoderException { super(); if (result == null) { throw new GeocoderException("No valid geocoder result found!"); } final GeocoderGeometry geometry = result.getGeometry(); if (geometry == null) { throw new GeocoderException("No geometry found in Google geocoding response!"); } final LatLng latLng = geometry.getLocation(); if (latLng == null) { throw new GeocoderException("No latitude/longitude found in Google geocoding response!"); } setCoordinates(latLng.getLng().doubleValue(), latLng.getLat().doubleValue()); } }
double longitudeArrivee; if (resultDepart != null) { latitudeDepart = resultDepart.getGeometry().getLocation().getLat().doubleValue(); longitudeDepart = resultDepart.getGeometry().getLocation().getLng().doubleValue(); } else { latitudeDepart = locationUtil.getCurrentLocation().getLatitude(); latitudeArrivee = resultArrivee.getGeometry().getLocation().getLat().doubleValue(); longitudeArrivee = resultArrivee.getGeometry().getLocation().getLng().doubleValue(); } else { latitudeArrivee = locationUtil.getCurrentLocation().getLatitude();
double longitudeArrivee; if (resultDepart != null) { latitudeDepart = resultDepart.getGeometry().getLocation().getLat().doubleValue(); longitudeDepart = resultDepart.getGeometry().getLocation().getLng().doubleValue(); } else { latitudeDepart = locationUtil.getCurrentLocation().getLatitude(); latitudeArrivee = resultArrivee.getGeometry().getLocation().getLat().doubleValue(); longitudeArrivee = resultArrivee.getGeometry().getLocation().getLng().doubleValue(); } else { latitudeArrivee = locationUtil.getCurrentLocation().getLatitude();
public static double[] getLatLngForAddr(String addr) { if (addr == null) return null; Geocoder geocoder = new Geocoder(); GeocoderRequest geocoderRequest; GeocodeResponse geocoderResponse; geocoderRequest = new GeocoderRequestBuilder() .setAddress(addr) .setLanguage("en").getGeocoderRequest(); geocoderResponse = geocoder.geocode(geocoderRequest); if (geocoderResponse != null) { if (geocoderResponse.getStatus() == GeocoderStatus.OK) { if (!geocoderResponse.getResults().isEmpty()) { GeocoderResult geocoderResult = // Get the first result geocoderResponse.getResults().iterator().next(); double[] loc = new double[2]; LatLng ll = geocoderResult.getGeometry().getLocation(); loc[0] = ll.getLat().doubleValue(); loc[1] = ll.getLng().doubleValue(); return loc; } } } return null; }