From 8b91284f7fe4dd2280484e25673634b78fb9c7c0 Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Sun, 15 May 2016 14:24:43 +0200 Subject: [PATCH] reintroduce addr:place for interpolation It is perfectly valid that interpolated addresses refer to something else than a street. Also gets rid of the maximum interpolation size. As we don't expand, arbitrary sizes are fine. --- sql/functions.sql | 34 ++++++++++++++++++---------------- sql/tables.sql | 1 + 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/sql/functions.sql b/sql/functions.sql index 8f2611d4..3403dfab 100644 --- a/sql/functions.sql +++ b/sql/functions.sql @@ -711,7 +711,7 @@ BEGIN endnumber := substring(nextnode.housenumber,'[0-9]+')::integer; IF startnumber IS NOT NULL AND endnumber IS NOT NULL - AND @(startnumber - endnumber) < 1000 AND startnumber != endnumber + AND startnumber != endnumber AND ST_GeometryType(sectiongeo) = 'ST_LineString' THEN IF (startnumber > endnumber) THEN @@ -722,9 +722,12 @@ BEGIN END IF; insert into location_property_osmline - values (sectiongeo, nextval('seq_place'), partition, wayid, NULL, startnumber, endnumber, - interpolationtype, street, coalesce(prevnode.postcode, defpostalcode), - calculated_country_code, geometry_sector, 2, now()); + values (sectiongeo, nextval('seq_place'), partition, wayid, NULL, + startnumber, endnumber, interpolationtype, + coalesce(street, prevnode.street, nextnode.street), + coalesce(addr_place, prevnode.addr_place, nextnode.addr_place), + coalesce(defpostalcode, prevnode.postcode, nextnode.postcode), + calculated_country_code, geometry_sector, 2, now()); END IF; -- early break if we are out of line string, @@ -1072,21 +1075,20 @@ BEGIN delete from location_property_osmline where place_id = OLD.place_id; RETURN NULL; END IF; - + IF NEW.indexed_status != 0 OR OLD.indexed_status = 0 THEN RETURN NEW; END IF; - - IF OLD.indexed_status = 2 and NEW.indexed_status=0 THEN - -- do the reparenting: (finally here, because ALL places in placex, that are needed for reparenting, need to be up to date) - -- (the osm interpolationline in location_property_osmline was marked for reparenting in placex_insert/placex_delete with index_status = 2 - -- => index.c: sets index_status back to 0 - -- => triggers this function) - place_centroid := ST_PointOnSurface(NEW.linegeo); - -- marking descendants for reparenting is not needed, because there are actually no descendants for interpolation lines - NEW.parent_place_id = get_interpolation_parent(NEW.osm_id, NEW.street, null, NEW.partition, place_centroid, NEW.linegeo); -- addr_place (3rd param) is not necessarily needed - return NEW; - END IF; + + -- do the reparenting: (finally here, because ALL places in placex, that are needed for reparenting, need to be up to date) + -- (the osm interpolationline in location_property_osmline was marked for reparenting in placex_insert/placex_delete with index_status = 1 or 2 (1 inset, 2 delete) + -- => index.c: sets index_status back to 0 + -- => triggers this function) + place_centroid := ST_PointOnSurface(NEW.linegeo); + -- marking descendants for reparenting is not needed, because there are actually no descendants for interpolation lines + NEW.parent_place_id = get_interpolation_parent(NEW.osm_id, NEW.street, NEW.addr_place, + NEW.partition, place_centroid, NEW.linegeo); + return NEW; END; $$ LANGUAGE plpgsql; diff --git a/sql/tables.sql b/sql/tables.sql index 75129ce8..19398eb5 100644 --- a/sql/tables.sql +++ b/sql/tables.sql @@ -95,6 +95,7 @@ CREATE TABLE location_property_osmline ( endnumber INTEGER, interpolationtype TEXT, street TEXT, + addr_place TEXT, postcode TEXT, calculated_country_code VARCHAR(2), geometry_sector INTEGER, -- 2.39.5