1 -- Prints taginfo project description in the standard output
4 -- create fake "osm2pgsql" table for flex-base, originally created by the main C++ program
6 function osm2pgsql.define_table(...) end
8 -- provide path to flex-style lua file
9 package.path = arg[0]:match("(.*/)") .. "?.lua;" .. package.path
10 local flex = require('import-' .. (arg[1] or 'extratags'))
11 local json = require ('dkjson')
13 local NAME_DESCRIPTIONS = {
14 'Searchable auxiliary name of the place',
15 main = 'Searchable primary name of the place',
16 house = 'House name part of an address, searchable'
18 local ADDRESS_DESCRIPTIONS = {
19 'Used to determine the address of a place',
20 main = 'Primary key for an address point',
21 postcode = 'Used to determine the postcode of a place',
22 country = 'Used to determine country of a place (only if written as two-letter code)',
23 interpolation = 'Primary key for an address interpolation line'
26 ------------ helper functions ---------------------
27 -- Sets the key order for the resulting JSON table
28 local function set_keyorder(table, order)
34 local function get_key_description(key, description)
37 desc.description = description
38 set_keyorder(desc, {'key', 'description'})
42 local function get_key_value_description(key, value, description)
43 local desc = {key = key, value = value, description = description}
44 set_keyorder(desc, {'key', 'value', 'description'})
48 local function group_table_to_keys(tags, data, descriptions)
49 for group, values in pairs(data) do
50 local desc = descriptions[group] or descriptions[1]
51 for _, key in pairs(values) do
52 if key:sub(1, 1) ~= '*' and key:sub(#key, #key) ~= '*' then
53 table.insert(tags, get_key_description(key, desc))
59 -- Prints the collected tags in the required format in JSON
60 local function print_taginfo()
61 local taginfo = flex.get_taginfo()
64 for k, values in pairs(taginfo.main) do
65 if values[1] == nil or values[1] == 'delete' or values[1] == 'extra' then
66 for v, group in pairs(values) do
67 if type(v) == 'string' and group ~= 'delete' and group ~= 'extra' then
68 local text = 'POI/feature in the search database'
69 if type(group) ~= 'function' then
70 text = 'Fallback ' .. text
72 table.insert(tags, get_key_value_description(k, v, text))
75 elseif type(values[1]) == 'function' or values[1] == 'fallback' then
76 local desc = 'POI/feature in the search database'
77 if values[1] == 'fallback' then
78 desc = 'Fallback ' .. desc
81 for v, group in pairs(values) do
82 if group == 'delete' or group == 'extra' then
86 if next(excp) ~= nil then
87 desc = desc .. string.format(' (except for values: %s)',
88 table.concat(excp, ', '))
90 table.insert(tags, get_key_description(k, desc))
94 group_table_to_keys(tags, taginfo.name, NAME_DESCRIPTIONS)
95 group_table_to_keys(tags, taginfo.address, ADDRESS_DESCRIPTIONS)
99 data_url = 'https://nominatim.openstreetmap.org/taginfo.json',
102 description = 'OSM search engine.',
103 project_url = 'https://nominatim.openstreetmap.org',
104 doc_url = 'https://nominatim.org/release-docs/develop/',
105 contact_name = 'Sarah Hoffmann',
106 contact_email = 'lonvia@denofr.de'
111 set_keyorder(format, {'data_format', 'data_url', 'project', 'tags'})
112 set_keyorder(format.project, {'name', 'description', 'project_url', 'doc_url',
113 'contact_name', 'contact_email'})
115 print(json.encode(format))