From 6d888a7a625fcf5b9b24761afdb973cef4d8147b Mon Sep 17 00:00:00 2001 From: Rafa de la Torre Date: Wed, 6 Jul 2016 18:03:20 +0200 Subject: [PATCH] Fix for points getting None cost Sometimes there's no route information for the point in a particular angle we're interested in. In this case it is better to use more points/angles and discard the ones we're not interested in. --- .../cartodb_services/mapzen/isolines.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/server/lib/python/cartodb_services/cartodb_services/mapzen/isolines.py b/server/lib/python/cartodb_services/cartodb_services/mapzen/isolines.py index 95294ad..a78cf4a 100644 --- a/server/lib/python/cartodb_services/cartodb_services/mapzen/isolines.py +++ b/server/lib/python/cartodb_services/cartodb_services/mapzen/isolines.py @@ -3,7 +3,7 @@ import logging class MapzenIsolines: - NUMBER_OF_ANGLES = 12 + NUMBER_OF_ANGLES = 24 MAX_ITERS = 5 TOLERANCE = 0.1 @@ -77,7 +77,13 @@ class MapzenIsolines: location_estimates[j] = self._calculate_dest_location(origin, angles[j], (rmax[j]+rmin[j])/2.0) - return location_estimates + # delete points that got None + location_estimates_filtered = [] + for i, c in enumerate(costs): + if c <> isorange: + location_estimates_filtered.append(location_estimates[i]) + + return location_estimates_filtered