Skip to content
This repository has been archived by the owner on Jan 9, 2020. It is now read-only.

Commit

Permalink
Change order of functions
Browse files Browse the repository at this point in the history
  • Loading branch information
jirik committed Jun 6, 2017
1 parent 9623dec commit ce739a0
Showing 1 changed file with 36 additions and 36 deletions.
72 changes: 36 additions & 36 deletions language.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,39 @@
CREATE OR REPLACE FUNCTION delete_empty_keys(tags hstore) RETURNS hstore AS $$
DECLARE
result hstore;
BEGIN
select
hstore(array_agg(key), array_agg(value)) into result
from
each(hstore(tags))
where nullif(value, '') is not null;
RETURN result;
END;
$$ STRICT
LANGUAGE plpgsql IMMUTABLE;


CREATE OR REPLACE FUNCTION remove_latin(text) RETURNS text AS $$
DECLARE
i integer;
DECLARE
letter text;
result text = '';
BEGIN
FOR i IN 1..char_length($1) LOOP
letter := substr($1, i, 1);
IF (unaccent(letter) !~ '^[a-zA-Z].*') THEN
result := result || letter;
END IF;
END LOOP;
result := regexp_replace(result, '(\([ -.]*\)|\[[ -.]*\])', '');
result := regexp_replace(result, ' +\. *$', '');
result := trim(both ' -\n' from result);
RETURN result;
END;
$$ LANGUAGE 'plpgsql' IMMUTABLE;


CREATE OR REPLACE FUNCTION get_latin_name(tags hstore, geometry geometry) RETURNS text AS $$
SELECT COALESCE(
CASE
Expand Down Expand Up @@ -54,39 +90,3 @@ BEGIN
END;
$$ STRICT
LANGUAGE plpgsql IMMUTABLE;


CREATE OR REPLACE FUNCTION delete_empty_keys(tags hstore) RETURNS hstore AS $$
DECLARE
result hstore;
BEGIN
select
hstore(array_agg(key), array_agg(value)) into result
from
each(hstore(tags))
where nullif(value, '') is not null;
RETURN result;
END;
$$ STRICT
LANGUAGE plpgsql IMMUTABLE;


CREATE OR REPLACE FUNCTION remove_latin(text) RETURNS text AS $$
DECLARE
i integer;
DECLARE
letter text;
result text = '';
BEGIN
FOR i IN 1..char_length($1) LOOP
letter := substr($1, i, 1);
IF (unaccent(letter) !~ '^[a-zA-Z].*') THEN
result := result || letter;
END IF;
END LOOP;
result := regexp_replace(result, '(\([ -.]*\)|\[[ -.]*\])', '');
result := regexp_replace(result, ' +\. *$', '');
result := trim(both ' -\n' from result);
RETURN result;
END;
$$ LANGUAGE 'plpgsql' IMMUTABLE;

0 comments on commit ce739a0

Please sign in to comment.