1 -- Defines defaults used in the topic definitions.
 
   7 local function group_merge(group1, group2)
 
   8     for name, values in pairs(group2) do
 
   9         if group1[name] == nil then
 
  12             for _, v in pairs(values) do
 
  13                 table.insert(group1[name], v)
 
  21 -- Customized main tag filter functions
 
  23 local EXCLUDED_FOOTWAYS = { sidewalk = 1, crossing = 1, link = 1, traffic_aisle }
 
  25 local function filter_footways(place)
 
  26     if place.has_name then
 
  27         local footway = place.object.tags.footway
 
  28         if footway == nil or EXCLUDED_FOOTWAYS[footway] ~= 1 then
 
  35 local function include_when_tag_present(key, value, named)
 
  37         return function(place)
 
  38                    if place.has_name and place.intags[key] == value then
 
  44         return function(place)
 
  45                    if place.intags[key] == value then
 
  53 local function exclude_when_key_present(key, named)
 
  55         return function(place)
 
  56                    if place.has_name and place.intags[key] == nil then
 
  62         return function(place)
 
  63                    if place.intags[key] == nil then
 
  72 local function lock_transform(place)
 
  73     if place.object.tags.waterway ~= nil then
 
  74         local name = place.object.tags.lock_name
 
  76             return place:clone{names={name=name, ref=place.object.tags.lock_ref}}
 
  83 -- Main tag definition
 
  87 module.MAIN_TAGS.admin = {
 
  88     boundary = {administrative = 'named'},
 
  89     landuse = {residential = 'fallback',
 
  91                farmyard = 'fallback',
 
  92                industrial = 'fallback',
 
  93                commercial = 'fallback',
 
  94                allotments = 'fallback',
 
  96     place = {county = 'always',
 
  98              municipality = 'always',
 
 106              subdivision = 'always',
 
 107              allotments = 'always',
 
 108              neighbourhood = 'always',
 
 110              isolated_dwelling = 'always',
 
 112              city_block = 'always',
 
 116 module.MAIN_TAGS.all_boundaries = {
 
 119                 land_area = 'delete',
 
 120                 postal_code = 'always'},
 
 121     landuse = 'fallback',
 
 125 module.MAIN_TAGS.natural = {
 
 127                 riverbank = 'delete'},
 
 131                coastline = 'delete',
 
 133                water = exclude_when_key_present('water', true)},
 
 134     mountain_pass = {'always',
 
 136     water = {include_when_tag_present('natural', 'water', true),
 
 144              intermittent = 'delete',
 
 149 module.MAIN_TAGS_POIS = function (group)
 
 150     group = group or 'delete'
 
 152     aerialway = {'always',
 
 159                parking_space = group,
 
 160                parking_entrance = group,
 
 161                waste_disposal = group,
 
 162                hunting_stand = group},
 
 163     building = {'fallback',
 
 165     bridge = {'named_with_key',
 
 171     emergency = {'always',
 
 174                  fire_hydrant = group},
 
 175     healthcare = {'fallback',
 
 180                turning_circle = group,
 
 181                mini_roundabout = group,
 
 186                turning_loop = group,
 
 187                passing_place = group,
 
 188                street_lamp = 'named',
 
 189                traffic_signals = 'named'},
 
 190     historic = {'always',
 
 193     information = {include_when_tag_present('tourism', 'information'),
 
 195                    route_marker = 'never',
 
 196                    trail_blaze = 'never'},
 
 197     junction = {'fallback',
 
 200                nature_reserve = 'fallback',
 
 201                swimming_pool = 'named',
 
 203     lock = {yes = lock_transform},
 
 204     man_made = {pier = 'always',
 
 208                 water_tower = 'always',
 
 211                 lighthouse = 'always',
 
 212                 watermill = 'always',
 
 214     military = {'always',
 
 225                level_crossing = group,
 
 228                buffer_stop = group},
 
 234                information = exclude_when_key_present('information')},
 
 235     tunnel = {'named_with_key',
 
 239 module.MAIN_TAGS_STREETS = {}
 
 241 module.MAIN_TAGS_STREETS.default = {
 
 242     place = {square = 'always'},
 
 243     highway = {motorway = 'always',
 
 246                secondary = 'always',
 
 248                unclassified = 'always',
 
 249                residential = 'always',
 
 251                living_street = 'always',
 
 252                pedestrian = 'always',
 
 256                footway = filter_footways,
 
 260                motorway_link = 'named',
 
 261                trunk_link = 'named',
 
 262                primary_link = 'named',
 
 263                secondary_link = 'named',
 
 264                tertiary_link = 'named'}
 
 267 module.MAIN_TAGS_STREETS.car = {
 
 268     place = {square = 'always'},
 
 269     highway = {motorway = 'always',
 
 272                secondary = 'always',
 
 274                unclassified = 'always',
 
 275                residential = 'always',
 
 277                living_street = 'always',
 
 280                motorway_link = 'always',
 
 281                trunk_link = 'always',
 
 282                primary_link = 'always',
 
 283                secondary_link = 'always',
 
 284                tertiary_link = 'always'}
 
 287 module.MAIN_TAGS_STREETS.all = {
 
 288     place = {square = 'always'},
 
 289     highway = {motorway = 'always',
 
 292                secondary = 'always',
 
 294                unclassified = 'always',
 
 295                residential = 'always',
 
 297                living_street = 'always',
 
 298                pedestrian = 'always',
 
 304                bridleway = 'always',
 
 306                motorway_link = 'always',
 
 307                trunk_link = 'always',
 
 308                primary_link = 'always',
 
 309                secondary_link = 'always',
 
 310                tertiary_link = 'always'}
 
 316 module.NAME_TAGS = {}
 
 318 module.NAME_TAGS.core = {main = {'name', 'name:*',
 
 319                                  'int_name', 'int_name:*',
 
 320                                  'nat_name', 'nat_name:*',
 
 321                                  'reg_name', 'reg_name:*',
 
 322                                  'loc_name', 'loc_name:*',
 
 323                                  'old_name', 'old_name:*',
 
 324                                  'alt_name', 'alt_name:*', 'alt_name_*',
 
 325                                  'official_name', 'official_name:*',
 
 326                                  'place_name', 'place_name:*',
 
 327                                  'short_name', 'short_name:*'},
 
 328                          extra = {'ref', 'int_ref', 'nat_ref', 'reg_ref',
 
 329                                   'loc_ref', 'old_ref', 'ISO3166-2'}
 
 331 module.NAME_TAGS.address = {house = {'addr:housename'}}
 
 332 module.NAME_TAGS.poi = group_merge({main = {'brand'},
 
 333                                     extra = {'iata', 'icao'}},
 
 334                                    module.NAME_TAGS.core)
 
 338 module.ADDRESS_TAGS = {}
 
 340 module.ADDRESS_TAGS.core = { extra = {'addr:*', 'is_in:*', 'tiger:county'},
 
 341                              postcode = {'postal_code', 'postcode', 'addr:postcode',
 
 342                                          'tiger:zip_left', 'tiger:zip_right'},
 
 343                              country = {'country_code', 'ISO3166-1',
 
 344                                         'addr:country_code', 'is_in:country_code',
 
 345                                         'addr:country', 'is_in:country'}
 
 348 module.ADDRESS_TAGS.houses = { main = {'addr:housenumber',
 
 349                                        'addr:conscriptionnumber',
 
 350                                        'addr:streetnumber'},
 
 351                                interpolation = {'addr:interpolation'}
 
 354 -- Ignored tags (prefiltered away)
 
 356 module.IGNORE_KEYS = {}
 
 358 module.IGNORE_KEYS.metatags = {'note', 'note:*', 'source', 'source:*', '*source',
 
 359                                'attribution', 'comment', 'fixme', 'created_by',
 
 360                                'tiger:cfcc', 'tiger:reviewed', 'nysgissam:*',
 
 361                                'NHD:*', 'nhd:*', 'gnis:*', 'geobase:*', 'yh:*',
 
 362                                'osak:*', 'naptan:*', 'CLC:*', 'import', 'it:fvg:*',
 
 363                                'lacounty:*', 'ref:linz:*',
 
 364                                'ref:bygningsnr', 'ref:ruian:*', 'building:ruian:type',
 
 367 module.IGNORE_KEYS.name = {'*:prefix', '*:suffix', 'name:prefix:*', 'name:suffix:*',
 
 368                            'name:etymology', 'name:etymology:*',
 
 369                            'name:signed', 'name:botanical'}
 
 370 module.IGNORE_KEYS.address = {'addr:street:*', 'addr:city:*', 'addr:district:*',
 
 371                               'addr:province:*', 'addr:subdistrict:*', 'addr:place:*',
 
 374 -- Extra tags (prefiltered away)
 
 376 module.EXTRATAGS = {}
 
 378 module.EXTRATAGS.required = {'wikipedia', 'wikipedia:*', 'wikidata', 'capital'}