Content deleted Content added
remove config["coordinates"], config["coord"]; leave note referencing talk page |
update from sandbox: allow locally-specified coords to override Wikidata (per Template talk:Maplink#Template:Infobox power station/sandbox) |
||
Line 1:
local mf = require('Module:Mapframe')
-- Trim whitespace from args, and remove empty args
function
local cleanArgs = {}
for key, val in pairs(argsTable) do
Line 49 ⟶ 50:
p._main = function(_config)
local config = trimArgs(_config)
-- Use wikidata by default
local useWikidata = true
-- Do not use wikidata when coords are specified, unless explicitly set
if config.coord then
useWikidata = config.wikidata and true or false
end
-- Require wikidata item, or specified coords
local wikidataId = config.id or mw.wikibase.getEntityIdForCurrentPage()
if not
return ''
end
-- Require
local hasCoordinates = hasWikidataProperty(wikidataId, 'P625') or config.coordinates or config.coord
if not hasCoordinates then
return ''
end
-- `args` is the arguments
local args = {}
Line 94 ⟶ 106:
-- Shape
if useWikidata then
if config.id then args.id = config.id end end
-- Line
if useWikidata then
if config.id then args.id2 = config.id end end
-- Point
local hasOsmRelationId = hasWikidataProperty(wikidataId, 'P402') -- P402 is OSM relation ID
local shouldShowPointMarker = not(hasOsmRelationId) or (config.marker and config.marker ~= 'none') or (config.coordinates or config.coord)
if shouldShowPointMarker then
local argNumber = useWikidata and "3" or ""
args["type".
if config.id then args.id3 = config.id end▼
if config.
args["marker-color3"] = config["marker-color"] or config["marker-colour"] or "#5E74F3"▼
if config.marker then args["marker"..argNumber] = config.marker end
▲ args["marker-
end
local mapframe = mf._main(args)
|