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:
@@ -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;
|
||||
|
||||
@@ -14,9 +14,12 @@ layer:
|
||||
All water polygons from [OpenStreetMapData](http://osmdata.openstreetmap.de/) have the class `ocean`.
|
||||
Water bodies are classified as `lake` or `river` for water bodies with the [`waterway`](http://wiki.openstreetmap.org/wiki/Key:waterway) tag.
|
||||
values:
|
||||
- ocean
|
||||
- lake
|
||||
- river
|
||||
lake:
|
||||
waterway: ['', 'lake']
|
||||
dock:
|
||||
waterway: 'dock'
|
||||
river:
|
||||
ocean:
|
||||
intermittent:
|
||||
description: |
|
||||
Mark with `1` if it is an [intermittent](http://wiki.openstreetmap.org/wiki/Key:intermittent) water polygon.
|
||||
|
||||
Reference in New Issue
Block a user