Modul:Karte: Unterschied zwischen den Versionen

817 Bytes hinzugefügt ,  Gestern um 16:46
geocode location and locationlist erweitert um popuptitle/popuptext
(Karte() mit wik.getArgs)
(geocode location and locationlist erweitert um popuptitle/popuptext)
Zeile 25: Zeile 25:
local minimum_one_geocode_ok = false
local minimum_one_geocode_ok = false
if not com.isTrue(args["Ehemals"]) then
if not com.isTrue(args["Ehemals"]) then
local loc = str.splitAndStrip(args["locationlist"] or "", ";")
-- locationlist und location zusammenführen
if args["location"] ~= nil then
local locations_merged = str.splitAndStrip(args["locationlist"] or "", ";")
table.insert(loc, args["location"])
local location = str.strip(args["location"] or "")
if location ~= "" then
table.insert(locations_merged, args["location"] ..
"~" .. (args["popuptitle"] or "") ..
"~" .. (args["popuptext"] or ""))
end
end
for _, l in ipairs(loc) do
-- alle locations durchiterieren und für jedes ein subobject erstellen
for _, l in ipairs(locations_merged) do
local subobject_entry = {}
local subobject_entry = {}
subobject_entry["Geolokation"] = l
-- Aufteilung location ~ popuptitle ~ popuptext
local geocode = frame:callParserFunction("#geocode", l)
l = str.split2(l, "~")
if geocode ~= "Geocoding failed" then
local location = str.strip(l[1] or "")
subobject_entry["Geokoordinate"] = geocode
local popuptitle = str.strip(l[2] or "")
minimum_one_geocode_ok = true
local popuptext = str.strip(l[3] or "")
-- location geocode
if location ~= "" then
subobject_entry["Geolokation"] = location
local geocode = frame:callParserFunction("#geocode", location)
if geocode ~= "Geocoding failed" then
subobject_entry["Geokoordinate"] = geocode
minimum_one_geocode_ok = true
end
end
end
-- popuptitle und popuptext ablegen
if popuptitle ~= "" then
subobject_entry["KartePopupTitle"] = popuptitle
end
if popuptext ~= "" then
subobject_entry["KartePopupText"] = popuptext
end
-- subobject in Liste aufnehmen
table.insert(subobjects, subobject_entry)
table.insert(subobjects, subobject_entry)
end
end
Zeile 60: Zeile 81:


-- bisherige Vorlagen-Karte
-- bisherige Vorlagen-Karte
t = frame:expandTemplate{title = "Karte/Legacy", args = args}
t = t .. frame:expandTemplate{title = "Karte/Legacy", args = args}


mw.logObject(t, "t")
mw.logObject(t, "t")