Skip to content

Commit

Permalink
Jormungandr: use max_nb_journeys in isochrone
Browse files Browse the repository at this point in the history
close hove-io#356 as count fill max_nb_journeys when provided
  • Loading branch information
antoine-de committed Oct 19, 2015
1 parent 69d16b4 commit db9310c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions source/jormungandr/jormungandr/scenarios/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,11 @@ def isochrone(self, request, instance):
req.journeys.streetnetwork_params.destination_mode = self.destination_modes[0]
resp = instance.send_and_receive(req)

if not request['debug']:
# on isochrone we can filter the number of max journeys
if request["max_nb_journeys"] and len(resp.journeys) > request["max_nb_journeys"]:
del resp.journeys[request["max_nb_journeys"]:]

return resp

def _remove_not_long_enough_fallback(self, resp, instance):
Expand Down
9 changes: 8 additions & 1 deletion source/jormungandr/tests/isochrone_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,17 @@ def test_reverse_isochrone_coord_clockwise(self):
assert error_code == 404
assert normal_response['error']['message'] == 'reverse isochrone works only for anti-clockwise request'


def test_isochrone_non_clockwise(self):
q = "v1/coverage/basic_routing_test/journeys?datetime=20120614T080000&from=A&datetime_represents=arrival"
normal_response, error_code = self.query_no_assert(q)

assert error_code == 404
assert normal_response['error']['message'] == 'isochrone works only for clockwise request'

def test_isochrone_count(self):
query = "v1/coverage/basic_routing_test/stop_points/A/journeys?max_duration=25500&datetime=20120614T080000"
response = self.query(query)
assert len(response["journeys"]) == 2
query += "&count=1"
response = self.query(query)
assert len(response["journeys"]) == 1

0 comments on commit db9310c

Please sign in to comment.