mirror of
https://github.com/osm-search/Nominatim.git
synced 2024-12-18 10:32:08 +03:00
improve calculation of postcode for interpolations
This commit is contained in:
parent
53f8459e97
commit
413c69ddc9
@ -1043,8 +1043,8 @@ DECLARE
|
|||||||
linegeo GEOMETRY;
|
linegeo GEOMETRY;
|
||||||
splitline GEOMETRY;
|
splitline GEOMETRY;
|
||||||
sectiongeo GEOMETRY;
|
sectiongeo GEOMETRY;
|
||||||
|
interpol_postcode TEXT;
|
||||||
postcode TEXT;
|
postcode TEXT;
|
||||||
seg_postcode TEXT;
|
|
||||||
BEGIN
|
BEGIN
|
||||||
-- deferred delete
|
-- deferred delete
|
||||||
IF OLD.indexed_status = 100 THEN
|
IF OLD.indexed_status = 100 THEN
|
||||||
@ -1063,9 +1063,11 @@ BEGIN
|
|||||||
NEW.address->'place',
|
NEW.address->'place',
|
||||||
NEW.partition, place_centroid, NEW.linegeo);
|
NEW.partition, place_centroid, NEW.linegeo);
|
||||||
|
|
||||||
|
IF NEW.address is not NULL AND NEW.address ? 'postcode' AND NEW.address->'postcode' not similar to '%(,|;)%' THEN
|
||||||
IF NEW.address is not NULL and NEW.address ? 'postcode' THEN
|
interpol_postcode := NEW.address->'postcode';
|
||||||
NEW.postcode = NEW.address->'postcode';
|
housenum := getorcreate_postcode_id(NEW.address->'postcode');
|
||||||
|
ELSE
|
||||||
|
interpol_postcode := NULL;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
-- if the line was newly inserted, split the line as necessary
|
-- if the line was newly inserted, split the line as necessary
|
||||||
@ -1078,7 +1080,6 @@ BEGIN
|
|||||||
|
|
||||||
linegeo := NEW.linegeo;
|
linegeo := NEW.linegeo;
|
||||||
startnumber := NULL;
|
startnumber := NULL;
|
||||||
postcode := NEW.postcode;
|
|
||||||
|
|
||||||
FOR nodeidpos in 1..array_upper(waynodes, 1) LOOP
|
FOR nodeidpos in 1..array_upper(waynodes, 1) LOOP
|
||||||
|
|
||||||
@ -1111,15 +1112,24 @@ BEGIN
|
|||||||
sectiongeo := ST_Reverse(sectiongeo);
|
sectiongeo := ST_Reverse(sectiongeo);
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
seg_postcode := coalesce(postcode,
|
-- determine postcode
|
||||||
prevnode.address->'postcode',
|
postcode := coalesce(interpol_postcode,
|
||||||
nextnode.address->'postcode');
|
prevnode.address->'postcode',
|
||||||
|
nextnode.address->'postcode',
|
||||||
|
postcode);
|
||||||
|
|
||||||
|
IF postcode is NULL THEN
|
||||||
|
SELECT placex.postcode FROM placex WHERE place_id = NEW.parent_place_id INTO postcode;
|
||||||
|
END IF;
|
||||||
|
IF postcode is NULL THEN
|
||||||
|
postcode := get_nearest_postcode(NEW.country_code, nextnode.geometry);
|
||||||
|
END IF;
|
||||||
|
|
||||||
IF NEW.startnumber IS NULL THEN
|
IF NEW.startnumber IS NULL THEN
|
||||||
NEW.startnumber := startnumber;
|
NEW.startnumber := startnumber;
|
||||||
NEW.endnumber := endnumber;
|
NEW.endnumber := endnumber;
|
||||||
NEW.linegeo := sectiongeo;
|
NEW.linegeo := sectiongeo;
|
||||||
NEW.postcode := seg_postcode;
|
NEW.postcode := postcode;
|
||||||
ELSE
|
ELSE
|
||||||
insert into location_property_osmline
|
insert into location_property_osmline
|
||||||
(linegeo, partition, osm_id, parent_place_id,
|
(linegeo, partition, osm_id, parent_place_id,
|
||||||
@ -1128,7 +1138,7 @@ BEGIN
|
|||||||
geometry_sector, indexed_status)
|
geometry_sector, indexed_status)
|
||||||
values (sectiongeo, NEW.partition, NEW.osm_id, NEW.parent_place_id,
|
values (sectiongeo, NEW.partition, NEW.osm_id, NEW.parent_place_id,
|
||||||
startnumber, endnumber, NEW.interpolationtype,
|
startnumber, endnumber, NEW.interpolationtype,
|
||||||
NEW.address, seg_postcode,
|
NEW.address, postcode,
|
||||||
NEW.country_code, NEW.geometry_sector, 0);
|
NEW.country_code, NEW.geometry_sector, 0);
|
||||||
END IF;
|
END IF;
|
||||||
END IF;
|
END IF;
|
||||||
|
Loading…
Reference in New Issue
Block a user