15.458
Bearbeitungen
Keine Bearbeitungszusammenfassung |
Keine Bearbeitungszusammenfassung |
||
| Zeile 34: | Zeile 34: | ||
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 | ||
| Zeile 79: | Zeile 80: | ||
local geocode = "Geocoding failed" -- to do: diesen Block später rausschmeißen nach Aufbau nominatim.fuerthwiki.de | 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 | 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 = | geocode = getGeocode(frame, location) -- to do: nur diese Zeile bleibt übrig | ||
end -- to do: diesen Block später rausschmeißen nach Aufbau nominatim.fuerthwiki.de | end -- to do: diesen Block später rausschmeißen nach Aufbau nominatim.fuerthwiki.de | ||
if geocode ~= "Geocoding failed" then | if geocode ~= "Geocoding failed" then | ||
| Zeile 110: | Zeile 111: | ||
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 = | local geocode = getGeocode(frame, args["lat"] .. "," .. args["lon"]) | ||
if geocode ~= "Geocoding failed" then | if geocode ~= "Geocoding failed" then | ||
geoobject_entry["Geokoordinate"] = geocode | geoobject_entry["Geokoordinate"] = geocode | ||
| Zeile 120: | Zeile 121: | ||
table.insert(geoobjects, geoobject_entry) | table.insert(geoobjects, geoobject_entry) | ||
end | end | ||
-- Geolokation/Geokoordinate setzen | |||
for _, o in ipairs(geoobjects) do -- to do: obsolete, wenn sobobject genutzt | |||
attrlist:setAttr("Geolokation", o["Geolokation"]) -- to do: obsolete, wenn sobobject genutzt | |||
attrlist:setAttr("Geokoordinate", o["Geokoordinate"]) -- to do: obsolete, wenn sobobject genutzt | |||
end -- to do: obsolete, wenn sobobject genutzt | |||
-- Attribute setzen | -- Attribute setzen | ||
if not com.isTrue(args["noattr"]) then | if not com.isTrue(args["noattr"]) then | ||
-- normale Attribute setzen | |||
mw.smw.set(attrlist) | |||
-- geoobjects setzen | -- geoobjects als subobjecte setzen | ||
mw.logObject(geoobjects, "geoobjects") | mw.logObject(geoobjects, "geoobjects") | ||
for _, o in ipairs(geoobjects) do | for _, o in ipairs(geoobjects) do | ||
| Zeile 131: | Zeile 141: | ||
mw.smw.subobject(o, id) | mw.smw.subobject(o, id) | ||
end | end | ||
-- GeoJson | -- GeoJson | ||
| Zeile 194: | Zeile 194: | ||
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 205: | Zeile 205: | ||
if not com.isEmpty(popuptext) then | if not com.isEmpty(popuptext) then | ||
geoobject_entry["KartePopupText"] = popuptext | geoobject_entry["KartePopupText"] = popuptext | ||
end | |||
end | |||
function attrlist:setAttr(attr, val) | |||
if val ~= nil then | |||
if attrlist[attr] == nil then | |||
attrlist[attr] = {} | |||
end | |||
table.insert(attrlist[attr] or {}, val) | |||
end | end | ||
end | end | ||
return p | return p | ||