X-Git-Url: https://git.openstreetmap.org/nominatim.git/blobdiff_plain/f3c4196c758a7720aefc26a7043bf1c6553028e2..dbaf215feacb6ca82ec8c1bf3821ba5ebf218778:/lib-sql/functions/address_lookup.sql diff --git a/lib-sql/functions/address_lookup.sql b/lib-sql/functions/address_lookup.sql index b6c552c4..e144e9fd 100644 --- a/lib-sql/functions/address_lookup.sql +++ b/lib-sql/functions/address_lookup.sql @@ -1,3 +1,10 @@ +-- SPDX-License-Identifier: GPL-2.0-only +-- +-- This file is part of Nominatim. (https://nominatim.org) +-- +-- Copyright (C) 2022 by the Nominatim developer community. +-- For a full list of authors see the git log. + -- Functions for returning address information for a place. DROP TYPE IF EXISTS addressline CASCADE; @@ -223,11 +230,13 @@ BEGIN OR placex.country_code = place.country_code) ORDER BY rank_address desc, (place_addressline.place_id = in_place_id) desc, - (fromarea and place.centroid is not null and not isaddress - and (place.address is null or avals(name) && avals(place.address)) - and ST_Contains(geometry, place.centroid)) desc, - isaddress desc, fromarea desc, - distance asc, rank_search desc + (CASE WHEN coalesce((avals(name) && avals(place.address)), False) THEN 2 + WHEN isaddress THEN 0 + WHEN fromarea + and place.centroid is not null + and ST_Contains(geometry, place.centroid) THEN 1 + ELSE -1 END) desc, + fromarea desc, distance asc, rank_search desc LOOP -- RAISE WARNING '%',location; location_isaddress := location.rank_address != current_rank_address;