Avoid reaching provider for empty geocodings

This commit is contained in:
Antonio
2018-03-13 16:01:05 +01:00
parent 07ed2a4112
commit 59751d7c9c

View File

@@ -98,6 +98,11 @@ RETURNS Geometry AS $$
try:
service_manager.assert_within_limits()
if not searchtext and not city and not state_province and not country:
service_manager.quota_service.increment_empty_service_use()
return None
geocoder = HereMapsGeocoder(service_manager.config.heremaps_app_id, service_manager.config.heremaps_app_code, service_manager.logger, service_manager.config.heremaps_service_params)
coordinates = geocoder.geocode(searchtext=searchtext, city=city, state=state_province, country=country)
if coordinates:
@@ -130,6 +135,11 @@ RETURNS Geometry AS $$
try:
service_manager.assert_within_limits(quota=False)
if not searchtext and not city and not state_province and not country:
service_manager.quota_service.increment_empty_service_use()
return None
geocoder = GoogleMapsGeocoder(service_manager.config.google_client_id, service_manager.config.google_api_key, service_manager.logger)
coordinates = geocoder.geocode(searchtext=searchtext, city=city, state=state_province, country=country)
if coordinates:
@@ -166,6 +176,11 @@ RETURNS Geometry AS $$
try:
service_manager.assert_within_limits()
if not searchtext and not city and not state_province and not country:
service_manager.quota_service.increment_empty_service_use()
return None
geocoder = MapzenGeocoder(service_manager.config.mapzen_api_key, service_manager.logger, service_manager.config.service_params)
country_iso3 = None
if country:
@@ -208,6 +223,11 @@ RETURNS Geometry AS $$
try:
service_manager.assert_within_limits()
if not searchtext and not city and not state_province and not country:
service_manager.quota_service.increment_empty_service_use()
return None
geocoder = MapboxGeocoder(service_manager.config.mapbox_api_key, service_manager.logger, service_manager.config.service_params)
country_iso3166 = None