/** * {@inheritDoc} */ @Override public Object clone() { return new GeoHashPoint(getLatitude(), getLongitude()); }
/** * Gets the geohash. * * @return the geohash */ public String getGeohash() { return GeoHashExtensions.encode(getLatitude(), getLongitude()); }
/** * Sets the geocoding data. * * @param address * the new geocoding data * @throws MalformedURLException * the malformed url exception * @throws IOException * Signals that an I/O exception has occurred. * @throws SAXException * Signals that an SAX error or warning has occurred. * @throws ParserConfigurationException * Indicates a serious configuration error. */ public static void setGeocodingData(final Addresses address) throws MalformedURLException, IOException, ParserConfigurationException, SAXException { String responseFromGoogle = Geocoder .getGeolocationAsXml(address.getStreet() + " " + address.getStreetnumber() + " " + address.getZipcode().getZipcode() + " " + address.getZipcode().getCity()); GeoHashPoint geoHashModel = Geocoder.getGeocodingData(responseFromGoogle); if (geoHashModel != null) { address.setGeohash(geoHashModel.getGeohash()); address.setLatitude(geoHashModel.getLat().toString()); address.setLongitude(geoHashModel.getLng().toString()); } } }
/** * Returns the distance between two given geohash values. * * @param startGeohashValue * the geohash value from where to start the measurement. * @param endGeohashValue * the geohash value where to end the measurement. * @param unit * the measurement unit * @return the distance between the given geohash values. */ public static double distanceBetweenPoints(final String startGeohashValue, final String endGeohashValue, final MeasuringUnit unit) { return distanceBetweenPoints(new GeoHashPoint(startGeohashValue), new GeoHashPoint(endGeohashValue), unit); }
/** * {@inheritDoc} */ @Override public String toString() { final StringBuilder buffer = new StringBuilder(); buffer.append("[GeoHashPoint:"); buffer.append(super.toString()); buffer.append(" Geohash : "); buffer.append(getGeohash()); buffer.append("]"); return buffer.toString(); }
/** * Gets the latitude as BigDecimal object. * * @return the latitude as BigDecimal object. */ public BigDecimal getLat() { return BigDecimal.valueOf(getLatitude()); }
/** * Gets the longitude as BigDecimal object. * * @return the longitude as BigDecimal object. */ public BigDecimal getLng() { return BigDecimal.valueOf(getLongitude()); }
/** * Sets the geocoding data. * * @param address * the new geocoding data * @throws MalformedURLException * the malformed url exception * @throws IOException * Signals that an I/O exception has occurred. * @throws SAXException * Signals that an SAX error or warning has occurred. * @throws ParserConfigurationException * Indicates a serious configuration error. */ public static void setGeocodingData(final Addresses address) throws MalformedURLException, IOException, ParserConfigurationException, SAXException { String responseFromGoogle = Geocoder.getGeolocationAsXml(address.getStreet() + " " + address.getStreetnumber() + " " + address.getZipcode().getZipcode() + " " + address.getZipcode().getCity()); GeoHashPoint geoHashModel = Geocoder.getGeocodingData(responseFromGoogle); if (geoHashModel != null) { address.setGeohash(geoHashModel.getGeohash()); address.setLatitude(geoHashModel.getLat().toString()); address.setLongitude(geoHashModel.getLng().toString()); } }
/** * Gets the {@link GeoHashPoint} object from the given ip address or return null if nothing is * found. * * @param lookupService * the lookup service * @param ipAddress * the ip address * @return the {@link GeoHashPoint} object from the given ip address or return null if nothing * is found. */ public static GeoHashPoint getGeoHashPoint(final LookupService lookupService, final String ipAddress) { final Location lc = lookupService.getLocation(ipAddress); if (lc != null) { return new GeoHashPoint(lc.latitude, lc.longitude); } return null; }
/** * Gets the geohash from the given ip address or return an empty String if nothing is found. * * @param lookupService * the lookup service * @param ipAddress * the ip address * @return the geohash from ip address or an empty String if nothing is found. */ public static String getGeohashFromIpAddress(final LookupService lookupService, final String ipAddress) { final GeoHashPoint geoHashPoint = getGeoHashPoint(lookupService, ipAddress); if (geoHashPoint != null) { return geoHashPoint.getGeohash(); } return ""; }
double lat = Double.parseDouble(l); double lng = Double.parseDouble(longtidude); model = new GeoHashPoint(lat, lng);
double lat = Double.parseDouble(l); double lng = Double.parseDouble(longtidude); model = new GeoHashPoint(lat, lng);