Modul:Flächensumme
Zur Navigation springen
Zur Suche springen
Dokumentation und Testfälle unter Modul:Flächensumme/Doku.
local p = {}
require("Modul:Hilfsfunktionen")
function holeFlaeche(landschaft)
if landschaft=='' then return {} end
s='[[Teil von::'..landschaft..']]'
local teile=mw.smw.ask(s
..'|mainlabel=-'
..'|?Fläche'
..'|limit=500'
..'|searchlabel='
)
if teile==nil then return {} end
return teile
end
function p.Abfrage(frame)
if (frame.args[1]==nil) then
return 'no parameter found'
end
local landschaft=robusttrim(frame.args[1])
local teile=holeFlaeche(landschaft)
local flaeche=0
for k,v in pairs(teile) do
local f=tonumber(v['Fläche'])
if f~=nil then
flaeche=flaeche+f
end
end
return math.floor(flaeche + 0.5)
end
return p