Skip to content

Commit 60e6622

Browse files
mmeyer724jonthornton
authored andcommitted
Fix get_by_point for python 3
1 parent fa36c51 commit 60e6622

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

mtapi/mtapi.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import urllib, contextlib, datetime, copy
22
from collections import defaultdict
3+
from itertools import islice
34
from operator import itemgetter
45
import csv, math, json
56
import threading
@@ -185,9 +186,10 @@ def get_by_point(self, point, limit=5):
185186
with self._read_lock:
186187
sortable_stations = copy.deepcopy(self._stations).values()
187188

188-
sortable_stations.sort(key=lambda x: distance(x['location'], point))
189-
sortable_stations = map(lambda x: x.serialize(), sortable_stations)
190-
return sortable_stations[:limit]
189+
sorted_stations = sorted(sortable_stations, key=lambda s: distance(s['location'], point))
190+
serialized_stations = map(lambda s: s.serialize(), sorted_stations)
191+
192+
return list(islice(serialized_stations, limit))
191193

192194
def get_routes(self):
193195
return self._routes.keys()

0 commit comments

Comments
 (0)