Modul:Karte/Work: Unterschied zwischen den Versionen

Keine Bearbeitungszusammenfassung
Keine Bearbeitungszusammenfassung
 
(41 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 7: Zeile 7:
local smw = require("Modul:SMW")
local smw = require("Modul:SMW")
local box = require("Modul:Box")
local box = require("Modul:Box")
local logOn = true -- loggings an/aus


function p.Karte(frame)
function p.Karte(frame)
Zeile 19: Zeile 21:


function p.karte(frame, args)
function p.karte(frame, args)
-- mw.log("karte(frame, args)")
if logOn then
-- mw.logObject(args, "args")
mw.log("karte(frame, args)")
-- Konsolenzeilen zum Debuggen:
end
-- =p.karte(mw.getCurrentFrame(), args)
logObject(args, "args")
-- =p.karte(mw.getCurrentFrame(), {pagename="Zum Adler", location="Restaurant Zum Adler, Fürth, Bayern, Deutschland"})
local t = ""
local t = ""
local kategorien = {}
local kategorien = {}
Zeile 37: Zeile 38:
geoobjects.geojson = {}
geoobjects.geojson = {}
geoobjects.geojson.arg = args["geojson"]
geoobjects.geojson.arg = args["geojson"]
geoobjects.geojson.pagename = geoobjects.geojson.arg or pagename
geoobjects.geojson.pagename = geoobjects.geojson.arg or pagename -- oder implizite GeoJson mit gleichem Seitennamen
geoobjects.geojson.fullpagename = "GeoJson:" .. geoobjects.geojson.pagename
geoobjects.geojson.fullpagename = "GeoJson:" .. geoobjects.geojson.pagename
geoobjects.geojson.url = "{{canonicalurl:" .. geoobjects.geojson.fullpagename .. "}}"
geoobjects.geojson.url =
"{{canonicalurl:" .. geoobjects.geojson.fullpagename .. "}}" -- über diese kommt man schneller dazu, eine neue GeoJson-Karte anzulegen
geoobjects.geojson.exists = wik.pageExists(geoobjects.geojson.fullpagename)
geoobjects.geojson.exists = wik.pageExists(geoobjects.geojson.fullpagename)
geoobjects.geojson.missing =
(geoobjects.geojson.arg ~= nil and not geoobjects.geojson.exists)


-- width/height
-- width/height
Zeile 54: Zeile 58:
end
end


-- geocode location and locationlist
-- geocode location and locationlist -- zerlegt locationlist und versucht geocode zu jeder location
local minimum_one_geocode_ok = false -- Flag, dass mindestens ein geocode erfolgreich war
local minimum_one_geocode_ok = false -- Flag, dass mindestens ein geocode erfolgreich war
-- locationlist und location zusammenführen
-- locationlist in table splitten und mit location zusammenführen
local locationlist = str.splitAndStrip(args["locationlist"] or "", ";")
local locationlist = {}
table.insert(locationlist,
if args["locationlist"] ~= nil then
(args["location"] or "") .. "~" ..
locationlist = str.splitAndStrip(args["locationlist"] or "", ";")
(args["popuptitle"] or "") .. "~" ..
end
(args["popuptext"] or ""))
if args["location"] ~= nil then -- location hinzufügen
-- alle locations durchiterieren und für jedes ein subobject erstellen
table.insert(locationlist, args["location"] .. "~" ..
(args["popuptitle"] or "") .. "~" .. (args["popuptext"] or "")) -- ein leeres ~ ~ wird später wieder bereinigt
end
-- alle locations durchiterieren und für jedes ein geoobject (später subobject) erstellen
for _, l in ipairs(locationlist) do
for _, l in ipairs(locationlist) do
-- Aufteilung location ~ popuptitle ~ popuptext
-- Aufteilung location ~ popuptitle ~ popuptext bzw. l[1] ~ l[2] ~ l[3]
l = str.split2(l, "~")
l = str.split2(l, "~")
local location = str.strip(l[1] or "")
local location = str.nilStrip(l[1])
local popuptitle = str.strip(l[2] or "")
if location ~= nil then
local popuptext = str.strip(l[3] or "")
-- location auswerten
if location ~= "" then
local geoobject_entry = {["Geolokation"] = location,
local geoobject_entry = {["Geolokation"] = location}
["KartePopupTitle"] = str.nilStrip(l[2]),
["KartePopupText"] = str.nilStrip(l[3])}
-- Prüfung Koordinate (Zahl) oder textuelle Objektlokation
-- Prüfung Koordinate (Zahl) oder textuelle Objektlokation
-- wenn Objektlokation und Ehemals, dann nicht auswerten
-- wenn textuelle Objektlokation und Ehemals, dann nicht auswerten,
if string.match(location, "%d") == nil and -- Keine-Zahl-Erkennung. location kann auch Koordinate sein
-- weil diese in OSM nicht mehr vorhanden sind
if string.match(location, "%d") == nil and -- textuellen location (Keine Koordinaten-Zahl)?
  com.isTrue(args["Ehemals"]) then
  com.isTrue(args["Ehemals"]) then
kategorien["Hat Objektlokation, ist aber ehemaliges Objekt"] = true
kategorien["Hat textuelle Objektlokation, ist aber ehemaliges Objekt"] = true
else -- if args["lat"] == nil or args["lon"] == nil then -- to do: dieses if später rausschmeißen nach Aufbau nominatim.fuerthwiki.de
else
local geocode = frame:callParserFunction("#geocode", location)
local geocode = frame:callParserFunction("#geocode", location)
if geocode ~= "Geocoding failed" then
if geocode ~= "Geocoding failed" then -- erfolgreiches geocode
geoobject_entry["Geokoordinate"] = geocode
geoobject_entry["Geokoordinate"] = geocode -- Koordinate übernehmen
geoobject_entry["Quellangaben"] = "location"
geoobject_entry["Quellangaben"] = "location"
minimum_one_geocode_ok = true
minimum_one_geocode_ok = true
Zeile 86: Zeile 95:
kategorien["Hat Geo-Kodierungsfehler"] = true
kategorien["Hat Geo-Kodierungsfehler"] = true
local smw_geokoordinate = mw.smw.ask( -- SMW-Abfrage
local smw_geokoordinate = mw.smw.ask( -- SMW-Abfrage
"[[-Has subobject::" .. pagename .. "]]" ..
"[[-Has subobject::" .. pagename .. "]]" .. -- liefert nil, wenn nix gefunden
"[[SubObjektTyp::Geo]]" ..
"[[Geolokation::" .. location .. "]]" ..
"[[Geolokation::" .. location .. "]]" ..
"|?Geokoordinate|limit=1") or {{}}
"|?Geokoordinate|limit=1") or {{}} -- deswegen {{}}
smw_geokoordinate = smw_geokoordinate[1]["Geokoordinate"]
smw_geokoordinate = smw_geokoordinate[1]["Geokoordinate"] -- 1. Ergebnis (limit=1)
if smw_geokoordinate ~= nil then -- SMW-DB Geokoordinate vorhanden?
if smw_geokoordinate ~= nil then -- SMW-DB Geokoordinate vorhanden?
kategorien["Hat Geo-Kodierungsfehler, aber Geokoordinate in SMW-DB noch vorhanden"] = true
kategorien["Hat Geo-Kodierungsfehler, aber Geokoordinate in SMW-DB noch vorhanden"] = true
geoobject_entry["Geokoordinate"] = smw_geokoordinate
geoobject_entry["Geokoordinate"] = smw_geokoordinate -- SMW-DB-Koordinate übernehmen (beibehalten)
geoobject_entry["Quellangaben"] = "SMW-DB"
geoobject_entry["Quellangaben"] = "SMW-DB"
minimum_one_geocode_ok = true
minimum_one_geocode_ok = true
else
else -- geocode und SMW-DB-Abfrage nicht erfolgreich
kategorien["Hat Geo-Kodierungsfehler und Geokoordinate nicht in SMW-DB vorhanden"] = true
kategorien["Hat Geo-Kodierungsfehler und Geokoordinate nicht in SMW-DB vorhanden"] = true
geoobject_entry["Quellangaben"] = "geocode error"
end
end
end -- if geocode ~= "Geocoding failed" then
end -- if geocode ~= "Geocoding failed" then
end -- if Zahlerkennung
end -- if textuellen location (Keine Koordinaten-Zahl)?
geoobject_entry["KartePopupTitle"] = popuptitle
geoobject_entry["KartePopupText"] = popuptext
table.insert(geoobjects, geoobject_entry)
table.insert(geoobjects, geoobject_entry)
end -- if location ~= "" then
end -- if location ~= nil then
end -- for _, l in ipairs(locations_merged) do
end -- for _, l in ipairs(locationlist) do


-- geocode lon/lat, nur wenn location/locationlist nicht erfolgreich oder ehemals
-- lon/lat, nur wenn location/locationlist nicht erfolgreich oder Ehemals
if (not minimum_one_geocode_ok or com.isTrue(args["Ehemals"])) and  
if (not minimum_one_geocode_ok or com.isTrue(args["Ehemals"])) and  
  args["lat"] ~= nil and args["lon"] ~= nil then
  args["lat"] ~= nil and args["lon"] ~= nil then
local geoobject_entry = {}
local geokoordinate = frame:callParserFunction( -- lat/lon-Angabe in Default-Format konvertieren und prüfen
local geocode = frame:callParserFunction(
"#coordinates", args["lat"] .. "," .. args["lon"])
"#coordinates", args["lat"] .. "," .. args["lon"])
geoobject_entry["Geokoordinate"] = geocode
if string.find(geokoordinate, "error") == nil then -- Fehlermeldung enthält kein "error"
geoobject_entry["Quellangaben"] = "lat/lon"
local geoobject_entry = {
geoobject_entry["KartePopupTitle"] = popuptitle
["Geokoordinate"] = geokoordinate,
geoobject_entry["KartePopupText"] = popuptext
["Quellangaben"] = "lat/lon",
table.insert(geoobjects, geoobject_entry)
["KartePopupTitle"] = str.nilStrip(args["popuptitle"]),
["KartePopupText"] = str.nilStrip(args["popuptext"])}
table.insert(geoobjects, geoobject_entry)
else
kategorien["Hat fehlerhafte Koordinate"] = true
end
end
end
logObject(geoobjects, "geoobjects")


-- Attribute setzen
-- Attribute setzen
if not com.isTrue(args["noattr"]) then
if not com.isTrue(args["noattr"]) then -- kann per noattr deaktiviert werden
-- Geolokation/Geokoordinate setzen
-- Geokoordinate setzen (zusätzlich zu den subobjects für div. Karten-Queries)
for _, o in ipairs(geoobjects) do -- to do: obsolete, wenn sobobject genutzt
for _, o in ipairs(geoobjects) do
setAttr(attrlist, "Geolokation", o["Geolokation"]) -- to do: obsolete, wenn sobobject genutzt
setAttr(attrlist, "Geokoordinate", o["Geokoordinate"])
setAttr(attrlist, "Geokoordinate", o["Geokoordinate"]) -- to do: obsolete, wenn sobobject genutzt
end
end -- to do: obsolete, wenn sobobject genutzt
-- GeoJson
-- GeoJson
if geoobjects.geojson.exists then
if geoobjects.geojson.exists then
Zeile 132: Zeile 146:
-- zoom
-- zoom
setAttr(attrlist, "Zoomlevel", args["zoom"])
setAttr(attrlist, "Zoomlevel", args["zoom"])
-- normale Attribute setzen
-- jetzt "normale" Attribute setzen
-- mw.logObject(attrlist, "attrlist")
logObject(attrlist, "attrlist")
mw.smw.set(attrlist)
mw.smw.set(attrlist)
-- geoobjects als subobjects setzen
-- geoobjects als subobjects setzen
-- mw.logObject(geoobjects, "geoobjects")
for _, o in ipairs(geoobjects) do
for _, o in ipairs(geoobjects) do
o["SubObjektTyp"] = "Geo"
local id = "Geo " ..
o["KartePopupTitle"] = nil -- brauchen nicht gespeichert werden
smw.subobjectIdCleaner(o["Geolokation"] or o["Geokoordinate"])
o["KartePopupText"] = nil
local attrlist = { ["SubObjektTyp"] = "Geo",
local id = "Geo " .. smw.subobjectIdCleaner(o["Geolokation"] or o["Geokoordinate"])
["Geolokation"] = o["Geolokation"],
mw.smw.subobject(o, id)
["Geokoordinate"] = o["Geokoordinate"],
["Quellangaben"] = o["Quellangaben"]}
logObject(id, "id (subobject)")
logObject(attrlist, "attrlist (subobject)")
mw.smw.subobject(attrlist, id)
end
end
end
end


if not com.isTrue(args["nomap"]) then -- keine Karte anzeigen?
-- Karte anzeigen
-- sondern nur geoobjects und SMW-DB
if not com.isTrue(args["nomap"]) then -- keine Karte anzeigen oder nur geoobjects und SMW-DB?
-- Anwendung: Faktenbox, aber mit eigener Karten-Darstellung z.B. Straße
-- Karten-Argumente (display_map) erstellen
-- Karten-Argumente (display_map) erstellen
local map_args = { "", ["zoom"] = args["zoom"], -- gemeinsame settings
local map_args = { "", ["zoom"] = args["zoom"], -- gemeinsame settings und erstmal leere locationlist
["width"] = args["width"], ["height"] = args["height"],
["width"] = args["width"], ["height"] = args["height"], -- map_args[1] = ""
["enablefullscreen"] = "yes", ["resizable"] = "yes"}
["enablefullscreen"] = "yes", ["resizable"] = "yes"}
-- geojson-Argument
-- geojson-Argument
if geoobjects.geojson.exists then
if geoobjects.geojson.exists then
map_args["geojson"] = geoobjects.geojson.pagename
map_args["geojson"] = geoobjects.geojson.pagename
if #geoobjects > 0 then
kategorien["Hat geojson und location/lat/lon"] = true
end
end
end
-- location/lat/lon-Argumente
-- location/lat/lon-Argumente
if not (geoobjects.geojson.exists and -- Pin-Anzeige deaktivieren, wenn GeoJson vorhanden und hide_loc_latlon=Ja
if not (geoobjects.geojson.exists and -- Pin-Anzeige deaktivieren, wenn GeoJson vorhanden und hide_loc_latlon=Ja
com.isTrue(args["hide_loc_latlon"])) then -- SMW-DB wird trotzdem geschrieben
com.isTrue(args["hide_loc_latlon"])) then -- SMW-DB wird trotzdem geschrieben
for _, o in ipairs(geoobjects) do
for _, o in ipairs(geoobjects) do -- Anwendung: Es soll GeoJson-Karte aber ohne die location/lat/lon-Nadeln angezeigt werden
if o["Geokoordinate"] ~= nil then
if o["Geokoordinate"] ~= nil then
if map_args[1] ~= "" then
if map_args[1] ~= "" then
Zeile 168: Zeile 183:
end
end
map_args[1] = map_args[1] .. o["Geokoordinate"]
map_args[1] = map_args[1] .. o["Geokoordinate"]
-- PopUp-Text und -Titel
if o["KartePopupTitle"] ~= nil then
if o["KartePopupTitle"] ~= nil then
map_args[1] = map_args[1] .. "~" .. o["KartePopupTitle"]
map_args[1] = map_args[1] .. "~" .. o["KartePopupTitle"]
if o["KartePopupText"] ~= nil then
if o["KartePopupText"] ~= nil then -- keine Text ohne Titel
map_args[1] = map_args[1] .. "~" .. o["KartePopupText"]
map_args[1] = map_args[1] .. "~" .. o["KartePopupText"]
end
end
Zeile 177: Zeile 193:
end
end
end
end
 
-- Karte (display_map)
-- Karte (display_map)
if map_args[1] ~= "" or map_args["geojson"] ~= nil then
logObject(map_args, "map_args")
-- mw.logObject(map_args, "map_args")
if map_args[1] ~= "" or map_args["geojson"] ~= nil then -- wenn locationlist oder geojson vorhanden
t = t .. frame:callParserFunction("#display_map", map_args)
t = t .. frame:callParserFunction("#display_map", map_args)
if geoobjects.geojson.arg ~= nil and map_args["geojson"] == nil then
if geoobjects.geojson.missing then
t = t .. "<small>Karte [" .. geoobjects.geojson.url .. " " ..
t = t .. "<small>Karte [" .. geoobjects.geojson.url .. " " ..
geoobjects.geojson.arg .. "] nicht gefunden</small>"
geoobjects.geojson.arg .. "] nicht gefunden. </small>"
end
end
-- Fehlermeldung bei geocode-Fehler
if kategorien["Hat Geo-Kodierungsfehler"] then
t = t .. "<small>Geo-Kodierungsfehler: Objekt(e) nicht gefunden. </small>"
end
elseif kategorien["Hat Geo-Kodierungsfehler"] then
t = t .. "Geo-Kodierungsfehler: Objekt(e) nicht gefunden."
else
else
if com.isTrue(args["form"]) then
if com.isTrue(args["form"]) then
Zeile 200: Zeile 222:
geoobjects.geojson.fullpagename ..
geoobjects.geojson.fullpagename ..
"].<br>Siehe auch [[Hilfe:Karten]]"
"].<br>Siehe auch [[Hilfe:Karten]]"
kategorien["Ohne Position"] = true
kategorien["Hat keine Positionsangabe"] = true
end
end
-- Box um Karte
-- Box um Karte
if com.isTrue(args["box"]) then
if com.isTrue(args["box"]) then
local headline = args["headline"] or geoobjects.geojson.arg or pagename
local headline = args["headline"] -- Box-Überschrift
if headline == nil and geoobjects.geojson.exists then
headline = geoobjects.geojson.pagename
end
t = box.box{headline = headline, content = t, textalign = center}
t = box.box{headline = headline, content = t, textalign = center}
end
end
Zeile 218: Zeile 243:
kategorien["Hat Geolokation, aber keine Geokoordinate"] = true
kategorien["Hat Geolokation, aber keine Geokoordinate"] = true
end
end
end
-- Check "Hat geojson und location/lat/lon"
if geoobjects.geojson.exists and #geoobjects > 0 then
kategorien["Hat geojson und location/lat/lon"] = true
end
end
-- Kategorien nun setzen
-- Kategorien nun setzen
for k, _ in pairs(kategorien) do
logObject(kategorien, "kategorien")
t = t .. "[[Kategorie:" .. k .. "]]"
if wik.namespace() == "" then
for k, _ in pairs(kategorien) do
t = t .. "[[Kategorie:" .. k .. "]]"
end
end
end


-- mw.logObject(t, "t")
logObject(t, "t")
t = frame:preprocess(t)
t = frame:preprocess(t)
return t, geoobjects
return t, geoobjects
Zeile 248: Zeile 280:
com.isTrue(args["GeoJsonKarte"])
com.isTrue(args["GeoJsonKarte"])
return argsVorhanden
return argsVorhanden
end
function logObject(...)
if logOn then
mw.logObject(...)
end
end
end


return p
return p

Aktuelle Version vom 18. Dezember 2025, 14:48 Uhr

Die Dokumentation für dieses Modul kann unter Modul:Karte/Work/Doku erstellt werden

p = {}

local com = require("Modul:Common")
local str = require("Modul:String")
local dev = require("Modul:Development")
local wik = require("Modul:Wiki")
local smw = require("Modul:SMW")
local box = require("Modul:Box")

local logOn = true																-- loggings an/aus

function p.Karte(frame)
	local frame, pargs = dev.GetFrameAndParentArgs(frame)
	-- nur die benötigten Argumente übernehmen
	local args = {"lat", "lon", "location", "locationlist", "geojson", "zoom",
		"popuptitle", "popuptext", "box", "headline", "width", "height", "Work"}
	local args = wik.getArgs(pargs, args)
	local t, _ = p.karte(frame, args)
	return t
end

function p.karte(frame, args)
	if logOn then
		mw.log("karte(frame, args)")
	end
	logObject(args, "args")
	local t = ""
	local kategorien = {}
	local attrlist = {}
	local geoobjects = {}
	local pagename = args["pagename"] or wik.pagename()							-- nur zum Debuggen pagename vorgebbar

	-- defaults setzen
	args["box"] = args["box"] or "Ja"
	args["zoom"] = args["zoom"] or "16"

	-- geojson-Angabe auswerten
	geoobjects.geojson = {}
	geoobjects.geojson.arg = args["geojson"]
	geoobjects.geojson.pagename = geoobjects.geojson.arg or pagename			-- oder implizite GeoJson mit gleichem Seitennamen
	geoobjects.geojson.fullpagename = "GeoJson:" .. geoobjects.geojson.pagename
	geoobjects.geojson.url =
		"{{canonicalurl:" .. geoobjects.geojson.fullpagename .. "}}"			-- über diese kommt man schneller dazu, eine neue GeoJson-Karte anzulegen
	geoobjects.geojson.exists = wik.pageExists(geoobjects.geojson.fullpagename)
	geoobjects.geojson.missing =
		(geoobjects.geojson.arg ~= nil and not geoobjects.geojson.exists)

	-- width/height
	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
		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										-- zerlegt locationlist und versucht geocode zu jeder location
	local minimum_one_geocode_ok = false										-- Flag, dass mindestens ein geocode erfolgreich war
	-- locationlist in table splitten und mit location zusammenführen
	local locationlist = {}
	if args["locationlist"] ~= nil then
		locationlist = str.splitAndStrip(args["locationlist"] or "", ";")
	end
	if args["location"] ~= nil then												-- location hinzufügen
		table.insert(locationlist, args["location"] .. "~" ..
			(args["popuptitle"] or "") .. "~" .. (args["popuptext"] or ""))		-- ein leeres ~ ~ wird später wieder bereinigt
	end
	-- alle locations durchiterieren und für jedes ein geoobject (später subobject) erstellen
	for _, l in ipairs(locationlist) do
		-- Aufteilung location ~ popuptitle ~ popuptext bzw. l[1] ~ l[2] ~ l[3]
		l = str.split2(l, "~")
		local location = str.nilStrip(l[1])
		if location ~= nil then
			-- location auswerten
			local geoobject_entry = {["Geolokation"] = location,
				["KartePopupTitle"] = str.nilStrip(l[2]),
				["KartePopupText"] = str.nilStrip(l[3])}
			-- Prüfung Koordinate (Zahl) oder textuelle Objektlokation
			-- wenn textuelle Objektlokation und Ehemals, dann nicht auswerten,
			-- weil diese in OSM nicht mehr vorhanden sind
			if string.match(location, "%d") == nil and							-- textuellen location (Keine Koordinaten-Zahl)?
			   com.isTrue(args["Ehemals"]) then
				kategorien["Hat textuelle Objektlokation, ist aber ehemaliges Objekt"] = true
			else
				local geocode = frame:callParserFunction("#geocode", location)
				if geocode ~= "Geocoding failed" then							-- erfolgreiches geocode
					geoobject_entry["Geokoordinate"] = geocode					-- Koordinate übernehmen
					geoobject_entry["Quellangaben"] = "location"
					minimum_one_geocode_ok = true
				else
					-- geocode nicht erfolgreich => SMW-DB-Eintrag nehmen
					kategorien["Hat Geo-Kodierungsfehler"] = true
					local smw_geokoordinate = mw.smw.ask(						-- SMW-Abfrage
						"[[-Has subobject::" .. pagename .. "]]" ..				-- liefert nil, wenn nix gefunden
						"[[SubObjektTyp::Geo]]" ..
						"[[Geolokation::" .. location .. "]]" ..
						"|?Geokoordinate|limit=1") or {{}}						-- deswegen {{}}
					smw_geokoordinate = smw_geokoordinate[1]["Geokoordinate"]	-- 1. Ergebnis (limit=1)
					if smw_geokoordinate ~= nil then							-- SMW-DB Geokoordinate vorhanden?
						kategorien["Hat Geo-Kodierungsfehler, aber Geokoordinate in SMW-DB noch vorhanden"] = true
						geoobject_entry["Geokoordinate"] = smw_geokoordinate	-- SMW-DB-Koordinate übernehmen (beibehalten)
						geoobject_entry["Quellangaben"] = "SMW-DB"
						minimum_one_geocode_ok = true
					else														-- geocode und SMW-DB-Abfrage nicht erfolgreich
						kategorien["Hat Geo-Kodierungsfehler und Geokoordinate nicht in SMW-DB vorhanden"] = true
						geoobject_entry["Quellangaben"] = "geocode error"
					end
				end -- if geocode ~= "Geocoding failed" then
			end -- if textuellen location (Keine Koordinaten-Zahl)?
			table.insert(geoobjects, geoobject_entry)
		end -- if location ~= nil then
	end -- for _, l in ipairs(locationlist) do

	-- lon/lat, nur wenn location/locationlist nicht erfolgreich oder Ehemals
	if (not minimum_one_geocode_ok or com.isTrue(args["Ehemals"])) and 
	   args["lat"] ~= nil and args["lon"] ~= nil then
		local geokoordinate = frame:callParserFunction(							-- lat/lon-Angabe in Default-Format konvertieren und prüfen
			"#coordinates", args["lat"] .. "," .. args["lon"])
		if string.find(geokoordinate, "error") == nil then						-- Fehlermeldung enthält kein "error"
			local geoobject_entry = {
				["Geokoordinate"] = geokoordinate,
				["Quellangaben"] = "lat/lon",
				["KartePopupTitle"] = str.nilStrip(args["popuptitle"]),
				["KartePopupText"] = str.nilStrip(args["popuptext"])}
			table.insert(geoobjects, geoobject_entry)
		else
			kategorien["Hat fehlerhafte Koordinate"] = true
		end
	end

	logObject(geoobjects, "geoobjects")

	-- Attribute setzen
	if not com.isTrue(args["noattr"]) then										-- kann per noattr deaktiviert werden
		-- Geokoordinate setzen (zusätzlich zu den subobjects für div. Karten-Queries)
		for _, o in ipairs(geoobjects) do
			setAttr(attrlist, "Geokoordinate", o["Geokoordinate"])
		end
		-- GeoJson
		if geoobjects.geojson.exists then
			setAttr(attrlist, "GeoJson", geoobjects.geojson.fullpagename)
		end
		-- zoom
		setAttr(attrlist, "Zoomlevel", args["zoom"])
		-- jetzt "normale" Attribute setzen
		logObject(attrlist, "attrlist")
		mw.smw.set(attrlist)
		-- geoobjects als subobjects setzen
		for _, o in ipairs(geoobjects) do
			local id = "Geo " .. 
				smw.subobjectIdCleaner(o["Geolokation"] or o["Geokoordinate"])
			local attrlist = { ["SubObjektTyp"] = "Geo",
				["Geolokation"] = o["Geolokation"],
				["Geokoordinate"] = o["Geokoordinate"],
				["Quellangaben"] = o["Quellangaben"]}
			logObject(id, "id (subobject)")
			logObject(attrlist, "attrlist (subobject)")
			mw.smw.subobject(attrlist, id)
		end
	end

	-- Karte anzeigen
	if not com.isTrue(args["nomap"]) then										-- keine Karte anzeigen oder nur geoobjects und SMW-DB?
																				-- Anwendung: Faktenbox, aber mit eigener Karten-Darstellung z.B. Straße
		-- Karten-Argumente (display_map) erstellen
		local map_args = { "", ["zoom"] = args["zoom"],							-- gemeinsame settings und erstmal leere locationlist
			["width"] = args["width"], ["height"] = args["height"],				-- map_args[1] = ""
			["enablefullscreen"] = "yes", ["resizable"] = "yes"}
		-- geojson-Argument
		if geoobjects.geojson.exists then
			map_args["geojson"] = geoobjects.geojson.pagename
		end
		-- location/lat/lon-Argumente
		if not (geoobjects.geojson.exists and									-- Pin-Anzeige deaktivieren, wenn GeoJson vorhanden und hide_loc_latlon=Ja
				com.isTrue(args["hide_loc_latlon"])) then						-- SMW-DB wird trotzdem geschrieben
			for _, o in ipairs(geoobjects) do									-- Anwendung: Es soll GeoJson-Karte aber ohne die location/lat/lon-Nadeln angezeigt werden
				if o["Geokoordinate"] ~= nil then
					if map_args[1] ~= "" then
						map_args[1] = map_args[1] .. ";"
					end
					map_args[1] = map_args[1] .. o["Geokoordinate"]
					-- PopUp-Text und -Titel
					if o["KartePopupTitle"] ~= nil then
						map_args[1] = map_args[1] .. "~" .. o["KartePopupTitle"]
						if o["KartePopupText"] ~= nil then						-- keine Text ohne Titel
							map_args[1] = map_args[1] .. "~" .. o["KartePopupText"]
						end
					end
				end
			end
		end

		-- Karte (display_map)
		logObject(map_args, "map_args")
		if map_args[1] ~= "" or map_args["geojson"] ~= nil then					-- wenn locationlist oder geojson vorhanden
			t = t .. frame:callParserFunction("#display_map", map_args)
			if geoobjects.geojson.missing then
				t = t .. "<small>Karte [" .. geoobjects.geojson.url .. " " ..
					geoobjects.geojson.arg .. "] nicht gefunden. </small>"
			end
			-- Fehlermeldung bei geocode-Fehler
			if kategorien["Hat Geo-Kodierungsfehler"] then
				t = t .. "<small>Geo-Kodierungsfehler: Objekt(e) nicht gefunden. </small>"
			end
		elseif kategorien["Hat Geo-Kodierungsfehler"] then
			t = t .. "Geo-Kodierungsfehler: Objekt(e) nicht gefunden."
		else
			if com.isTrue(args["form"]) then
				t = t .. "Positionsangabe fehlt oder fehlende Karte<br>" ..
					geoobjects.geojson.fullpagename ..
					"<br>Bitte Position in Formular eintragen oder"
			else
				t = t .. "Breiten-/Längengrad (lat/lon) fehlt, Objekt-Lokation " ..
				"(location) fehlt oder fehlende Karte<br>" ..
				geoobjects.geojson.fullpagename
			end
			t = t .. "<br>[" .. geoobjects.geojson.url ..
				" Hier klicken zum Anlegen der Karte<br>" ..
				geoobjects.geojson.fullpagename ..
				"].<br>Siehe auch [[Hilfe:Karten]]"
			kategorien["Hat keine Positionsangabe"] = true
		end
	
		-- Box um Karte
		if com.isTrue(args["box"]) then
			local headline = args["headline"]									-- Box-Überschrift
			if headline == nil and geoobjects.geojson.exists then
				headline = geoobjects.geojson.pagename
			end
			t = box.box{headline = headline, content = t, textalign = center}
		end

	end -- if not com.isTrue(args["nomap"]) then

	-- Kategorien setzen
	kategorien["Hat Karte"] = true
	-- Check "Hat Geolokation, aber keine Geokoordinate"
	for _, o in ipairs(geoobjects) do
		if o["Geolokation"] ~= nil and o["Geokoordinate"] == nil then
			kategorien["Hat Geolokation, aber keine Geokoordinate"] = true
		end
	end
	-- Check "Hat geojson und location/lat/lon"
	if geoobjects.geojson.exists and #geoobjects > 0 then
		kategorien["Hat geojson und location/lat/lon"] = true
	end
	-- Kategorien nun setzen
	logObject(kategorien, "kategorien")
	if wik.namespace() == "" then
		for k, _ in pairs(kategorien) do
			t = t .. "[[Kategorie:" .. k .. "]]"
		end
	end

	logObject(t, "t")
	t = frame:preprocess(t)
	return t, geoobjects
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

function p.kartenArgsVorhanden(args)
	local argsVorhanden =
		(not com.isEmpty(args["lat"]) and not com.isEmpty(args["lon"])) or
		not com.isEmpty(args["location"]) or
		not com.isEmpty(args["locationlist"]) or
		not com.isEmpty(args["geojson"]) or
		wik.pageExists("GeoJson:" .. wik.pagename()) or
		com.isTrue(args["GeoJsonKarte"])
	return argsVorhanden
end

function logObject(...)
	if logOn then
		mw.logObject(...)
	end
end

return p