Modul:Karte/Work: Unterschied zwischen den Versionen

Aus FürthWiki

keine Bearbeitungszusammenfassung
Keine Bearbeitungszusammenfassung
Keine Bearbeitungszusammenfassung
Zeile 27: Zeile 27:


-- geocode location and locationlist
-- geocode location and locationlist
local subobjects = {}
local geoobjects = {}
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
Zeile 40: Zeile 40:
-- alle locations durchiterieren und für jedes ein subobject erstellen
-- alle locations durchiterieren und für jedes ein subobject erstellen
for _, l in ipairs(locations_merged) do
for _, l in ipairs(locations_merged) do
local subobject_entry = {}
local geoobject_entry = {}
-- Aufteilung location ~ popuptitle ~ popuptext
-- Aufteilung location ~ popuptitle ~ popuptext
l = str.split2(l, "~")
l = str.split2(l, "~")
Zeile 48: Zeile 48:
-- location geocode
-- location geocode
if location ~= "" then
if location ~= "" then
subobject_entry["Geolokation"] = location
geoobject_entry["Geolokation"] = location
local geocode = frame:callParserFunction(
local geocode = frame:callParserFunction(
"#geocode", {location, format="float", directional="no"})
"#geocode", {location, format="float", directional="no"})
if geocode ~= "Geocoding failed" then
if geocode ~= "Geocoding failed" then
subobject_entry["Geokoordinate"] = geocode
geoobject_entry["Geokoordinate"] = geocode
minimum_one_geocode_ok = true
minimum_one_geocode_ok = true
else
else
Zeile 58: Zeile 58:
"[[-Has subobject::" .. pagename .. "]]" ..
"[[-Has subobject::" .. pagename .. "]]" ..
"[[Geolokation::" .. location .. "]]" ..
"[[Geolokation::" .. location .. "]]" ..
"|?Geokoordinate")
"|?Geokoordinate|limit=1")
if smw_geokoordinate ~= nil then
if smw_geokoordinate ~= nil and
subobject_entry["Geokoordinate"] = smw_geokoordinate["Geokoordinate"]
smw_geokoordinate[1]["Geokoordinate"] ~= nil then
geoobject_entry["Geokoordinate"] =
smw_geokoordinate[1]["Geokoordinate"]
minimum_one_geocode_ok = true
minimum_one_geocode_ok = true
end
end
Zeile 67: Zeile 69:
-- popuptitle und popuptext ablegen
-- popuptitle und popuptext ablegen
if popuptitle ~= "" then
if popuptitle ~= "" then
subobject_entry["KartePopupTitle"] = popuptitle
geoobject_entry["KartePopupTitle"] = popuptitle
end
end
if popuptext ~= "" then
if popuptext ~= "" then
subobject_entry["KartePopupText"] = popuptext
geoobject_entry["KartePopupText"] = popuptext
end
end
-- subobject in Liste aufnehmen
-- subobject in Liste aufnehmen
table.insert(subobjects, subobject_entry)
table.insert(geoobjects, geoobject_entry)
end
end
end
end
Zeile 81: Zeile 83:
local geocode = frame:callParserFunction("#geocode", {args["lat"] .. "," .. args["lon"], format="float", directional="no"})
local geocode = frame:callParserFunction("#geocode", {args["lat"] .. "," .. args["lon"], format="float", directional="no"})
if geocode ~= "Geocoding failed" then
if geocode ~= "Geocoding failed" then
local subobject_entry = {}
local geoobject_entry = {}
subobject_entry["Geokoordinate"] = geocode
geoobject_entry["Geokoordinate"] = geocode
if popuptitle ~= "" then
if popuptitle ~= "" then
subobject_entry["KartePopupTitle"] = popuptitle
geoobject_entry["KartePopupTitle"] = popuptitle
end
end
if popuptext ~= "" then
if popuptext ~= "" then
subobject_entry["KartePopupText"] = popuptext
geoobject_entry["KartePopupText"] = popuptext
end
end
table.insert(subobjects, subobject_entry)
table.insert(geoobjects, geoobject_entry)
end
end
end
end
-- subobjects setzen
-- geoobjects setzen
mw.logObject(subobjects, "subobjects")
mw.logObject(geoobjects, "geoobjects")
for _, s in ipairs(subobjects) do
for _, o in ipairs(geoobjects) do
s["SubObjektTyp"] = "Geo"
o["SubObjektTyp"] = "Geo"
local id = smw.subobjectIdCleaner(s["Geolokation"] or s["Geokoordinate"])
local id = smw.subobjectIdCleaner(o["Geolokation"] or o["Geokoordinate"])
mw.smw.subobject(s, id)
mw.smw.subobject(o, id)
end
end