def get_places_bbox(bbox, es: Elasticsearch, indices: IndexNames, settings: Settings, query_params: http.QueryParams): raw_params = dict(query_params) if 'raw_filter' in query_params: raw_params['raw_filter'] = query_params.get_list('raw_filter') try: params = PlacesQueryParam(**raw_params) except ValidationError as e: logger.warning(f"Validation Error: {e.json()}") raise BadRequest(detail={"message": e.errors()}) bbox_places = fetch_bbox_places(es, indices, categories=params.raw_filter, bbox=params.bbox, max_size=params.size) places_list = [] for p in bbox_places: poi = POI.load_place(p['_source'], params.lang, settings, params.verbosity) places_list.append(poi) return {"places": places_list}
def gquery(params: http.QueryParams) -> list: try: fopen = open(fields["fpgroup"], "r") except: b = exceptions.NotFound() b.default_detail = "Bad group file path" raise b retlist = [] if (not params._list): raise exceptions.BadRequest() ##Empty for line in fopen.read().splitlines(): f = line.split(":") f.pop(1) for i, gfield in enumerate(f): if (i == len(f) - 1): #last element is always member check f[-1] = f[-1].split(",") if (params._dict.get("member")): qmems = params.get_list("member") #get list of members if (len(qmems) > len(f[-1])): break if (len(set(qmems) & set(f[-1])) != len(qmems)): break retlist.append(dict(zip(groupf, f))) if (params.get(groupf[i]) and params.get(groupf[i]) != gfield): break return retlist