--DEBUG: RAISE WARNING '% %',NEW.osm_type,NEW.osm_id;
-- just block these
- IF NEW.class = 'highway' and NEW.type in ('turning_circle','traffic_signals','mini_roundabout','noexit','crossing') THEN
--- RAISE WARNING 'bad highway %',NEW.osm_id;
- RETURN null;
- END IF;
IF NEW.class in ('landuse','natural') and NEW.name is null THEN
-- RAISE WARNING 'empty landuse %',NEW.osm_id;
RETURN null;
ELSEIF NEW.type in ('national_park') THEN
NEW.rank_search := 18;
NEW.rank_address := 18;
- ELSEIF NEW.type in ('suburb','croft','subdivision') THEN
+ ELSEIF NEW.type in ('suburb','croft','subdivision','isolated_dwelling') THEN
NEW.rank_search := 20;
NEW.rank_address := NEW.rank_search;
- ELSEIF NEW.type in ('farm','locality','islet','isolated_dwelling','mountain_pass') THEN
+ ELSEIF NEW.type in ('farm','locality','islet','mountain_pass') THEN
NEW.rank_search := 20;
NEW.rank_address := 0;
-- Irish townlands, tagged as place=locality and locality=townland
END IF;
END IF;
+ END IF;
+
+ -- Name searches can be done for ways as well as relations
+ IF NEW.osm_type in ('W','R') AND NEW.rank_search < 26 THEN
+
-- not found one yet? how about doing a name search
IF NEW.centroid IS NULL AND (NEW.name->'name') is not null and make_standard_name(NEW.name->'name') != '' THEN
INSERT INTO place_addressline VALUES (NEW.place_id, location.place_id, true, location_isaddress, location.distance, location.rank_address);
IF location_isaddress THEN
- address_havelevel[location.rank_address] := true;
- IF NOT location.isguess THEN
- SELECT geometry FROM placex WHERE place_id = location.place_id INTO location_parent;
- END IF;
- END IF;
---RAISE WARNING ' Terms: (%) %',location, nameaddress_vector;
+ address_havelevel[location.rank_address] := true;
+ IF NOT location.isguess THEN
+ SELECT geometry FROM placex WHERE place_id = location.place_id INTO location_parent;
+ END IF;
+
+ IF location.rank_address > parent_place_id_rank THEN
+ NEW.parent_place_id = location.place_id;
+ parent_place_id_rank = location.rank_address;
+ END IF;
- IF location.rank_address > parent_place_id_rank THEN
- NEW.parent_place_id = location.place_id;
- parent_place_id_rank = location.rank_address;
END IF;
+--RAISE WARNING ' Terms: (%) %',location, nameaddress_vector;
+
END IF;
END LOOP;
END IF;
-- Just block these - lots and pointless
- IF NEW.class = 'highway' and NEW.type in ('turning_circle','traffic_signals','mini_roundabout','noexit','crossing') THEN
- RETURN null;
- END IF;
IF NEW.class in ('landuse','natural') and NEW.name is null THEN
RETURN null;
END IF;
IF existingplacex.osm_type IS NULL THEN
IF existing.osm_type IS NOT NULL THEN
+ -- pathological case caused by the triggerless copy into place during initial import
+ -- force delete even for large areas, it will be reinserted later
+ UPDATE place set geometry = ST_SetSRID(ST_Point(0,0), 4326) where osm_type = NEW.osm_type and osm_id = NEW.osm_id and class = NEW.class and type = NEW.type;
DELETE from place where osm_type = NEW.osm_type and osm_id = NEW.osm_id and class = NEW.class and type = NEW.type;
END IF;
country_code = NEW.country_code,
parent_place_id = null,
extratags = NEW.extratags,
- admin_level = NEW.admin_level,
+ admin_level = CASE WHEN NEW.admin_level > 15 THEN 15 ELSE NEW.admin_level END,
indexed_status = 2,
geometry = NEW.geometry
where place_id = existingplacex.place_id;