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

Commit

Permalink
Merge pull request #4 from openmaptiles/multilinguality
Browse files Browse the repository at this point in the history
Create get_basic_names function
  • Loading branch information
jirik authored May 26, 2017
2 parents 1b580ac + a6bd5c0 commit faed18e
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions language.sql
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,28 @@ CREATE OR REPLACE FUNCTION get_name_int(tags hstore) RETURNS text AS $$
tags->'name'
);
$$ LANGUAGE SQL IMMUTABLE STRICT;


CREATE OR REPLACE FUNCTION get_basic_names(tags hstore) RETURNS hstore AS $$
DECLARE
tags_array text[] := ARRAY[]::text[];
name_latin text;
name_nonlatin text;
name_int text;
BEGIN
name_latin := get_latin_name(tags);
name_nonlatin := get_nonlatin_name(tags);
name_int := get_name_int(tags);
IF name_latin IS NOT NULL THEN
tags_array := tags_array || ARRAY['name:latin', name_latin];
END IF;
IF name_nonlatin IS NOT NULL THEN
tags_array := tags_array || ARRAY['name:nonlatin', name_nonlatin];
END IF;
IF name_int IS NOT NULL THEN
tags_array := tags_array || ARRAY['name_int', name_int];
END IF;
RETURN hstore(tags_array);
END;
$$ STRICT
LANGUAGE plpgsql IMMUTABLE;

0 comments on commit faed18e

Please sign in to comment.