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_ids INTEGER[];
 
  20   place_centroid := ST_Centroid(pointgeo);
 
  21   out_partition := get_partition(in_countrycode);
 
  22   out_parent_place_id := null;
 
  24   address_street_word_ids := word_ids_from_name(in_street);
 
  25   IF address_street_word_ids IS NOT NULL THEN
 
  26     out_parent_place_id := getNearestNamedRoadPlaceId(out_partition, place_centroid,
 
  27                                                       address_street_word_ids);
 
  30   IF out_parent_place_id IS NULL THEN
 
  31     SELECT getNearestRoadPlaceId(out_partition, place_centroid)
 
  32       INTO out_parent_place_id;
 
  36   out_postcode := in_postcode;
 
  37   IF out_postcode IS NULL THEN
 
  38     SELECT postcode from placex where place_id = out_parent_place_id INTO out_postcode;
 
  40   -- XXX look into postcode table
 
  43   insert into location_property_aux (place_id, partition, parent_place_id,
 
  44                                      housenumber, postcode, centroid)
 
  45     values (nextval('seq_place'), out_partition, out_parent_place_id,
 
  46             in_housenumber, out_postcode, place_centroid);
 
  47   newpoints := newpoints + 1;