/** * {@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 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 ""; }
/** * 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()); } } }
/** * 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()); } }