X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/b2cca7cea1b39eb8dda4d066a666a22544fd8752..6f442b6617dc30729b7657f3e5e6e5dfb57e6ac0:/sql/functions.sql diff --git a/sql/functions.sql b/sql/functions.sql index bd64697a..b88a7f81 100644 --- a/sql/functions.sql +++ b/sql/functions.sql @@ -1161,7 +1161,8 @@ BEGIN DELETE FROM place_addressline WHERE place_id = NEW.place_id; result := deleteRoad(NEW.partition, NEW.place_id); result := deleteLocationArea(NEW.partition, NEW.place_id, NEW.rank_search); - UPDATE placex set linked_place_id = null where linked_place_id = NEW.place_id; + UPDATE placex set linked_place_id = null, indexed_status = 2 + where linked_place_id = NEW.place_id; IF NEW.linked_place_id is not null THEN RETURN NEW; @@ -2183,7 +2184,8 @@ END; $$ LANGUAGE plpgsql; -CREATE OR REPLACE FUNCTION get_address_by_language(for_place_id BIGINT, languagepref TEXT[]) RETURNS TEXT +--housenumber only needed for tiger data +CREATE OR REPLACE FUNCTION get_address_by_language(for_place_id BIGINT, housenumber INTEGER, languagepref TEXT[]) RETURNS TEXT AS $$ DECLARE result TEXT[]; @@ -2195,7 +2197,7 @@ BEGIN result := '{}'; prevresult := ''; - FOR location IN select * from get_addressdata(for_place_id) where isaddress order by rank_address desc LOOP + FOR location IN select * from get_addressdata(for_place_id, housenumber) where isaddress order by rank_address desc LOOP currresult := trim(get_name_by_language(location.name, languagepref)); IF currresult != prevresult AND currresult IS NOT NULL AND result[(100 - location.rank_address)] IS NULL THEN result[(100 - location.rank_address)] := trim(get_name_by_language(location.name, languagepref)); @@ -2223,10 +2225,10 @@ create type addressline as ( distance FLOAT ); -CREATE OR REPLACE FUNCTION get_addressdata(in_place_id BIGINT) RETURNS setof addressline +CREATE OR REPLACE FUNCTION get_addressdata(in_place_id BIGINT, in_housenumber INTEGER) RETURNS setof addressline AS $$ DECLARE - for_place_id BIGINT; + for_place_id BIGINT;--parent_place_id result TEXT[]; search TEXT[]; found INTEGER; @@ -2242,11 +2244,14 @@ DECLARE countryname HSTORE; hadcountry BOOLEAN; BEGIN - - select parent_place_id,'us', housenumber, 30, postcode, null, 'place', 'house' from location_property_tiger - WHERE place_id = in_place_id - INTO for_place_id,searchcountrycode, searchhousenumber, searchrankaddress, searchpostcode, searchhousename, searchclass, searchtype; - + --first query tiger data + select parent_place_id,'us', 30, postcode, null, 'place', 'house' from location_property_tiger + WHERE place_id = in_place_id AND in_housenumber>=startnumber AND in_housenumber <= endnumber + INTO for_place_id,searchcountrycode, searchrankaddress, searchpostcode, searchhousename, searchclass, searchtype; + IF for_place_id IS NOT NULL THEN + searchhousenumber = in_housenumber::text; + END IF; + IF for_place_id IS NULL THEN select parent_place_id,'us', housenumber, 30, postcode, null, 'place', 'house' from location_property_aux WHERE place_id = in_place_id