Modul:Geo: Unterschied zwischen den Versionen

Code-Optimierungen
K (HeikoBot verschob die Seite Modul:Geocode nach Modul:Geo, ohne dabei eine Weiterleitung anzulegen)
(Code-Optimierungen)
Zeile 85: Zeile 85:


function p.GetPLZList(frame)
function p.GetPLZList(frame)
local sep = frame.args.sep or ";"
return table.concat(p.getPLZList(), frame.args.sep or ";")
local plz_table = p.getPLZList()
local plz_list = str.list(plz_table, sep)
return plz_list
end
end


Zeile 98: Zeile 95:
-- mw.logObject(frame)
-- mw.logObject(frame)
local plz = ""
local plz = ""
local stadtteile = frame.args[1]
local stadtteile = frame.args[1] or ""
if not com.isEmpty(stadtteile) then
if stadtteile ~= "" then
local stadtteile = str.splitAndStrip(stadtteile, ";")
local stadtteile = str.splitAndStrip(stadtteile, ";")
plz = p.stadtteil2PLZ(stadtteile)
plz = p.stadtteil2PLZ(stadtteile)
plz = str.list(plz, ";")
plz = table.concat(plz, ";")
end
end
-- mw.log(plz)
-- mw.log(plz)
Zeile 111: Zeile 108:
-- gibt die Postleitzahlen der Stadtteile als table zurück
-- gibt die Postleitzahlen der Stadtteile als table zurück
local plz_table = {}
local plz_table = {}
if not com.isEmpty(stadtteile) then
if type(stadtteile) == "table" then
if type(stadtteile) == "table" then
for _, s in pairs(stadtteile) do
for _, s in pairs(stadtteile) do
for _, p in pairs(que.getValues(s, "PLZ", true)) do -- p ist string
for _, p in pairs(que.getValues(s, "PLZ", true)) do -- p ist string
plz_table[tonumber(p)] = true -- diese Mechanik verhindert mehrfaches Einfügen der gleichen PLZ
plz_table[tonumber(p)] = true -- diese Mechanik verhindert mehrfaches Einfügen der gleichen PLZ
end
end
end
else
plz_table[tonumber(que.getValues(stadtteile, "PLZ", true)[1])] = true
end
end
elseif stadtteile ~= nil and stadtteile ~= "" then
plz_table[tonumber(que.getValues(stadtteile, "PLZ", true)[1])] = true
end
end
-- mw.logObject(plz_table)
-- mw.logObject(plz_table)