$$
LANGUAGE plpgsql IMMUTABLE;
-CREATE OR REPLACE FUNCTION get_word_score(wordscores wordscore[], words text[]) RETURNS integer
- AS $$
-DECLARE
- idxword integer;
- idxscores integer;
- result integer;
-BEGIN
- IF (wordscores is null OR words is null) THEN
- RETURN 0;
- END IF;
-
- result := 0;
- FOR idxword in 1 .. array_upper(words, 1) LOOP
- FOR idxscores in 1 .. array_upper(wordscores, 1) LOOP
- IF wordscores[idxscores].word = words[idxword] THEN
- result := result + wordscores[idxscores].score;
- END IF;
- END LOOP;
- END LOOP;
-
- RETURN result;
-END;
-$$
-LANGUAGE plpgsql IMMUTABLE;
-
CREATE OR REPLACE FUNCTION get_country_code(place geometry) RETURNS TEXT
AS $$
DECLARE
search_maxdistance FLOAT[];
search_mindistance FLOAT[];
address_havelevel BOOLEAN[];
--- search_scores wordscore[];
--- search_scores_pos INTEGER;
i INTEGER;
iMax FLOAT;
$$
LANGUAGE plpgsql IMMUTABLE;
---CREATE OR REPLACE FUNCTION get_connected_ways(way_ids INTEGER[]) RETURNS SETOF planet_osm_ways
--- AS $$
---DECLARE
--- searchnodes INTEGER[];
--- location RECORD;
--- j INTEGER;
---BEGIN
---
--- searchnodes := '{}';
--- FOR j IN 1..array_upper(way_ids, 1) LOOP
--- FOR location IN
--- select nodes from planet_osm_ways where id = way_ids[j] LIMIT 1
--- LOOP
--- IF not (ARRAY[location.nodes] <@ searchnodes) THEN
--- searchnodes := searchnodes || location.nodes;
--- END IF;
--- END LOOP;
--- END LOOP;
---
--- RETURN QUERY select * from planet_osm_ways where nodes && searchnodes and NOT ARRAY[id] <@ way_ids;
---END;
---$$
---LANGUAGE plpgsql IMMUTABLE;
CREATE OR REPLACE FUNCTION get_address_postcode(for_place_id BIGINT) RETURNS TEXT
AS $$