Module:OSM and Module:OSM/sandbox: Difference between pages

(Difference between pages)
Jump to navigation Jump to search
Page 1
Page 2
imported>Polyglot
Add possibility to run query independent of wikidata Q-number
 
imported>Lemondoge
More simplification
 
Line 32: Line 32:
itemID = ""
itemID = ""
itemObject = nil
itemObject = nil
elseif args.id then
-- build query for specific Q-item(s)
itemID = args.id
pcall(function () itemObject = mw.wikibase.getEntityObject(mw.text.split(itemID,";")[1]) end)
else
else
if args.id then
itemObject = mw.wikibase.getEntityObject()
-- build query for specific Q-item(s)
if itemObject == nil then
itemID = args.id
return "This page doesn't have a wikidata entry"
pcall(function () itemObject = mw.wikibase.getEntityObject(mw.text.split(itemID,";")[1]) end)
else
itemObject = mw.wikibase.getEntityObject()
if itemObject == nil then
return "This page doesn't have a wikidata entry"
end
-- build query for current page
itemID = itemObject.id
end
end
-- build query for current page
itemID = itemObject.id
end
end
-- Always perform a regular expression based search
-- Always perform a regular expression based search
     -- The data may contain multiple values
     -- The data may contain multiple values
     if frame.args.overpass == nil then
     if frame.args.overpass == nil then
itemID = '"~"(^|;)(' .. itemID:gsub(";", "\|") .. ')(;|$)'
itemID = '"~"(^|;)(' .. itemID:gsub(";", "%|") .. ')(;|$)'
leftbracket = '["'
leftbracket = '["'
rightbracket = '"]'
rightbracket = '"]'
Line 66: Line 64:
query = ''
query = ''
end
end
if args.coord and not(args.limitToBBOX=='no') then
if args.coord and (args.limitToBBOX ~= 'no') then
-- The user can provide coordinates and a zoom factor
-- The user can provide coordinates and a zoom factor
coord = '&C=' .. args.coord
coord = '&C=' .. args.coord