#
# Configuration file for OSM import
#
# Customized for OpenOrienteering Mapper
#

# put here the name of keys for ways that are assumed to be polygons if they are closed
# see https://wiki.openstreetmap.org/wiki/Map_Features
closed_ways_are_polygons=aeroway,amenity,boundary,building,craft,geological,historic,landuse,leisure,military,natural,office,place,shop,sport,tourism

# Avoid laundering of keys ( ':' turned into '_' )
attribute_name_laundering=no

# uncomment to report all nodes, including the ones without any (significant) tag
#report_all_nodes=yes

# uncomment to report all ways, including the ones without any (significant) tag
#report_all_ways=yes

[points]
# common attributes
osm_id=yes
osm_version=no
osm_timestamp=yes
osm_uid=no
osm_user=no
osm_changeset=no

# keys to report as OGR fields
attributes=access,aerialway,aeroway,amenity,area,barrier,bridge,building,cycleway,foot,geological,highway,historic,intermittent,landuse,leaf_type,leisure,location,man_made,military,name,natural,pipeline,power,railway,ruins,sport,surface,shop,smoothness,ref,tourism,tracktype,tunnel,waterway,wood:age,wood:density
# keys that, alone, are not significant enough to report a node as a OGR point
unsignificant=created_by,converted_by,source,time,ele,attribution
# keys that should NOT be reported in the "other_tags" field
ignore=created_by,converted_by,source,time,note,openGeoDB:,fixme,FIXME
# uncomment to avoid creation of "other_tags" field
#other_tags=no
# uncomment to create "all_tags" field. "all_tags" and "other_tags" are exclusive
#all_tags=yes

[lines]
# common attributes
osm_id=yes
osm_version=no
osm_timestamp=yes
osm_uid=no
osm_user=no
osm_changeset=no

# keys to report as OGR fields
attributes=access,aerialway,aeroway,amenity,area,barrier,bridge,building,cycleway,foot,geological,highway,historic,intermittent,landuse,leaf_type,leisure,location,man_made,military,name,natural,pipeline,power,railway,ruins,sport,surface,shop,smoothness,ref,tourism,tracktype,tunnel,waterway,wood:age,wood:density

# type of attribute 'foo' can be changed with something like
#foo_type=Integer/Real/String/DateTime

# keys that should NOT be reported in the "other_tags" field
ignore=created_by,converted_by,source,time,note,openGeoDB:,fixme,FIXME
# uncomment to avoid creation of "other_tags" field
#other_tags=no
# uncomment to create "all_tags" field. "all_tags" and "other_tags" are exclusive
#all_tags=yes

#computed_attributes must appear before the keywords _type and _sql
computed_attributes=z_order
z_order_type=Integer
# Formula based on https://github.com/openstreetmap/osm2pgsql/blob/master/style.lua#L13
# [foo] is substituted by value of tag foo. When substitution is not wished, the [ character can be escaped with \[ in literals
z_order_sql="SELECT (CASE [highway] WHEN 'minor' THEN 3 WHEN 'road' THEN 3 WHEN 'unclassified' THEN 3 WHEN 'residential' THEN 3 WHEN 'tertiary_link' THEN 4 WHEN 'tertiary' THEN 4 WHEN 'secondary_link' THEN 6 WHEN 'secondary' THEN 6 WHEN 'primary_link' THEN 7 WHEN 'primary' THEN 7 WHEN 'trunk_link' THEN 8 WHEN 'trunk' THEN 8 WHEN 'motorway_link' THEN 9 WHEN 'motorway' THEN 9 ELSE 0 END) + (CASE WHEN [bridge] IN ('yes', 'true', '1') THEN 10 ELSE 0 END) + (CASE WHEN [tunnel] IN ('yes', 'true', '1') THEN -10 ELSE 0 END) + (CASE WHEN [railway] IS NOT NULL THEN 5 ELSE 0 END) + (CASE WHEN [layer] IS NOT NULL THEN 10 * CAST([layer] AS INTEGER) ELSE 0 END)"

[multipolygons]
# common attributes
# note: for multipolygons, osm_id=yes instantiates a osm_id field for the id of relations
# and a osm_way_id field for the id of closed ways. Both fields are exclusively set.
osm_id=yes
osm_version=no
osm_timestamp=yes
osm_uid=no
osm_user=no
osm_changeset=no

# keys to report as OGR fields
attributes=access,aerialway,aeroway,amenity,area,barrier,bridge,building,cycleway,foot,geological,highway,historic,intermittent,landuse,leaf_type,leisure,location,man_made,military,name,natural,pipeline,power,railway,ruins,sport,surface,shop,smoothness,ref,tourism,tracktype,tunnel,waterway,wood:age,wood:density
# keys that should NOT be reported in the "other_tags" field
ignore=created_by,converted_by,source,time,note,openGeoDB:,fixme,FIXME
# uncomment to avoid creation of "other_tags" field
#other_tags=no
# uncomment to create "all_tags" field. "all_tags" and "other_tags" are exclusive
#all_tags=yes

# GDAL used to have a hard-coded filter which dropped the 'area' tag.
# Cf. https://github.com/OpenOrienteering/mapper/issues/1635
computed_attributes=is_area
is_area_type=String
is_area_sql="SELECT (CASE WHEN [osm_way_id] IS NOT NULL THEN 'yes' ELSE NULL END)"

[multilinestrings]
# common attributes
osm_id=yes
osm_version=no
osm_timestamp=yes
osm_uid=no
osm_user=no
osm_changeset=no

# keys to report as OGR fields
attributes=access,aerialway,aeroway,amenity,area,barrier,bridge,building,cycleway,foot,geological,highway,historic,intermittent,landuse,leaf_type,leisure,location,man_made,military,name,natural,pipeline,power,railway,ruins,sport,surface,shop,smoothness,ref,tourism,tracktype,tunnel,waterway,wood:age,wood:density
# keys that should NOT be reported in the "other_tags" field
ignore=created_by,converted_by,source,time,note,openGeoDB:,fixme,FIXME
# uncomment to avoid creation of "other_tags" field
#other_tags=no
# uncomment to create "all_tags" field. "all_tags" and "other_tags" are exclusive
#all_tags=yes

[other_relations]
# common attributes
osm_id=yes
osm_version=no
osm_timestamp=yes
osm_uid=no
osm_user=no
osm_changeset=no

# keys to report as OGR fields
attributes=access,aerialway,aeroway,amenity,area,barrier,bridge,building,cycleway,foot,geological,highway,historic,intermittent,landuse,leaf_type,leisure,location,man_made,military,name,natural,pipeline,power,railway,ruins,sport,surface,shop,smoothness,ref,tourism,tracktype,tunnel,waterway,wood:age,wood:density
# keys that should NOT be reported in the "other_tags" field
ignore=created_by,converted_by,source,time,note,openGeoDB:,fixme,FIXME
# uncomment to avoid creation of "other_tags" field
#other_tags=no
# uncomment to create "all_tags" field. "all_tags" and "other_tags" are exclusive
#all_tags=yes
