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