Module:Sandbox/Yurik/OSM NoWD

local p = {}

function p.show( frame ) local dataPage = 'Sandbox/Yurik/OSM objects with missing Wikidata ID.tab' local results = {}

table.insert(results, '!Name||LVL||ID||Wikipedia||Boundary||Type||Designation\n') for key, row in pairs(mw.ext.data.get(dataPage).data) do       local relid, admin_level, latitude, longitude, name, wikipedia, boundary, type_, designation = unpack(row) if wikipedia then wikipedia =  .. wikipedia ..  end local line = '|-\n| ' .. '| ' .. (name or '') .. '\n' .. '| ' .. (admin_level or '') .. '\n' .. '| [http://www.openstreetmap.org/relation/' .. relid .. ' ' .. relid .. '] (.. relid .. ' edit) \n' .. '| ' .. (wikipedia or '') .. '\n' .. '| ' .. (boundary or '') .. '\n' .. '| ' .. (type_ or '') .. '\n' .. '| ' .. (designation or '') .. '\n' table.insert(results, line) end

return '{| class="wikitable sortable"\n' .. table.concat(results, '\n') .. '|}' end

function p.dup( frame ) local dataPage = 'Sandbox/Yurik/OSM objects with duplicate Wikidata ID.tab' local results = {} local lastId = nil

table.insert(results, '! Wikidata ID, title || OSM relation || LVL || Name in OSM\n') for key, row in pairs(mw.ext.data.get(dataPage).data) do       local admin_level, relid, wikidata, name, wikipedia, boundary, type_, altname, designation = unpack(row) local isNewRow = lastId ~= wikidata lastId = wikidata local namestr = (name and (name .. '/') or '') .. (boundary and (boundary .. '_') or '') .. (type_ or '') .. (altname and ('/' .. altname) or '') .. (designation and ('/' .. designation) or '') if isNewRow then table.insert(results, '|-\n| colspan=4 style="background-color: black;" |\n') wikidata = "  ''' [https://wikidata.org/wiki/" .. wikidata .. " " .. wikidata .. "] '''"       elseif wikipedia then wikidata = "" .. wikipedia .. "" else wikidata = '' end local line = '|-\n| ' .. '| ' .. wikidata .. '\n' .. '| [http://www.openstreetmap.org/relation/' .. relid .. ' ' .. relid .. '] (.. relid .. ' edit) \n' .. '| ' .. (admin_level or '') .. '\n' .. '| ' .. namestr .. '\n' table.insert(results, line) end

return '{| class="wikitable"\n' .. table.concat(results, '\n') .. '|}' end

return p