public GeolocAddress geolocByLatitudeLongitude(final String latitude, final String longitude) { GeolocAddress geolocAddress = null; GoogleGeoCode geoCode = geolocGoogleWithLatitudeLongitude(latitude, longitude); if (geoCode != null && "OVER_QUERY_LIMIT".equals(geoCode.getStatus())) { logger.error("API Geoloc returns message OVER_QUERY_LIMIT: " + geoCode.getErrorMessage()); engineSettingService.flagSettingGoogleGeolocationApiOverQuota(); return geolocAddress; } if (geoCode != null && geoCode.getResults().size() > 0) { GoogleGeoCodeResult googleGeoCodeResult = geoCode.getResults().get(0); String formatedAdress = googleGeoCodeResult.getFormattedAddress(); formatedAdress = formatedAdress.replace(" ", "+").replace("\"", "+"); geolocAddress = new GeolocAddress(); geolocAddress.setAddress(googleGeoCodeResult.getAddress()); geolocAddress.setPostalCode(googleGeoCodeResult.getPostalCode()); geolocAddress.setCity(googleGeoCodeResult.getCity()); geolocAddress.setCountry(googleGeoCodeResult.getCountryCode()); geolocAddress.setJson(SerializationHelper.serialize(geoCode)); geolocAddress.setFormatedAddress(formatedAdress); geolocAddress.setLatitude(latitude); geolocAddress.setLongitude(longitude); // SANITY CHECK : DON'T SAVE AN ADDRESS WHICH ALREADY EXIST BUT WAS LOCATED WITH LAT/LONG // DIFFERENT GeolocAddress geolocGeolocAddress = geolocDao.getGeolocAddressByFormatedAddress(formatedAdress); if (geolocGeolocAddress == null) { geolocAddress = geolocDao.saveOrUpdateGeolocAddress(geolocAddress); } } return geolocAddress; }
public GeolocCity geolocByCityAndCountry(final String city, final String country) { GeolocCity geolocCity = null; String addressParam = encodeGoogleAddress(null, null, city, country); GoogleGeoCode geoCode = geolocGoogleWithAddress(addressParam); if (geoCode != null && "OVER_QUERY_LIMIT".equals(geoCode.getStatus())) { logger.error("API Geoloc returns message OVER_QUERY_LIMIT: " + geoCode.getErrorMessage()); engineSettingService.flagSettingGoogleGeolocationApiOverQuota(); return geolocCity; } if (geoCode != null) { geolocCity = new GeolocCity(); geolocCity.setCity(city); geolocCity.setCountry(country); geolocCity.setJson(SerializationHelper.serialize(geoCode)); geolocCity.setLatitude(geoCode.getLatitude()); geolocCity.setLongitude(geoCode.getLongitude()); if (city == null) { // SANITY CHECK : DON'T SAVE A CITY AS NULL TOO MANY TIME GeolocCity geolocCityCheck = geolocDao.getGeolocCityByCountryWithNullCity(country); if (geolocCityCheck == null) { try { geolocCity = geolocDao.saveOrUpdateGeolocCity(geolocCity); } catch (Exception e) { logger.error( "Can't save GeolocCity: City: '" + geolocCity.getCity() + "', Country: '" + geolocCity.getCountry() + "'", e); } } } else { try { geolocCity = geolocDao.saveOrUpdateGeolocCity(geolocCity); } catch (Exception e) { logger.error( "Can't save GeolocCity: City: '" + geolocCity.getCity() + "', Country: '" + geolocCity.getCountry() + "'", e); } } } return geolocCity; }
public GeolocAddress geolocByAddress( final String address, final String postalCode, final String city, final String country) { GeolocAddress geolocAddress = null; String formatedAddress = encodeGoogleAddress(address, postalCode, city, country); GoogleGeoCode geoCode = geolocGoogleWithAddress(formatedAddress); if (geoCode != null && "OVER_QUERY_LIMIT".equals(geoCode.getStatus())) { logger.error("API Geoloc returns message OVER_QUERY_LIMIT: " + geoCode.getErrorMessage()); engineSettingService.flagSettingGoogleGeolocationApiOverQuota(); return geolocAddress; } if (geoCode != null) { geolocAddress = new GeolocAddress(); geolocAddress.setAddress(address); geolocAddress.setPostalCode(postalCode); geolocAddress.setCity(city); geolocAddress.setCountry(country); geolocAddress.setJson(SerializationHelper.serialize(geoCode)); geolocAddress.setFormatedAddress(formatedAddress); geolocAddress.setLatitude(geoCode.getLatitude()); geolocAddress.setLongitude(geoCode.getLongitude()); geolocAddress = geolocDao.saveOrUpdateGeolocAddress(geolocAddress); } return geolocAddress; }
public void deleteGeolocAddress(final GeolocAddress geolocCity) { geolocDao.deleteGeolocAddress(geolocCity); }
public GeolocAddress saveOrUpdateGeolocAddress(final GeolocAddress geolocCity) { return geolocDao.saveOrUpdateGeolocAddress(geolocCity); }
public GeolocAddress getGeolocAddressByLatitudeAndLongitude( final String latitude, final String longitude, Object... params) { return geolocDao.getGeolocAddressByLatitudeAndLongitude(latitude, longitude, params); }
public GeolocAddress getGeolocAddressByFormatedAddress( final String formatedAddress, Object... params) { return geolocDao.getGeolocAddressByFormatedAddress(formatedAddress, params); }
public void deleteGeolocCity(final GeolocCity geolocCity) { geolocDao.deleteGeolocCity(geolocCity); }
public GeolocCity saveOrUpdateGeolocCity(final GeolocCity geolocCity) { return geolocDao.saveOrUpdateGeolocCity(geolocCity); }
public GeolocCity getGeolocCityByCountryWithNullCity(final String country, Object... params) { return geolocDao.getGeolocCityByCountryWithNullCity(country, params); }
public GeolocCity getGeolocCityByCityAndCountry( final String city, final String country, Object... params) { return geolocDao.getGeolocCityByCityAndCountry(city, country, params); }