END IF;
ELSEIF NEW.class = 'place' THEN
- IF NEW.type in ('continent') THEN
- NEW.rank_search := 2;
- NEW.rank_address := NEW.rank_search;
- NEW.country_code := NULL;
- ELSEIF NEW.type in ('sea') THEN
+ IF NEW.type in ('continent', 'sea') THEN
NEW.rank_search := 2;
NEW.rank_address := 0;
NEW.country_code := NULL;
ELSEIF NEW.type in ('country') THEN
NEW.rank_search := 4;
- NEW.rank_address := NEW.rank_search;
+ IF ST_GeometryType(NEW.geometry) IN ('ST_Polygon','ST_MultiPolygon') THEN
+ NEW.rank_address := NEW.rank_search;
+ ELSE
+ NEW.rank_address := 0;
+ END IF;
ELSEIF NEW.type in ('state') THEN
NEW.rank_search := 8;
- NEW.rank_address := NEW.rank_search;
+ IF ST_GeometryType(NEW.geometry) IN ('ST_Polygon','ST_MultiPolygon') THEN
+ NEW.rank_address := NEW.rank_search;
+ ELSE
+ NEW.rank_address := 0;
+ END IF;
ELSEIF NEW.type in ('region') THEN
NEW.rank_search := 18; -- dropped from previous value of 10
NEW.rank_address := 0; -- So badly miss-used that better to just drop it!
select placex.place_id, osm_type, osm_id, name,
CASE WHEN extratags ? 'place' THEN 'place' ELSE class END as class,
CASE WHEN extratags ? 'place' THEN extratags->'place' ELSE type END as type,
- admin_level, fromarea, isaddress,
+ admin_level, fromarea, isaddress and linked_place_id is NULL as isaddress,
CASE WHEN address_place_id = for_place_id AND rank_address = 0 THEN 100 WHEN rank_address = 11 THEN 5 ELSE rank_address END as rank_address,
distance,country_code,postcode
from place_addressline join placex on (address_place_id = placex.place_id)