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:
@@ -15,12 +15,23 @@ layer:
|
||||
[`aerodrome`](http://wiki.openstreetmap.org/wiki/Proposed_features/Aerodrome)
|
||||
and `aerodrome:type` tags.
|
||||
values:
|
||||
- international
|
||||
- public
|
||||
- regional
|
||||
- military
|
||||
- private
|
||||
- other
|
||||
international:
|
||||
aerodrome: 'international'
|
||||
aerodrome_type: 'international'
|
||||
public:
|
||||
aerodrome: 'public'
|
||||
aerodrome_type: ['%public%', 'civil']
|
||||
regional:
|
||||
aerodrome: 'regional'
|
||||
aerodrome_type: 'regional'
|
||||
military:
|
||||
aerodrome: 'military'
|
||||
aerodrome_type: '%military%'
|
||||
military: 'airfield'
|
||||
private:
|
||||
aerodrome: 'private'
|
||||
aerodrome_type: 'private'
|
||||
other:
|
||||
iata: 3-character code issued by the IATA.
|
||||
icao: 4-letter code issued by the ICAO.
|
||||
ele: Elevation (`ele`) in meters.
|
||||
|
||||
@@ -27,27 +27,7 @@ $$
|
||||
COALESCE(NULLIF(name_de, ''), name, name_en) AS name_de,
|
||||
tags,
|
||||
CASE
|
||||
WHEN aerodrome = 'international'
|
||||
OR aerodrome_type = 'international'
|
||||
THEN 'international'
|
||||
WHEN
|
||||
aerodrome = 'public'
|
||||
OR aerodrome_type LIKE '%public%'
|
||||
OR aerodrome_type = 'civil'
|
||||
THEN 'public'
|
||||
WHEN
|
||||
aerodrome = 'regional'
|
||||
OR aerodrome_type = 'regional'
|
||||
THEN 'regional'
|
||||
WHEN
|
||||
aerodrome = 'military'
|
||||
OR aerodrome_type LIKE '%military%'
|
||||
OR military = 'airfield'
|
||||
THEN 'military'
|
||||
WHEN
|
||||
aerodrome = 'private'
|
||||
OR aerodrome_type = 'private'
|
||||
THEN 'private'
|
||||
%%FIELD_MAPPING: class %%
|
||||
ELSE 'other'
|
||||
END AS class,
|
||||
NULLIF(iata, '') AS iata,
|
||||
|
||||
Reference in New Issue
Block a user