Merge pull request #452 from CartoDB/fix_misplaced_coordinate_polyline
Multiple fixes
This commit is contained in:
commit
2f54ef7e4e
@ -80,6 +80,8 @@ class MapboxGeocoder(Traceable):
|
|||||||
return self._parse_geocoder_response(response.text)
|
return self._parse_geocoder_response(response.text)
|
||||||
elif response.status_code == requests.codes.bad_request:
|
elif response.status_code == requests.codes.bad_request:
|
||||||
return []
|
return []
|
||||||
|
elif response.status_code == requests.codes.unprocessable_entity:
|
||||||
|
return []
|
||||||
else:
|
else:
|
||||||
raise ServiceException(response.status_code, response)
|
raise ServiceException(response.status_code, response)
|
||||||
except requests.Timeout as te:
|
except requests.Timeout as te:
|
||||||
|
@ -49,6 +49,8 @@ class MapboxIsolines():
|
|||||||
response = self._matrix_client.matrix([origin] + targets,
|
response = self._matrix_client.matrix([origin] + targets,
|
||||||
profile)
|
profile)
|
||||||
json_response = json.loads(response)
|
json_response = json.loads(response)
|
||||||
|
if not json_response:
|
||||||
|
return []
|
||||||
|
|
||||||
costs = [None] * number_of_angles
|
costs = [None] * number_of_angles
|
||||||
|
|
||||||
@ -125,6 +127,9 @@ class MapboxIsolines():
|
|||||||
unit_factor=unit_factor,
|
unit_factor=unit_factor,
|
||||||
number_of_angles=number_of_angles)
|
number_of_angles=number_of_angles)
|
||||||
|
|
||||||
|
if not costs:
|
||||||
|
continue
|
||||||
|
|
||||||
errors = [(cost - isorange) / float(isorange) for cost in costs]
|
errors = [(cost - isorange) / float(isorange) for cost in costs]
|
||||||
max_abs_error = max([abs(e) for e in errors])
|
max_abs_error = max([abs(e) for e in errors])
|
||||||
if max_abs_error <= tolerance:
|
if max_abs_error <= tolerance:
|
||||||
|
@ -72,6 +72,8 @@ class MapboxMatrixClient(Traceable):
|
|||||||
return response.text
|
return response.text
|
||||||
elif response.status_code == requests.codes.bad_request:
|
elif response.status_code == requests.codes.bad_request:
|
||||||
return '{}'
|
return '{}'
|
||||||
|
elif response.status_code == requests.codes.unprocessable_entity:
|
||||||
|
return '{}'
|
||||||
else:
|
else:
|
||||||
raise ServiceException(response.status_code, response)
|
raise ServiceException(response.status_code, response)
|
||||||
except requests.Timeout as te:
|
except requests.Timeout as te:
|
||||||
|
@ -91,6 +91,8 @@ class MapboxRouting(Traceable):
|
|||||||
return self._parse_routing_response(response.text)
|
return self._parse_routing_response(response.text)
|
||||||
elif response.status_code == requests.codes.bad_request:
|
elif response.status_code == requests.codes.bad_request:
|
||||||
return MapboxRoutingResponse(None, None, None)
|
return MapboxRoutingResponse(None, None, None)
|
||||||
|
elif response.status_code == requests.codes.unprocessable_entity:
|
||||||
|
return MapboxRoutingResponse(None, None, None)
|
||||||
else:
|
else:
|
||||||
raise ServiceException(response.status_code, response)
|
raise ServiceException(response.status_code, response)
|
||||||
except requests.Timeout as te:
|
except requests.Timeout as te:
|
||||||
|
@ -45,6 +45,8 @@ def marshall_coordinates(coordinates):
|
|||||||
|
|
||||||
def coordinates_to_polygon(coordinates):
|
def coordinates_to_polygon(coordinates):
|
||||||
"""Convert a Coordinate array coordinates to a PostGIS polygon"""
|
"""Convert a Coordinate array coordinates to a PostGIS polygon"""
|
||||||
|
if not coordinates:
|
||||||
|
return None
|
||||||
coordinates.append(coordinates[0]) # Close the ring
|
coordinates.append(coordinates[0]) # Close the ring
|
||||||
result_coordinates = []
|
result_coordinates = []
|
||||||
for coordinate in coordinates:
|
for coordinate in coordinates:
|
||||||
|
@ -51,9 +51,7 @@ def polyline_to_linestring(polyline):
|
|||||||
"""Convert a Mapzen polyline shape to a PostGIS linestring"""
|
"""Convert a Mapzen polyline shape to a PostGIS linestring"""
|
||||||
coordinates = []
|
coordinates = []
|
||||||
for point in polyline:
|
for point in polyline:
|
||||||
# Divide by 10 because mapzen uses one more decimal than the
|
coordinates.append("%s %s" % (point[1], point[0]))
|
||||||
# google standard (https://mapzen.com/documentation/turn-by-turn/decoding/)
|
|
||||||
coordinates.append("%s %s" % (point[1]/10, point[0]/10))
|
|
||||||
wkt_coordinates = ','.join(coordinates)
|
wkt_coordinates = ','.join(coordinates)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -10,7 +10,7 @@ from setuptools import setup, find_packages
|
|||||||
setup(
|
setup(
|
||||||
name='cartodb_services',
|
name='cartodb_services',
|
||||||
|
|
||||||
version='0.16.4',
|
version='0.16.5',
|
||||||
|
|
||||||
description='CartoDB Services API Python Library',
|
description='CartoDB Services API Python Library',
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user