IF addr_street is null and addr_place is null THEN
select nodes from planet_osm_ways where id = wayid INTO waynodes;
- FOR location IN SELECT street, addr_place from placex
- where osm_type = 'N' and osm_id = ANY(nodes)
- and (street is not null or addr_place is not null)
+ FOR location IN SELECT placex.street, placex.addr_place from placex
+ where osm_type = 'N' and osm_id = ANY(waynodes)
+ and (placex.street is not null or placex.addr_place is not null)
and indexed_status < 100
limit 1 LOOP
addr_street = location.street;
END LOOP;
END IF;
+ IF parent_place_id is null THEN
+ RETURN 0;
+ END IF;
+
RETURN parent_place_id;
END;
$$
-- Ignore all nodes marked for deletion. (Might happen when the type changes.)
select * from placex where osm_type = 'N' and osm_id = waynodes[nodeidpos]::BIGINT
and indexed_status < 100
- order by (type = 'house'),place_id limit 1 INTO nextnode;
+ order by (type = 'address'),place_id limit 1 INTO nextnode;
IF nextnode.place_id IS NOT NULL THEN
IF nodeidpos > 1 and nodeidpos < array_upper(waynodes, 1) THEN
startnumber := startnumber + stepsize;
-- correct for odd/even
- IF (interpolationtype = 'odd' AND startnumber%2 = 0) OR (interpolationtype = 'even' AND startnumber%2 = 1) THEN
+ IF (interpolationtype = 'odd' AND startnumber%2 = 0)
+ OR (interpolationtype = 'even' AND startnumber%2 = 1) THEN
startnumber := startnumber - 1;
END IF;
endnumber := endnumber - 1;
- delete from placex where osm_type = 'N' and osm_id = prevnode.osm_id and type = 'house' and place_id != prevnode.place_id;
+ delete from placex where osm_type = 'N' and osm_id = prevnode.osm_id
+ and place_id != prevnode.place_id;
FOR housenum IN startnumber..endnumber BY stepsize LOOP
- -- this should really copy postcodes but it puts a huge burden on
- -- the system for no big benefit ideally postcodes should move up to the way
- insert into placex (place_id, partition, osm_type, osm_id, class, type, admin_level,
- housenumber, street, addr_place, isin, postcode,
- country_code, parent_place_id, rank_address, rank_search,
- indexed_status, geometry)
- values (nextval('seq_place'), partition, 'N', prevnode.osm_id, 'place', 'house', prevnode.admin_level,
- housenum, prevnode.street, prevnode.addr_place, prevnode.isin, coalesce(prevnode.postcode, defpostalcode),
- prevnode.country_code, prevnode.parent_place_id, prevnode.rank_address, prevnode.rank_search,
- 0, ST_LineInterpolatePoint(sectiongeo, (housenum::float-orginalstartnumber::float)/originalnumberrange::float));
+ insert into placex (place_id, partition, osm_type, osm_id,
+ class, type, admin_level, housenumber,
+ postcode,
+ country_code, parent_place_id, rank_address, rank_search,
+ indexed_status, indexed_date, geometry_sector,
+ geometry)
+ values (nextval('seq_place'), partition, 'N', prevnode.osm_id,
+ 'place', 'address', prevnode.admin_level, housenum,
+ coalesce(prevnode.postcode, defpostalcode),
+ prevnode.country_code, parent_place_id, 30, 30,
+ 0, now(), geometry_sector, calculated_country_code,
+ ST_LineInterpolatePoint(sectiongeo, (housenum::float-orginalstartnumber::float)/originalnumberrange::float));
newpoints := newpoints + 1;
--RAISE WARNING 'interpolation number % % ',prevnode.place_id,housenum;
END LOOP;
BEGIN
--DEBUG: RAISE WARNING '% %',NEW.osm_type,NEW.osm_id;
- IF place_id is not null THEN
- RETURN NEW; -- already indexed (happens for interpolated addresses
+ -- ignore interpolated addresses
+ IF NEW.class = 'place' and NEW.type = 'address' THEN
+ RETURN NEW;
END IF;
-- just block these
RETURN NEW;
END IF;
+ -- ignore interpolated addresses
+ IF NEW.class = 'place' and NEW.type = 'address' THEN
+ RETURN NEW;
+ END IF;
+
--DEBUG: RAISE WARNING 'placex_update % %',NEW.osm_type,NEW.osm_id;
--RAISE WARNING '%',NEW.place_id;
-- interpolations XXXXX
IF NEW.class = 'place' AND NEW.type = 'houses'THEN
- IF osm_type = 'W' and ST_GeometryType(NEW.geometry) = 'ST_LineString' THEN
+ IF NEW.osm_type = 'W' and ST_GeometryType(NEW.geometry) = 'ST_LineString' THEN
NEW.parent_place_id := get_interpolation_parent(NEW.osm_id, NEW.street, NEW.addr_place,
NEW.partition, place_centroid, NEW.geometry);
- IF NEW.parent_place_id is not null THEN
- i := create_interpolation(NEW.osm_id, NEW.housenumber);
- END IF;
+ i := create_interpolation(NEW.osm_id, NEW.housenumber);
END IF;
RETURN NEW;
END IF;