15.269
Bearbeitungen
Keine Bearbeitungszusammenfassung Markierung: Manuelle Zurücksetzung |
Keine Bearbeitungszusammenfassung |
||
| Zeile 1: | Zeile 1: | ||
p = {} | p = {} | ||
local str = require("Modul:String") | |||
function p.karte(frame, args) | function p.karte(frame, args) | ||
mw.log("karte(frame, args)") | |||
mw.logObject(args, "args") | |||
local t = "" | local t = "" | ||
if (args["lat"] ~= nil and args["lon"] ~= nil) or | if (args["lat"] ~= nil and args["lon"] ~= nil) or | ||
args["location"] ~= nil or args["locationlist"] ~= nil or | args["location"] ~= nil or args["locationlist"] ~= nil or | ||
args["geojson"] ~= nil then | args["geojson"] ~= nil then | ||
-- geocode location and locationlist | |||
local subobjects = {} | |||
local minimum_one_geocode_ok = false | |||
if not com.isTrue(args["Ehemals"]) then | |||
local loc = str.splitAndStrip(fbdata.pargs["locationlist"] or "", ";") | |||
if args["location"] ~= nil then | |||
table.insert(loc, args["location"]) | |||
end | |||
for _, l in ipairs(loc) do | |||
local subobject_entry = {} | |||
subobject_entry["Geolokation"] = l | |||
local geocode = fbdata.frame:callParserFunction("#geocode", l) | |||
if geocode ~= "Geocoding failed" then | |||
subobject_entry["Geokoordinate"] = geocode | |||
minimum_one_geocode_ok = true | |||
end | |||
table.insert(subobjects, subobject_entry) | |||
end | |||
end | |||
-- geocode lon/lat | |||
if (not minimum_one_geocode_ok or com.isTrue(args["Ehemals"])) and args["lat"] ~= nil and args["lon"] ~= nil then | |||
local geocode = fbdata.frame:callParserFunction("#geocode", args["lat"] .. "," .. args["lon"]) | |||
if geocode ~= "Geocoding failed" then | |||
local subobject_entry = {} | |||
subobject_entry["Geokoordinate"] = geocode | |||
one_geocode_ok = true | |||
table.insert(subobjects, subobject_entry) | |||
end | |||
end | |||
mw.logObject(subobjects, "subobjects") | |||
-- subobjects setzen | |||
for _, s in ipairs(subobjects) do | |||
s["SubObjektTyp"] = "Geo" | |||
mw.smw.subobject(s, s["Geolokation"] or s["Geokoordinate"]) | |||
end | |||
t = frame:expandTemplate{title = "Karte", args = args} | t = frame:expandTemplate{title = "Karte", args = args} | ||
end | end | ||
mw.logObject(t, "t") | |||
return t | return t | ||
end | end | ||
return p | return p | ||