1 -- Functions for adding external data (currently unused).
3 CREATE OR REPLACE FUNCTION aux_create_property(pointgeo GEOMETRY, in_housenumber TEXT,
4 in_street TEXT, in_isin TEXT,
5 in_postcode TEXT, in_countrycode char(2))
11 place_centroid GEOMETRY;
12 out_partition INTEGER;
13 out_parent_place_id BIGINT;
15 address_street_word_id INTEGER;
20 place_centroid := ST_Centroid(pointgeo);
21 out_partition := get_partition(in_countrycode);
22 out_parent_place_id := null;
24 address_street_word_id := get_name_id(make_standard_name(in_street));
25 IF address_street_word_id IS NOT NULL THEN
26 FOR location IN SELECT * from getNearestNamedRoadFeature(out_partition, place_centroid, address_street_word_id) LOOP
27 out_parent_place_id := location.place_id;
31 IF out_parent_place_id IS NULL THEN
32 FOR location IN SELECT place_id FROM getNearestRoadFeature(out_partition, place_centroid) LOOP
33 out_parent_place_id := location.place_id;
37 out_postcode := in_postcode;
38 IF out_postcode IS NULL THEN
39 SELECT postcode from placex where place_id = out_parent_place_id INTO out_postcode;
41 -- XXX look into postcode table
44 insert into location_property_aux (place_id, partition, parent_place_id,
45 housenumber, postcode, centroid)
46 values (nextval('seq_place'), out_partition, out_parent_place_id,
47 in_housenumber, out_postcode, place_centroid);
48 newpoints := newpoints + 1;