@Override protected Void doInBackground(Void... voids) { try { GraphMetadata metadata = CalculItineraires.getInstance().getMetadata(); if (metadata != null) { setBounds(new LatLngBounds(new LatLng(new BigDecimal(metadata.getMinLatitude()), new BigDecimal(metadata.getMinLongitude())), new LatLng(new BigDecimal( metadata.getMaxLatitude()), new BigDecimal(metadata.getMaxLongitude())))); } } catch (OpenTripPlannerException ignore) { } return null; } }.execute((Void) null);
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; LatLngBounds that = (LatLngBounds) o; if (northeast != null ? !northeast.equals(that.northeast) : that.northeast != null) return false; if (southwest != null ? !southwest.equals(that.southwest) : that.southwest != null) return false; return true; }
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()); } }
/** * @return Returns a string of the form "lat,lng" for this LatLng. We round the lat/lng values to 6 decimal places by default. */ public String toUrlValue() { return toUrlValue(DEFAULT_PRECISION); }
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; }
/** * @param precision * @return Returns a string of the form "lat_lo,lng_lo,lat_hi,lng_hi" for this bounds, where "lo" corresponds to the southwest corner of the bounding box, while "hi" corresponds to the northeast corner of that box. */ public String toUrlValue(int precision) { return getSouthwest().toUrlValue(precision) + "," + getNortheast().toUrlValue(precision); }
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();
.setLocation(new LatLng(lat, lng)) .setLanguage("en").getGeocoderRequest(); geocoderResponse = geocoder.geocode(geocoderRequest);
@Override public int hashCode() { int result = channel != null ? channel.hashCode() : 0; result = 31 * result + (address != null ? address.hashCode() : 0); result = 31 * result + (language != null ? language.hashCode() : 0); result = 31 * result + (region != null ? region.hashCode() : 0); result = 31 * result + (bounds != null ? bounds.hashCode() : 0); result = 31 * result + (location != null ? location.hashCode() : 0); result = 31 * result + (components != null ? components.hashCode() : 0); return result; }
url.append("&address=").append(URLEncoder.encode(address, ENCODING)); } else if (location != null) { url.append("&latlng=").append(URLEncoder.encode(location.toUrlValue(), ENCODING)); } else { throw new IllegalArgumentException("Address or location must be defined"); url.append("&bounds=").append(URLEncoder.encode(bounds.getSouthwest().toUrlValue() + "|" + bounds.getNortheast().toUrlValue(), ENCODING));
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; GeocoderRequest that = (GeocoderRequest) o; if (address != null ? !address.equals(that.address) : that.address != null) return false; if (bounds != null ? !bounds.equals(that.bounds) : that.bounds != null) return false; if (channel != null ? !channel.equals(that.channel) : that.channel != null) return false; if (components != null ? !components.equals(that.components) : that.components != null) return false; if (language != null ? !language.equals(that.language) : that.language != null) return false; if (location != null ? !location.equals(that.location) : that.location != null) return false; if (region != null ? !region.equals(that.region) : that.region != null) return false; return true; }
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();
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 = location != null ? location.hashCode() : 0; result = 31 * result + (locationType != null ? locationType.hashCode() : 0); result = 31 * result + (viewport != null ? viewport.hashCode() : 0); result = 31 * result + (bounds != null ? bounds.hashCode() : 0); return result; }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; GeocoderGeometry that = (GeocoderGeometry) o; if (location != null ? !location.equals(that.location) : that.location != null) return false; if (locationType != that.locationType) return false; if (viewport != null ? !viewport.equals(that.viewport) : that.viewport != null) return false; if (bounds != null ? !bounds.equals(that.bounds) : that.bounds != null) return false; return true; }
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; }