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

Commit

Permalink
Create functions for multilinguality
Browse files Browse the repository at this point in the history
  • Loading branch information
jirik committed May 23, 2017
1 parent 587f001 commit 7e6a3a9
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions import_sql.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ function import_sql_files() {

function main() {
echo '\timing' > /root/.psqlrc
exec_psql_file "language.sql"
exec_psql_file "$VT_UTIL_DIR/postgis-vt-util.sql"
import_sql_files
}
Expand Down
30 changes: 30 additions & 0 deletions language.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
CREATE OR REPLACE FUNCTION get_latin_name(tags hstore) RETURNS text AS $$
SELECT COALESCE(
NULLIF(tags->'name:en', ''),
NULLIF(tags->'int_name', ''),
CASE
WHEN tags->'name' ~ '.*[a-zA-Z].*'
THEN tags->'name'
ELSE NULL
END
);
$$ LANGUAGE SQL IMMUTABLE STRICT;


CREATE OR REPLACE FUNCTION get_nonlatin_name(tags hstore) RETURNS text AS $$
SELECT
CASE
WHEN tags->'name' !~ '.*[a-zA-Z].*'
THEN tags->'name'
ELSE NULL
END;
$$ LANGUAGE SQL IMMUTABLE STRICT;

CREATE OR REPLACE FUNCTION get_name_int(tags hstore) RETURNS text AS $$
SELECT
COALESCE(
NULLIF(tags->'int_name', ''),
NULLIF(tags->'name:en', ''),
tags->'name'
);
$$ LANGUAGE SQL IMMUTABLE STRICT;

0 comments on commit 7e6a3a9

Please sign in to comment.