diff --git a/server/extension/sql/100_routing_helper.sql b/server/extension/sql/100_routing_helper.sql index 26a8880..cfd8035 100644 --- a/server/extension/sql/100_routing_helper.sql +++ b/server/extension/sql/100_routing_helper.sql @@ -37,7 +37,7 @@ RETURNS cdb_dataservices_server.simple_route AS $$ resp = client.calculate_route_point_to_point(origin_coordinates, dest_coordinates, mode, options, units) - if resp: + if resp and resp.shape: shape_linestring = polyline_to_linestring(resp.shape) quota_service.increment_success_service_use() return [shape_linestring, resp.length, resp.duration] diff --git a/server/lib/python/cartodb_services/cartodb_services/mapzen/routing.py b/server/lib/python/cartodb_services/cartodb_services/mapzen/routing.py index 2cff989..54b6145 100644 --- a/server/lib/python/cartodb_services/cartodb_services/mapzen/routing.py +++ b/server/lib/python/cartodb_services/cartodb_services/mapzen/routing.py @@ -45,6 +45,8 @@ class MapzenRouting: response = requests.get(self._url, params=request_params) if response.status_code == requests.codes.ok: return self.__parse_routing_response(response.text) + elif response.status_code == requests.codes.bad_request: + return MapzenRoutingResponse(None, None, None) else: response.raise_for_status() @@ -78,9 +80,7 @@ class MapzenRouting: shape = PolyLine().decode(legs['shape']) length = legs['summary']['length'] duration = legs['summary']['time'] - routing_response = MapzenRoutingResponse(shape, length, duration) - - return routing_response + return MapzenRoutingResponse(shape, length, duration) except IndexError: return [] except KeyError: