Manage field mapping in SQL declaratively

Simplify some of the OSM->OMT field value mappings using declarative syntax.

This approach is not for all cases, but in many it removes
the need of storing the same field in both the .yaml and .sql files.

TODO: support more complex AND/OR cases
This commit is contained in:
Yuri Astrakhan
2019-10-26 04:28:51 -04:00
parent f3667170f6
commit 1614a4656c
10 changed files with 156 additions and 120 deletions

View File

@@ -1,8 +1,6 @@
CREATE OR REPLACE FUNCTION water_class(waterway TEXT) RETURNS TEXT AS $$
SELECT CASE
WHEN waterway='' THEN 'lake'
WHEN waterway='lake' THEN 'lake'
WHEN waterway='dock' THEN 'dock'
%%FIELD_MAPPING: class %%
ELSE 'river'
END;
$$ LANGUAGE SQL IMMUTABLE;