X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/0deb9262c952d65ea673eb7e0bd0282230101f9c..5011fde1769338135329004b91fbace6d7a2660b:/nominatim/api/v1/helpers.py diff --git a/nominatim/api/v1/helpers.py b/nominatim/api/v1/helpers.py index ea7c125d..13087280 100644 --- a/nominatim/api/v1/helpers.py +++ b/nominatim/api/v1/helpers.py @@ -83,7 +83,7 @@ def extend_query_parts(queryparts: Dict[str, Any], details: Dict[str, Any], if parsed.countries: queryparts['countrycodes'] = ','.join(parsed.countries) queryparts['exclude_place_ids'] = \ - ','.join(chain(excluded, map(str, parsed.excluded))) + ','.join(chain(excluded, map(str, (e for e in parsed.excluded if e > 0)))) if parsed.viewbox: queryparts['viewbox'] = ','.join(f"{c:.7g}" for c in parsed.viewbox.coords) if parsed.bounded_viewbox: @@ -108,15 +108,18 @@ def deduplicate_results(results: SearchResults, max_results: int) -> SearchResul assert result.names and 'ref' in result.names if any(_is_postcode_relation_for(r, result.names['ref']) for r in results): continue - classification = (result.osm_object[0] if result.osm_object else None, - result.category, - result.display_name, - result.rank_address) - if result.osm_object not in osm_ids_done \ - and classification not in classification_done: + if result.source_table == SourceTable.PLACEX: + classification = (result.osm_object[0] if result.osm_object else None, + result.category, + result.display_name, + result.rank_address) + if result.osm_object not in osm_ids_done \ + and classification not in classification_done: + deduped.append(result) + osm_ids_done.add(result.osm_object) + classification_done.add(classification) + else: deduped.append(result) - osm_ids_done.add(result.osm_object) - classification_done.add(classification) if len(deduped) >= max_results: break @@ -136,10 +139,10 @@ def _deg(axis:str) -> str: return f"(?P<{axis}_deg>\\d+\\.\\d+)°?" def _deg_min(axis: str) -> str: - return f"(?P<{axis}_deg>\\d+)[°\\s]+(?P<{axis}_min>[\\d.]+)?[â²']*" + return f"(?P<{axis}_deg>\\d+)[°\\s]+(?P<{axis}_min>[\\d.]+)[â²']*" def _deg_min_sec(axis: str) -> str: - return f"(?P<{axis}_deg>\\d+)[°\\s]+(?P<{axis}_min>\\d+)[â²'\\s]+(?P<{axis}_sec>[\\d.]+)?[\"â³]*" + return f"(?P<{axis}_deg>\\d+)[°\\s]+(?P<{axis}_min>\\d+)[â²'\\s]+(?P<{axis}_sec>[\\d.]+)[\"â³]*" COORD_REGEX = [re.compile(r'(?:(?P
.*?)\s+)??' + r + r'(?:\s+(?P.*))?') for r in ( r"(?P [NS])\s*" + _deg('lat') + r"[\s,]+" + r"(?P [EW])\s*" + _deg('lon'),