Content deleted Content added
plain output for testing |
rest of data for json |
||
Line 52:
end
function
local coords
local frame = mw.getCurrentFrame()
if args.coord then
coords = args.coord
else
coords = frame:preprocess('{{WikidataCoord|display=|'..(args.id or args.ids or mw.wikibase.getEntityIdForCurrentPage())..'}}')
end
return frame:preprocess('[{{#invoke:coordinates|coord2text|'..coords..'|long}}, {{#invoke:coordinates|coord2text|'..coords..'|lat}}]')
end
function makeContentJson(args)
local data = {}
if
data.type = "Feature"
data.geometry = {
type = "Point",
coordinates = makeCoordsText(args)
}
data.properties = {
title = args.title or mw.getCurrentFrame():getParent():getTitle(),
["marker-symbol"] = args.marker or "marker",
["marker-color"] = "5E74F3"
}
else
data.type = "ExternalData"
if args.type == "data" or args.from then
data.service = "page"
elseif args.type == "line" then
data.service = "geoline"
elseif args.type == "shape" then
data.service = "geoshape"
elseif args.type == "shape-inverse" then
data.service = "geomask"
end
if args.id or args.ids or (not (args.from) and mw.wikibase.getEntityIdForCurrentPage()) then
data.ids = args.id or args.ids or mw.wikibase.getEntityIdForCurrentPage()
else
data.title = args.from
end
data.properties = {
stroke = args["stroke-color"] or args["stroke-colour"] or "#ff0000",
["stroke-width"] = args["stroke-width"] or "6"
}
end
data.properties.title = args.title or mw.getCurrentFrame():getParent():getTitle()
if args.description then
data.properties.description = args.description
end
return mw.text.jsonEncode(data)
|