def get_poi_within_radius_old(p_lat, p_lon, radius, category_id=None): """ Returns all the points of interest (POI) within the radius of the given point :param p_lat: the latitude of the given point :param p_lon: the longitude of the given point :param radius: the radius in metres :param category_id: the optional id of a certain category if left blank all categories will be considered :return: returns a list of tuples (distance, POI) """ ret_val = [] ancestor_key = ndb.Key("FIContent_v1", "POI") if category_id is not None: poi_query = POI.query(ancestor=ancestor_key).filter( POI.categoryID == category_id) else: poi_query = POI.query(ancestor=ancestor_key) potential_poi = poi_query.fetch() for poi in potential_poi: dist = distance_between_points(p_lat, p_lon, poi.lat, poi.lon) if dist < radius: ret_val.append((dist, poi)) return ret_val
def get_poi_within_radius_old(p_lat, p_lon, radius, category_id=None): """ Returns all the points of interest (POI) within the radius of the given point :param p_lat: the latitude of the given point :param p_lon: the longitude of the given point :param radius: the radius in metres :param category_id: the optional id of a certain category if left blank all categories will be considered :return: returns a list of tuples (distance, POI) """ ret_val = [] ancestor_key = ndb.Key("FIContent_v1", "POI") if category_id is not None: poi_query = POI.query(ancestor=ancestor_key).filter(POI.categoryID == category_id) else: poi_query = POI.query(ancestor=ancestor_key) potential_poi = poi_query.fetch() for poi in potential_poi: dist = distance_between_points(p_lat, p_lon, poi.lat, poi.lon) if dist < radius: ret_val.append((dist, poi)) return ret_val
def get_poi_between_latitudes(lat_min, lat_max, category_id=None): """ Returns all POI that have their latitudes between lat_min i lat_max :param lat_min: :param lat_max: :param category_id: :return: """ ancestor_key = ndb.Key("FIContent_v1", "POI") if category_id is not None: poi_query = POI.query(ancestor=ancestor_key).filter(POI.lat > lat_min).filter(POI.lat < lat_max)\ .filter(POI.categoryID == category_id) else: poi_query = POI.query(ancestor=ancestor_key).filter( POI.lat > lat_min).filter(POI.lat < lat_max) return poi_query.fetch(projection=[POI.lat, POI.lon])
def get_poi_between_latitudes(lat_min, lat_max, category_id=None): """ Returns all POI that have their latitudes between lat_min i lat_max :param lat_min: :param lat_max: :param category_id: :return: """ ancestor_key = ndb.Key("FIContent_v1", "POI") if category_id is not None: poi_query = ( POI.query(ancestor=ancestor_key) .filter(POI.lat > lat_min) .filter(POI.lat < lat_max) .filter(POI.categoryID == category_id) ) else: poi_query = POI.query(ancestor=ancestor_key).filter(POI.lat > lat_min).filter(POI.lat < lat_max) return poi_query.fetch(projection=[POI.lat, POI.lon])