From 77cdc3d8ffc81470968fafeb77fa2455bbffd1f1 Mon Sep 17 00:00:00 2001 From: Rafa de la Torre Date: Tue, 5 Jul 2016 18:36:28 +0200 Subject: [PATCH] Only refine individual solutions when error > TOLERANCE --- .../cartodb_services/mapzen/isolines.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 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 f6f50aa..2feb6ed 100644 --- a/server/lib/python/cartodb_services/cartodb_services/mapzen/isolines.py +++ b/server/lib/python/cartodb_services/cartodb_services/mapzen/isolines.py @@ -56,11 +56,13 @@ class MapzenIsolines: # let's refine the solution, binary search for j in xrange(0, self.NUMBER_OF_ANGLES): - if errors[j] > 0: - rmax[j] = (rmax[j] + rmin[j]) / 2.0 - else: - rmin[j] = (rmax[j] + rmin[j]) / 2.0 - location_estimates[j] = self._calculate_dest_location(origin, angles[j], (rmax[j]+rmin[j])/2.0) + + if abs(errors[j]) > self.TOLERANCE: + if errors[j] > 0: + rmax[j] = (rmax[j] + rmin[j]) / 2.0 + else: + rmin[j] = (rmax[j] + rmin[j]) / 2.0 + location_estimates[j] = self._calculate_dest_location(origin, angles[j], (rmax[j]+rmin[j])/2.0) # and check "actual" costs again resp = self._matrix_client.one_to_many([origin] + location_estimates, 'pedestrian')