- ELSEIF NEW.rank_search < 18 THEN
- diameter := 0.1;
- ELSEIF NEW.rank_search < 20 THEN
- diameter := 0.05;
- ELSEIF NEW.rank_search = 21 THEN
- diameter := 0.001;
- ELSEIF NEW.rank_search < 24 THEN
- diameter := 0.02;
- ELSEIF NEW.rank_search < 26 THEN
- diameter := 0.002; -- 100 to 200 meters
- ELSEIF NEW.rank_search < 28 THEN
- diameter := 0.001; -- 50 to 100 meters
- END IF;
- IF diameter > 0 THEN
--- RAISE WARNING 'placex point insert: % % % % %',NEW.osm_type,NEW.osm_id,NEW.class,NEW.type,diameter;
- IF NEW.rank_search >= 26 THEN
- -- roads may cause reparenting for >27 rank places
- update placex set indexed_status = 2 where indexed_status = 0 and rank_search > NEW.rank_search and ST_DWithin(placex.geometry, NEW.geometry, diameter);
- ELSEIF NEW.rank_search >= 16 THEN
- -- up to rank 16, street-less addresses may need reparenting
- update placex set indexed_status = 2 where indexed_status = 0 and rank_search > NEW.rank_search and ST_DWithin(placex.geometry, NEW.geometry, diameter) and (rank_search < 28 or name is not null or addr_place is not null);
- ELSE
- -- for all other places the search terms may change as well
- update placex set indexed_status = 2 where indexed_status = 0 and rank_search > NEW.rank_search and ST_DWithin(placex.geometry, NEW.geometry, diameter) and (rank_search < 28 or name is not null);
+ -- 16 = city, anything higher than city is effectively ignored (polygon required!)
+ IF NEW.type='postcode' THEN
+ diameter := 0.05;
+ ELSEIF NEW.rank_search < 16 THEN
+ diameter := 0;
+ ELSEIF NEW.rank_search < 18 THEN
+ diameter := 0.1;
+ ELSEIF NEW.rank_search < 20 THEN
+ diameter := 0.05;
+ ELSEIF NEW.rank_search = 21 THEN
+ diameter := 0.001;
+ ELSEIF NEW.rank_search < 24 THEN
+ diameter := 0.02;
+ ELSEIF NEW.rank_search < 26 THEN
+ diameter := 0.002; -- 100 to 200 meters
+ ELSEIF NEW.rank_search < 28 THEN
+ diameter := 0.001; -- 50 to 100 meters
+ END IF;
+ IF diameter > 0 THEN
+ -- RAISE WARNING 'placex point insert: % % % % %',NEW.osm_type,NEW.osm_id,NEW.class,NEW.type,diameter;
+ IF NEW.rank_search >= 26 THEN
+ -- roads may cause reparenting for >27 rank places
+ update placex set indexed_status = 2 where indexed_status = 0 and rank_search > NEW.rank_search and ST_DWithin(placex.geometry, NEW.geometry, diameter);
+ ELSEIF NEW.rank_search >= 16 THEN
+ -- up to rank 16, street-less addresses may need reparenting
+ update placex set indexed_status = 2 where indexed_status = 0 and rank_search > NEW.rank_search and ST_DWithin(placex.geometry, NEW.geometry, diameter) and (rank_search < 28 or name is not null or addr_place is not null);
+ ELSE
+ -- for all other places the search terms may change as well
+ update placex set indexed_status = 2 where indexed_status = 0 and rank_search > NEW.rank_search and ST_DWithin(placex.geometry, NEW.geometry, diameter) and (rank_search < 28 or name is not null);
+ END IF;