17.707
Bearbeitungen
Keine Bearbeitungszusammenfassung |
Keine Bearbeitungszusammenfassung |
||
| Zeile 86: | Zeile 86: | ||
-- Gebäude-Attribute von subobject abfragen | -- Gebäude-Attribute von subobject abfragen | ||
fbdata.attr.subid = geb.getSubobjectID(fbdata.pargs) | fbdata.attr.subid = geb.getSubobjectID(fbdata.pargs) | ||
local | local subobject_pagename = fbdata.pagename .. "#" .. fbdata.attr.subid | ||
queryGebaeudeArgs(fbdata.pargs, subobject_pagename) | |||
-- Faktenbox anzeigen (ohne Attribute setzen) | |||
if fbdata.pargs ~= {} then | |||
mw.logObject(fbdata.pargs, "fbdata.pargs") | |||
fbdata.attr.noattr = true | |||
t = geb.faktenbox(fbdata) -- Geo-Subjekte in pargs rückverwandeln | |||
end | |||
mw.logObject(t, "t") | |||
return t | |||
end | |||
function queryGebaeudeArgs(args, subobject_pagename) -- Gebäude-Attribute von subobject abfragen | |||
args = {} | |||
local query = "[[" .. subobject_pagename .. "]]" | |||
for _, a in ipairs(geb.gebaude_attr) do | for _, a in ipairs(geb.gebaude_attr) do | ||
query = query .. "|?" .. a .. "#-" | query = query .. "|?" .. a .. "#-" | ||
end | end | ||
query = query .. "|?GeoSubobject#-|?#-" | query = query .. "|?GeoSubobject#-|?#-" | ||
mw.logObject(query, "query") | |||
val = mw.smw.ask(query) | val = mw.smw.ask(query) | ||
mw.logObject(val, "val") | |||
if val == nil then | if val == nil then | ||
t = t .. "<br>Gebäude " .. | t = t .. "<br>Gebäude " .. | ||
( | (args["Objekt"] or "(nicht angegeben)") .. | ||
" mit Baujahr " .. | " mit Baujahr " .. | ||
( | (args["Baujahr"] or "(nicht angegeben)") .. | ||
" nicht gefunden<br>" | " nicht gefunden<br>" | ||
elseif #val > 1 then | elseif #val > 1 then | ||
t = t .. "<br>Mehrere Gebäude " .. | t = t .. "<br>Mehrere Gebäude " .. | ||
( | (args["Objekt"] or "(nicht angegeben)") .. | ||
" mit Baujahr " .. | " mit Baujahr " .. | ||
( | (args["Baujahr"] or "(nicht angegeben)") .. | ||
" gefunden<br>" | " gefunden<br>" | ||
else | else | ||
| Zeile 110: | Zeile 124: | ||
val = val[1] -- immer nur das erste subobject nehmen | val = val[1] -- immer nur das erste subobject nehmen | ||
val[1] = nil -- subobject id entfernen | val[1] = nil -- subobject id entfernen | ||
for a, v in pairs(val) do | for a, v in pairs(val) do | ||
if type(v) == "table" then | if type(v) == "table" then | ||
| Zeile 117: | Zeile 130: | ||
v = tostring(v) | v = tostring(v) | ||
end | end | ||
args[a] = v | |||
end | end | ||
getGeoArgs(fbdata, val.GeoSubobject) | getGeoArgs(fbdata, val.GeoSubobject) | ||
end | end | ||
end | end | ||
function getGeoArgs( | function getGeoArgs(args, geo_subobjects) -- wandelt die Geo-Subjekte wieder ein pargs zurück | ||
if geo_subobjects ~= nil then | if geo_subobjects ~= nil then | ||
if type(geo_subobjects) ~= "table" then | if type(geo_subobjects) ~= "table" then | ||
| Zeile 143: | Zeile 150: | ||
end | end | ||
query = query .. "|?Geokoordinate|?Geolokation|?GeoJson#-|?Zoomlevel|?#-" | query = query .. "|?Geokoordinate|?Geolokation|?GeoJson#-|?Zoomlevel|?#-" | ||
-- mw.logObject(query, "query") | |||
geo_subobjects = mw.smw.ask(query) or {} | geo_subobjects = mw.smw.ask(query) or {} | ||
-- mw.logObject(geo_subobjects, "geo_subobjects") | |||
-- Attribute zu pargs wandeln | -- Attribute zu pargs wandeln | ||
for _, o in ipairs(geo_subobjects) do | for _, o in ipairs(geo_subobjects) do | ||
| Zeile 152: | Zeile 159: | ||
local zoom = o["Zoomlevel"] | local zoom = o["Zoomlevel"] | ||
if location ~= nil then -- location-Liste mergen | if location ~= nil then -- location-Liste mergen | ||
if | if args["locationlist"] == nil then | ||
args["locationlist"] = location | |||
else | else | ||
args["locationlist"] = | |||
args["locationlist"] .. ";" .. location | |||
end | end | ||
end | end | ||
if | if args["geojson"] == nil and geojson ~= nil then -- GeoJson 1x übernehmen. Sind eh alle gleich | ||
args["geojson"] = string.sub(geojson, 9) -- "GeoJson:" abschneiden | |||
end | end | ||
if | if args["zoom"] == nil and zoom ~= nil then -- Zoomlevel 1x übernehmen. Sind eh alle gleich | ||
args["zoom"] = zoom | |||
end | end | ||
end | end | ||