15.082
Bearbeitungen
(Erstversion) |
(getArgs) |
||
| (3 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
| Zeile 8: | Zeile 8: | ||
function p.Adresse(frame) | function p.Adresse(frame) | ||
-- mw. | -- mw.logObject(frame, "Adresse(frame)") | ||
-- Konsolenzeile zum Debuggen: | -- Konsolenzeile zum Debuggen: | ||
-- =p.Adresse{pargs={["Adressart"]="Wohnung", ["Straße"]="Schwabacher Straße", ["Hausnummer"]="12",["AdresseVon"]=" | -- =p.Adresse{pargs={["Adressart"]="Wohnung", ["Straße"]="Schwabacher Straße", ["Hausnummer"]="12",["AdresseVon"]="2020-03-04", ["AdresseBis"]="2021-05-06", ["Kommentar"]="f"}} | ||
-- =p.Adresse{pargs={["Adressart"]="Wohnung", ["Straße"]="Fichtenstraße", ["Hausnummer"]="44",["AdresseVon"]=" | -- =p.Adresse{pargs={["Adressart"]="Wohnung", ["Straße"]="Fichtenstraße", ["Hausnummer"]="44",["AdresseVon"]="2020-03-04", ["AdresseBis"]="2021-05-06", ["Kommentar"]="f"}} | ||
local t = "" | local t = "" | ||
local fail = false | local fail = false | ||
local | local frame, pargs = dev.GetFrameAndParentArgs(frame) | ||
local attr, attr_empty = wik.getArgs(pargs, {"Adressart", "AdresseVon", "AdresseBis", "Straße", "Hausnummer", "Kommentar"}) | |||
local attr | |||
if attr_empty then -- Überhaupt Parameter übergeben? | |||
if | |||
fail = true | fail = true | ||
else | else | ||
-- Straße/Hausnummer auswerten | -- subobject-Name | ||
local subobject = {} | |||
table.insert(subobject, attr["Adressart"]) | |||
table.insert(subobject, attr["Straße"]) | |||
table.insert(subobject, attr["Hausnummer"]) | |||
subobject = table.concat(subobject, " ") | |||
if subobject == "" then -- subobject-Name fehlerhaft? | |||
fail = true | |||
else | |||
-- SubObjektTyp setzen | |||
attr["SubObjektTyp"] = "Adresse" | |||
-- Straße/Hausnummer auswerten | |||
if attr["Straße"] ~= nil then | |||
if attr["Hausnummer"] ~= nil then | |||
attr["StraßeHnr"] = attr["Straße"] .. " " .. attr["Hausnummer"] | |||
else | |||
attr["StraßeHnr"] = attr["Straße"] | |||
end | |||
elseif attr["Hausnummer"] ~= nil then | |||
fail = true -- Fehler Hausnummer ohne Straße | |||
end | end | ||
-- Postleitzahl ermitteln | |||
if attr["Straße"] ~= nil then | |||
local PLZ = geo.getPLZ(attr["Straße"], attr["Hausnummer"]) | |||
if PLZ ~= "" then | |||
attr["PLZ"] = PLZ | |||
end | |||
end | end | ||
-- VonObjekt erstellen | |||
if attr["StraßeHnr"] ~= nil then | |||
if wik.pageExists(attr["StraßeHnr"]) then | |||
attr["VonObjekt"] = attr["StraßeHnr"] | |||
else | |||
-- Seite mit passender StraßeHnr suchen | |||
local ask_result = mw.smw.ask("[[:+]][[Kategorie:Gebäude]][[StraßeHnr::" .. attr["StraßeHnr"] .. "]]|?#-|limit=1") | |||
if ask_result ~= nil and #ask_result > 0 then | |||
attr["VonObjekt"] = ask_result[1][1] | |||
end | |||
end | end | ||
end | end | ||
-- subobject setzen | |||
mw.smw.subobject(attr, subobject) | |||
-- Plausibilitätsprüfung von/bis | |||
if attr["AdresseVon"] ~= nil and attr["AdresseBis"] ~= nil and | |||
p.smwDate2CompareIndex(attr["AdresseVon"], "von") > p.smwDate2CompareIndex(attr["AdresseBis"], "bis") then | |||
fail = true | |||
end | end | ||
end -- Ende if subobject-Name fehlerhaft? | |||
end -- Ende if not attr_empty | |||
-- Kategorie:Fehlerhafte Adresse | -- Kategorie:Fehlerhafte Adresse | ||
| Zeile 92: | Zeile 82: | ||
end | end | ||
-- mw. | -- mw.logObject(t, "t") | ||
return t | return t | ||
end | end | ||