15.422
Bearbeitungen
Keine Bearbeitungszusammenfassung |
Keine Bearbeitungszusammenfassung |
||
| (24 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
| Zeile 9: | Zeile 9: | ||
function p.Karte(frame) | function p.Karte(frame) | ||
-- nur die benötigten Argumente übernehmen | -- nur die benötigten Argumente übernehmen | ||
local | local args = { | ||
"lat", "lon", "location", "locationlist", "geojson", "geocode", | "lat", "lon", "location", "locationlist", "geojson", "geocode", | ||
"zoom", "popuptitle", "popuptext", | "zoom", "popuptitle", "popuptext", | ||
| Zeile 15: | Zeile 15: | ||
"noattr", "form", | "noattr", "form", | ||
"Work", "Debug"} | "Work", "Debug"} | ||
local args = wik.getArgs(frame.args, args) | |||
return p.karte(frame, args) | return p.karte(frame, args) | ||
end | end | ||
| Zeile 34: | Zeile 28: | ||
local geoobjects = {} | local geoobjects = {} | ||
local kategorien = {} | local kategorien = {} | ||
local attrlist = {} | |||
local pagename = args["pagename"] or wik.pagename() -- nur zum Debuggen pagename vorgebbar | local pagename = args["pagename"] or wik.pagename() -- nur zum Debuggen pagename vorgebbar | ||
-- defaults setzen | -- defaults setzen | ||
args["box"] = args["box"] or "Ja" | |||
args["zoom"] = args["zoom"] or "16" | |||
local geojson_pagename = args["geojson"] or pagename | |||
local geojson_fullpagename = "GeoJson:" .. geojson_pagename | |||
if com. | -- width/height | ||
args[" | if com.isTrue(args["box"]) or args["width"] == "auto" then | ||
args["width"] = nil -- ohne width passt sich Karte eigenständig in Box ein | |||
elseif args["width"] == nil then | |||
end | args["width"] = "50%" -- default bei keiner width-Angabe und keiner Box | ||
end | |||
if com.isTrue(args["box"]) or args["height"] == "auto" then | |||
args["height"] = nil -- ohne height passt sich Karte eigenständig in Box ein | |||
elseif args["height"] == nil then | |||
args["height"] = "25%" -- default bei keiner height-Angabe und keiner Box | |||
end | |||
-- geocode location and locationlist | -- geocode location and locationlist | ||
| Zeile 76: | Zeile 73: | ||
else | else | ||
-- location geocode | -- location geocode | ||
local geocode = geocode(frame, location) | local geocode = "Geocoding failed" -- to do: diesen Block später rausschmeißen nach Aufbau nominatim.fuerthwiki.de | ||
if com.isEmpty(args["lat"]) or com.isEmpty(args["lon"]) then -- to do: diesen Block später rausschmeißen nach Aufbau nominatim.fuerthwiki.de | |||
geocode = getGeocode(frame, location) -- to do: nur diese Zeile bleibt übrig (mit local) | |||
end -- to do: diesen Block später rausschmeißen nach Aufbau nominatim.fuerthwiki.de | |||
if geocode ~= "Geocoding failed" then | if geocode ~= "Geocoding failed" then | ||
geoobject_entry["Geokoordinate"] = geocode | geoobject_entry["Geokoordinate"] = geocode | ||
| Zeile 106: | Zeile 106: | ||
not com.isEmpty(args["lat"]) and not com.isEmpty(args["lon"]) then | not com.isEmpty(args["lat"]) and not com.isEmpty(args["lon"]) then | ||
local geoobject_entry = {} | local geoobject_entry = {} | ||
-- local geocode = getGeocode(frame, args["lat"] .. "," .. args["lon"]) | |||
local geocode = args["lat"] .. "," .. args["lon"] -- to do: diesen Block später rausschmeißen und obigen aktivieren, wenn fertig | |||
if geocode ~= "Geocoding failed" then | if geocode ~= "Geocoding failed" then | ||
geoobject_entry["Geokoordinate"] = geocode | geoobject_entry["Geokoordinate"] = geocode | ||
| Zeile 119: | Zeile 120: | ||
-- Attribute setzen | -- Attribute setzen | ||
if not com.isTrue(args["noattr"]) then | if not com.isTrue(args["noattr"]) then | ||
-- Geolokation/Geokoordinate setzen | |||
-- geoobjects setzen | for _, o in ipairs(geoobjects) do -- to do: obsolete, wenn sobobject genutzt | ||
setAttr(attrlist, "Geolokation", o["Geolokation"]) -- to do: obsolete, wenn sobobject genutzt | |||
setAttr(attrlist, "Geokoordinate", o["Geokoordinate"]) -- to do: obsolete, wenn sobobject genutzt | |||
end -- to do: obsolete, wenn sobobject genutzt | |||
-- GeoJson | |||
if wik.pageExists(geojson_fullpagename) then | |||
setAttr(attrlist, "GeoJson", geojson_fullpagename) | |||
end | |||
-- zoom | |||
setAttr(attrlist, "Zoomlevel", args["zoom"]) | |||
-- normale Attribute setzen | |||
mw.logObject(attrlist, "attrlist") | |||
mw.smw.set(attrlist) | |||
-- geoobjects als subobjects setzen | |||
mw.logObject(geoobjects, "geoobjects") | mw.logObject(geoobjects, "geoobjects") | ||
for _, o in ipairs(geoobjects) do | for _, o in ipairs(geoobjects) do | ||
| Zeile 127: | Zeile 141: | ||
mw.smw.subobject(o, id) | mw.smw.subobject(o, id) | ||
end | end | ||
end | |||
-- Karte | |||
local map_args = { -- gemeinsame settings | |||
end | ["width"] = args["width"], ["height"] = args["height"], | ||
["zoom"] = args["zoom"], | |||
["enablefullscreen"] = "yes", ["resizable"] = "yes"} | |||
local display_map = false | |||
if wik.pageExists(geojson_fullpagename) then | |||
map_args["geojson"] = geojson_pagename | |||
table.insert(map_args, "") -- dummy / keine location | |||
display_map = true | |||
end | |||
if display_map then | |||
mw.logObject(map_args, "map_args") | |||
t = t .. frame:callParserFunction("#display_map", map_args) | |||
end | |||
-- bisherige Vorlagen-Karte | -- bisherige Vorlagen-Karte | ||
local karte_vorlage = "Karte/Legacy" | if not display_map then | ||
local karte_vorlage = "Karte/Legacy" | |||
if com.isTrue(args["Work"]) then | |||
-- args["Debug"] = "Ja" | karte_vorlage = karte_vorlage .. "/Work" | ||
-- args["Debug"] = "Ja" | |||
end | |||
mw.logObject(args, "args zur Vorlage " .. karte_vorlage) | |||
t = t .. frame:expandTemplate{title = karte_vorlage, args = args} | |||
end | end | ||
-- Box drum herum | -- Box drum herum | ||
| Zeile 175: | Zeile 203: | ||
end | end | ||
function | function getGeocode(frame, location) | ||
return frame:callParserFunction( | return frame:callParserFunction( | ||
"#geocode", {location, format="float", directional="no"}) | "#geocode", {location, format="float", directional="no"}) | ||
| Zeile 186: | Zeile 214: | ||
if not com.isEmpty(popuptext) then | if not com.isEmpty(popuptext) then | ||
geoobject_entry["KartePopupText"] = popuptext | geoobject_entry["KartePopupText"] = popuptext | ||
end | |||
end | |||
function setAttr(attrlist, attr, val) | |||
if val ~= nil then | |||
if attrlist[attr] == nil then | |||
attrlist[attr] = {val} | |||
else | |||
table.insert(attrlist[attr], val) | |||
end | |||
end | end | ||
end | end | ||
return p | return p | ||