def getNearbyStops(self, lat, long, exclude_stop=0): c = self.conn.cursor() RANGE = 0.005 rows = c.execute('''SELECT StopNo, FlagStopNo, StopName, CityDirection, SuburbName, Latitude, Longitude FROM stops WHERE StopNo != ? AND StopNo IN (SELECT StopNo FROM stops WHERE Latitude BETWEEN ? and ? INTERSECT SELECT StopNo FROM stops WHERE Longitude BETWEEN ? and ?)''', (exclude_stop, lat - RANGE, lat + RANGE, long - RANGE, long + RANGE)) stops = map(lambda row: dict(zip(map(lambda a: a[0], rows.description), row)), rows) c.close() for stop in stops: stop['Distance'] = distance_between(lat, long, stop['Latitude'], stop['Longitude']) stops.sort(cmp = lambda a, b: cmp(a['Distance'], b['Distance'])) return stops
def distance_to_liblocation(src, target): return distance_between(src.lat, src.lon, target.lat, target.lon) * 1000
def get_distance_from(self, lng, lat): return location.distance_between(float(lat), float(lng), float(self.lat), float(self.lng))
def distance_to_liblocation(self, target): return location.distance_between(self.lat, self.lon, target.lat, target.lon) * 1000