|
|
|
|
@@ -137,7 +137,7 @@ class RoutingConfig(ServiceConfig):
|
|
|
|
|
MAPZEN_PROVIDER = 'mapzen'
|
|
|
|
|
MAPBOX_PROVIDER = 'mapbox'
|
|
|
|
|
TOMTOM_PROVIDER = 'tomtom'
|
|
|
|
|
DEFAULT_PROVIDER = MAPZEN_PROVIDER
|
|
|
|
|
DEFAULT_PROVIDER = MAPBOX_PROVIDER
|
|
|
|
|
QUOTA_KEY = 'mapzen_routing_quota'
|
|
|
|
|
SOFT_LIMIT_KEY = 'soft_mapzen_routing_limit'
|
|
|
|
|
METRICS_LOG_KEY = 'routing_log_path'
|
|
|
|
|
@@ -148,12 +148,15 @@ class RoutingConfig(ServiceConfig):
|
|
|
|
|
self._routing_provider = self._redis_config[self.ROUTING_PROVIDER_KEY]
|
|
|
|
|
if not self._routing_provider:
|
|
|
|
|
self._routing_provider = self.DEFAULT_PROVIDER
|
|
|
|
|
self._mapzen_api_key = self._db_config.mapzen_routing_api_key
|
|
|
|
|
self._mapzen_service_params = self._db_config.mapzen_routing_service_params
|
|
|
|
|
self._mapbox_api_keys = self._db_config.mapbox_routing_api_keys
|
|
|
|
|
self._mapbox_service_params = self._db_config.mapbox_routing_service_params
|
|
|
|
|
self._tomtom_api_keys = self._db_config.tomtom_routing_api_keys
|
|
|
|
|
self._tomtom_service_params = self._db_config.tomtom_routing_service_params
|
|
|
|
|
if self._routing_provider == self.MAPZEN_PROVIDER:
|
|
|
|
|
self._mapzen_api_key = self._db_config.mapzen_routing_api_key
|
|
|
|
|
self._mapzen_service_params = self._db_config.mapzen_routing_service_params
|
|
|
|
|
elif self._routing_provider == self.MAPBOX_PROVIDER:
|
|
|
|
|
self._mapbox_api_keys = self._db_config.mapbox_routing_api_keys
|
|
|
|
|
self._mapbox_service_params = self._db_config.mapbox_routing_service_params
|
|
|
|
|
elif self._routing_provider == self.TOMTOM_PROVIDER:
|
|
|
|
|
self._tomtom_api_keys = self._db_config.tomtom_routing_api_keys
|
|
|
|
|
self._tomtom_service_params = self._db_config.tomtom_routing_service_params
|
|
|
|
|
self._set_monthly_quota()
|
|
|
|
|
self._set_soft_limit()
|
|
|
|
|
self._period_end_date = date_parse(self._redis_config[self.PERIOD_END_DATE])
|
|
|
|
|
@@ -244,7 +247,7 @@ class IsolinesRoutingConfig(ServiceConfig):
|
|
|
|
|
MAPBOX_PROVIDER = 'mapbox'
|
|
|
|
|
TOMTOM_PROVIDER = 'tomtom'
|
|
|
|
|
HEREMAPS_PROVIDER = 'heremaps'
|
|
|
|
|
DEFAULT_PROVIDER = MAPZEN_PROVIDER
|
|
|
|
|
DEFAULT_PROVIDER = MAPBOX_PROVIDER
|
|
|
|
|
METRICS_LOG_KEY = 'isolines_log_path'
|
|
|
|
|
|
|
|
|
|
def __init__(self, redis_connection, db_conn, username, orgname=None):
|
|
|
|
|
@@ -428,7 +431,7 @@ class GeocoderConfig(ServiceConfig):
|
|
|
|
|
USERNAME_KEY = 'username'
|
|
|
|
|
ORGNAME_KEY = 'orgname'
|
|
|
|
|
PERIOD_END_DATE = 'period_end_date'
|
|
|
|
|
DEFAULT_PROVIDER = MAPZEN_GEOCODER
|
|
|
|
|
DEFAULT_PROVIDER = MAPBOX_GEOCODER
|
|
|
|
|
METRICS_LOG_KEY = 'geocoder_log_path'
|
|
|
|
|
|
|
|
|
|
def __init__(self, redis_connection, db_conn, username, orgname=None, forced_provider=None):
|
|
|
|
|
@@ -635,50 +638,51 @@ class ServicesDBConfig:
|
|
|
|
|
heremaps_conf_json = self._get_conf('heremaps_conf')
|
|
|
|
|
if not heremaps_conf_json:
|
|
|
|
|
raise ConfigException('Here maps configuration missing')
|
|
|
|
|
else:
|
|
|
|
|
heremaps_conf = json.loads(heremaps_conf_json)
|
|
|
|
|
self._heremaps_geocoder_app_id = heremaps_conf['geocoder']['app_id']
|
|
|
|
|
self._heremaps_geocoder_app_code = heremaps_conf['geocoder']['app_code']
|
|
|
|
|
self._heremaps_geocoder_cost_per_hit = heremaps_conf['geocoder'][
|
|
|
|
|
'geocoder_cost_per_hit']
|
|
|
|
|
self._heremaps_geocoder_service_params = heremaps_conf['geocoder'].get('service', {})
|
|
|
|
|
self._heremaps_isolines_app_id = heremaps_conf['isolines']['app_id']
|
|
|
|
|
self._heremaps_isolines_app_code = heremaps_conf['isolines']['app_code']
|
|
|
|
|
self._heremaps_isolines_service_params = heremaps_conf['isolines'].get('service', {})
|
|
|
|
|
|
|
|
|
|
heremaps_conf = json.loads(heremaps_conf_json)
|
|
|
|
|
self._heremaps_geocoder_app_id = heremaps_conf['geocoder']['app_id']
|
|
|
|
|
self._heremaps_geocoder_app_code = heremaps_conf['geocoder']['app_code']
|
|
|
|
|
self._heremaps_geocoder_cost_per_hit = heremaps_conf['geocoder'][
|
|
|
|
|
'geocoder_cost_per_hit']
|
|
|
|
|
self._heremaps_geocoder_service_params = heremaps_conf['geocoder'].get('service', {})
|
|
|
|
|
self._heremaps_isolines_app_id = heremaps_conf['isolines']['app_id']
|
|
|
|
|
self._heremaps_isolines_app_code = heremaps_conf['isolines']['app_code']
|
|
|
|
|
self._heremaps_isolines_service_params = heremaps_conf['isolines'].get('service', {})
|
|
|
|
|
|
|
|
|
|
def _get_mapzen_config(self):
|
|
|
|
|
mapzen_conf_json = self._get_conf('mapzen_conf')
|
|
|
|
|
# We dont use mapzen anymore so we don't need to check for its configuration
|
|
|
|
|
if not mapzen_conf_json:
|
|
|
|
|
raise ConfigException('Mapzen configuration missing')
|
|
|
|
|
else:
|
|
|
|
|
mapzen_conf = json.loads(mapzen_conf_json)
|
|
|
|
|
self._mapzen_matrix_api_key = mapzen_conf['matrix']['api_key']
|
|
|
|
|
self._mapzen_matrix_quota = mapzen_conf['matrix']['monthly_quota']
|
|
|
|
|
self._mapzen_matrix_service_params = mapzen_conf['matrix'].get('service', {})
|
|
|
|
|
self._mapzen_isochrones_service_params = mapzen_conf.get('isochrones', {}).get('service', {})
|
|
|
|
|
self._mapzen_routing_api_key = mapzen_conf['routing']['api_key']
|
|
|
|
|
self._mapzen_routing_quota = mapzen_conf['routing']['monthly_quota']
|
|
|
|
|
self._mapzen_routing_service_params = mapzen_conf['routing'].get('service', {})
|
|
|
|
|
self._mapzen_geocoder_api_key = mapzen_conf['geocoder']['api_key']
|
|
|
|
|
self._mapzen_geocoder_quota = mapzen_conf['geocoder']['monthly_quota']
|
|
|
|
|
self._mapzen_geocoder_service_params = mapzen_conf['geocoder'].get('service', {})
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
mapzen_conf = json.loads(mapzen_conf_json)
|
|
|
|
|
self._mapzen_matrix_api_key = mapzen_conf['matrix']['api_key']
|
|
|
|
|
self._mapzen_matrix_quota = mapzen_conf['matrix']['monthly_quota']
|
|
|
|
|
self._mapzen_matrix_service_params = mapzen_conf['matrix'].get('service', {})
|
|
|
|
|
self._mapzen_isochrones_service_params = mapzen_conf.get('isochrones', {}).get('service', {})
|
|
|
|
|
self._mapzen_routing_api_key = mapzen_conf['routing']['api_key']
|
|
|
|
|
self._mapzen_routing_quota = mapzen_conf['routing']['monthly_quota']
|
|
|
|
|
self._mapzen_routing_service_params = mapzen_conf['routing'].get('service', {})
|
|
|
|
|
self._mapzen_geocoder_api_key = mapzen_conf['geocoder']['api_key']
|
|
|
|
|
self._mapzen_geocoder_quota = mapzen_conf['geocoder']['monthly_quota']
|
|
|
|
|
self._mapzen_geocoder_service_params = mapzen_conf['geocoder'].get('service', {})
|
|
|
|
|
|
|
|
|
|
def _get_mapbox_config(self):
|
|
|
|
|
mapbox_conf_json = self._get_conf('mapbox_conf')
|
|
|
|
|
if not mapbox_conf_json:
|
|
|
|
|
raise ConfigException('Mapbox configuration missing')
|
|
|
|
|
else:
|
|
|
|
|
mapbox_conf = json.loads(mapbox_conf_json)
|
|
|
|
|
self._mapbox_matrix_api_keys = mapbox_conf['matrix']['api_keys']
|
|
|
|
|
self._mapbox_matrix_quota = mapbox_conf['matrix']['monthly_quota']
|
|
|
|
|
self._mapbox_matrix_service_params = mapbox_conf['matrix'].get('service', {})
|
|
|
|
|
self._mapbox_isochrones_service_params = mapbox_conf.get('isochrones', {}).get('service', {})
|
|
|
|
|
self._mapbox_routing_api_keys = mapbox_conf['routing']['api_keys']
|
|
|
|
|
self._mapbox_routing_quota = mapbox_conf['routing']['monthly_quota']
|
|
|
|
|
self._mapbox_routing_service_params = mapbox_conf['routing'].get('service', {})
|
|
|
|
|
self._mapbox_geocoder_api_keys = mapbox_conf['geocoder']['api_keys']
|
|
|
|
|
self._mapbox_geocoder_quota = mapbox_conf['geocoder']['monthly_quota']
|
|
|
|
|
self._mapbox_geocoder_service_params = mapbox_conf['geocoder'].get('service', {})
|
|
|
|
|
|
|
|
|
|
mapbox_conf = json.loads(mapbox_conf_json)
|
|
|
|
|
self._mapbox_matrix_api_keys = mapbox_conf['matrix']['api_keys']
|
|
|
|
|
self._mapbox_matrix_quota = mapbox_conf['matrix']['monthly_quota']
|
|
|
|
|
self._mapbox_matrix_service_params = mapbox_conf['matrix'].get('service', {})
|
|
|
|
|
self._mapbox_isochrones_service_params = mapbox_conf.get('isochrones', {}).get('service', {})
|
|
|
|
|
self._mapbox_routing_api_keys = mapbox_conf['routing']['api_keys']
|
|
|
|
|
self._mapbox_routing_quota = mapbox_conf['routing']['monthly_quota']
|
|
|
|
|
self._mapbox_routing_service_params = mapbox_conf['routing'].get('service', {})
|
|
|
|
|
self._mapbox_geocoder_api_keys = mapbox_conf['geocoder']['api_keys']
|
|
|
|
|
self._mapbox_geocoder_quota = mapbox_conf['geocoder']['monthly_quota']
|
|
|
|
|
self._mapbox_geocoder_service_params = mapbox_conf['geocoder'].get('service', {})
|
|
|
|
|
|
|
|
|
|
def _get_tomtom_config(self):
|
|
|
|
|
tomtom_conf_json = self._get_conf('tomtom_conf')
|
|
|
|
|
|