X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/7879ad44cd1e36ae1235c3dcdfd9e477491813e4..b03be15442502aa2e52bacff70fb983cf4397d70:/sql/functions.sql diff --git a/sql/functions.sql b/sql/functions.sql index 66b53d51..80763eaa 100644 --- a/sql/functions.sql +++ b/sql/functions.sql @@ -1,3 +1,15 @@ +-- Splits the line at the given point and returns the two parts +-- in a multilinestring. +CREATE OR REPLACE FUNCTION split_line_on_node(line GEOMETRY, point GEOMETRY) +RETURNS GEOMETRY + AS $$ +BEGIN + RETURN ST_Split(ST_Snap(line, point, 0.0005), point); +END; +$$ +LANGUAGE plpgsql; + + CREATE OR REPLACE FUNCTION geometry_sector(partition INTEGER, place geometry) RETURNS INTEGER AS $$ DECLARE @@ -990,7 +1002,7 @@ BEGIN --DEBUG: RAISE WARNING 'placex_insert:END: % % % %',NEW.osm_type,NEW.osm_id,NEW.class,NEW.type; - RETURN NEW; -- @DIFFUPDATES@ The following is not needed until doing diff updates, and slows the main index process down + RETURN NEW; -- %DIFFUPDATES% The following is not needed until doing diff updates, and slows the main index process down IF NEW.rank_address > 0 THEN IF (ST_GeometryType(NEW.geometry) in ('ST_Polygon','ST_MultiPolygon') AND ST_IsValid(NEW.geometry)) THEN @@ -1606,6 +1618,7 @@ BEGIN NEW.parent_place_id = 0; parent_place_id_rank = 0; + -- convert isin to array of tokenids isin_tokens := '{}'::int[]; IF NEW.isin IS NOT NULL THEN @@ -1645,6 +1658,7 @@ BEGIN END IF; END IF; + -- %NOTIGERDATA% IF 0 THEN -- for the USA we have an additional address table. Merge in zip codes from there too IF NEW.rank_search = 26 AND NEW.calculated_country_code = 'us' THEN FOR location IN SELECT distinct postcode from location_property_tiger where parent_place_id = NEW.place_id LOOP @@ -1657,6 +1671,7 @@ BEGIN nameaddress_vector := array_merge(nameaddress_vector, ARRAY[address_street_word_id]); END LOOP; END IF; + -- %NOTIGERDATA% END IF; -- RAISE WARNING 'ISIN: %', isin_tokens; @@ -2315,7 +2330,6 @@ DECLARE countryname HSTORE; hadcountry BOOLEAN; BEGIN - -- first query osmline (interpolation lines) select parent_place_id, calculated_country_code, 30, postcode, null, 'place', 'house' from location_property_osmline WHERE place_id = in_place_id AND in_housenumber>=startnumber AND in_housenumber <= endnumber @@ -2323,8 +2337,9 @@ BEGIN IF for_place_id IS NOT NULL THEN searchhousenumber = in_housenumber::text; END IF; - + --then query tiger data + -- %NOTIGERDATA% IF 0 THEN IF for_place_id IS NULL THEN 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 @@ -2333,13 +2348,16 @@ BEGIN searchhousenumber = in_housenumber::text; END IF; END IF; - + -- %NOTIGERDATA% END IF; + + -- %NOAUXDATA% IF 0 THEN 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 INTO for_place_id,searchcountrycode, searchhousenumber, searchrankaddress, searchpostcode, searchhousename, searchclass, searchtype; END IF; - + -- %NOAUXDATA% END IF; + IF for_place_id IS NULL THEN select parent_place_id, calculated_country_code, housenumber, rank_search, postcode, name, class, type from placex WHERE place_id = in_place_id and rank_address = 30