Modul:Karte/Work: Unterschied zwischen den Versionen

Keine Bearbeitungszusammenfassung
Keine Bearbeitungszusammenfassung
 
(53 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 5: Zeile 5:
local wik = require("Modul:Wiki")
local wik = require("Modul:Wiki")
local smw = require("Modul:SMW")
local smw = require("Modul:SMW")
local box = require("Modul:Box")


function p.Karte(frame)
function p.Karte(frame)
Zeile 12: Zeile 13:
"zoom", "popuptitle", "popuptext",
"zoom", "popuptitle", "popuptext",
"box", "headline", "width", "height",
"box", "headline", "width", "height",
"noattr", "form"}
"noattr", "form",
args = wik.getArgs(frame.args, args)
"Work", "Debug"}
local args = wik.getArgs(frame.args, args)
return p.karte(frame, args)
return p.karte(frame, args)
end
end
Zeile 24: Zeile 26:
-- =p.karte(mw.getCurrentFrame(), {pagename="Zum Adler", location="Restaurant Zum Adler, Fürth, Bayern, Deutschland"})
-- =p.karte(mw.getCurrentFrame(), {pagename="Zum Adler", location="Restaurant Zum Adler, Fürth, Bayern, Deutschland"})
local t = ""
local t = ""
local pagename = args["pagename"] or wik.pagename() -- nur zum Debugging pagename vorgebbar
local geoobjects = {}
local kategorien = {}
local attrlist = {}
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"
local geojson_pagename = args["geojson"] or pagename
local geojson_fullpagename = "GeoJson:" .. geojson_pagename
 
-- 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
-- geocode location and locationlist
local geoobjects = {}
local minimum_one_geocode_ok = false -- Flag, dass mindestens ein geocode erfolgreich war
local minimum_one_geocode_ok = false
-- locationlist und location zusammenführen
if not com.isTrue(args["Ehemals"]) then
local locationlist = str.splitAndStrip(args["locationlist"] or "", ";")
-- locationlist und location zusammenführen
table.insert(locationlist,
local locations_merged = str.splitAndStrip(args["locationlist"] or "", ";")
(args["location"] or "") .. "~" ..
local location = str.strip(args["location"] or "")
(args["popuptitle"] or "") .. "~" ..
(args["popuptext"] or ""))
-- alle locations durchiterieren und für jedes ein subobject erstellen
for _, l in ipairs(locationlist) do
-- Aufteilung location ~ popuptitle ~ popuptext
l = str.split2(l, "~")
local location = str.strip(l[1] or "")
local popuptitle = str.strip(l[2] or "")
local popuptext = str.strip(l[3] or "")
if location ~= "" then
if location ~= "" then
table.insert(locations_merged, args["location"] ..
local geoobject_entry = {["Geolokation"] = location}
"~" .. (args["popuptitle"] or "") ..
-- Prüfung Koordinate (Zahl) oder textuelle Objektlokation
"~" .. (args["popuptext"] or ""))
-- wenn Objektlokation und Ehemals, dann nicht auswerten
end
if string.match(location, "%d") == nil and -- Keine-Zahl-Erkennung
-- alle locations durchiterieren und für jedes ein subobject erstellen
  com.isTrue(args["Ehemals"]) then
for _, l in ipairs(locations_merged) do
kategorien["Hat Objektlokation, ist aber ehemaliges Objekt"] = true
local geoobject_entry = {}
else
-- Aufteilung location ~ popuptitle ~ popuptext
-- location geocode
l = str.split2(l, "~")
local geocode = "Geocoding failed" -- to do: diesen Block später rausschmeißen nach Aufbau nominatim.fuerthwiki.de
local location = str.strip(l[1] or "")
if com.isEmpty(args["lat"]) or com.isEmpty(args["lon"]) then -- to do: diesen Block später rausschmeißen nach Aufbau nominatim.fuerthwiki.de
local popuptitle = str.strip(l[2] or "")
geocode = getGeocode(frame, location) -- to do: nur diese Zeile bleibt übrig (mit local)
local popuptext = str.strip(l[3] or "")
end -- to do: diesen Block später rausschmeißen nach Aufbau nominatim.fuerthwiki.de
-- location geocode
if location ~= "" then
geoobject_entry["Geolokation"] = location
local geocode = frame:callParserFunction(
"#geocode", {location, format="float", directional="no"})
if geocode ~= "Geocoding failed" then
if geocode ~= "Geocoding failed" then
geoobject_entry["Geokoordinate"] = geocode
geoobject_entry["Geokoordinate"] = geocode
geoobject_entry["Quellangaben"] = "location"
minimum_one_geocode_ok = true
minimum_one_geocode_ok = true
else
else
smw_geokoordinate = mw.smw.ask(
-- geocode nicht erfolgreich => SMW-DB nehmen
kategorien["Hat Geo-Kodierungsfehler"] = true
local smw_geokoordinate = mw.smw.ask(
"[[-Has subobject::" .. pagename .. "]]" ..
"[[-Has subobject::" .. pagename .. "]]" ..
"[[Geolokation::" .. location .. "]]" ..
"[[Geolokation::" .. location .. "]]" ..
"|?Geokoordinate|limit=1")
"|?Geokoordinate|limit=1") or {{}}
if smw_geokoordinate ~= nil and
smw_geokoordinate = smw_geokoordinate[1]["Geokoordinate"]
smw_geokoordinate[1]["Geokoordinate"] ~= nil then
if smw_geokoordinate ~= nil then -- SMW-DB Geokoordinate vorhanden?
geoobject_entry["Geokoordinate"] =
kategorien["Hat Geo-Kodierungsfehler, aber Geokoordinate in SMW-DB noch vorhanden"] = true
smw_geokoordinate[1]["Geokoordinate"]
geoobject_entry["Geokoordinate"] = smw_geokoordinate
geoobject_entry["Quellangaben"] = "SMW-DB"
minimum_one_geocode_ok = true
minimum_one_geocode_ok = true
end
end
end
end -- if geocode ~= "Geocoding failed" then
end
end -- if Zahlerkennung
-- popuptitle und popuptext ablegen
set_popuptitle_popuptext(geoobject_entry, popuptitle, popuptext)
if popuptitle ~= "" then
geoobject_entry["KartePopupTitle"] = popuptitle
end
if popuptext ~= "" then
geoobject_entry["KartePopupText"] = popuptext
end
-- subobject in Liste aufnehmen
table.insert(geoobjects, geoobject_entry)
table.insert(geoobjects, geoobject_entry)
end -- if location ~= "" then
end -- for _, l in ipairs(locations_merged) do
-- geocode lon/lat, nur wenn location/locationlist nicht erfolgreich oder ehemals
if (not minimum_one_geocode_ok or com.isTrue(args["Ehemals"])) and
  not com.isEmpty(args["lat"]) and not com.isEmpty(args["lon"]) then
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
geoobject_entry["Geokoordinate"] = geocode
geoobject_entry["Quellangaben"] = "lat/lon"
else
kategorien["Hat Geo-Kodierungsfehler"] = true
end
end
set_popuptitle_popuptext(geoobject_entry, popuptitle, popuptext)
table.insert(geoobjects, geoobject_entry)
end
end


-- geocode lon/lat
-- Attribute setzen
if (not minimum_one_geocode_ok or com.isTrue(args["Ehemals"])) and args["lat"] ~= nil and args["lon"] ~= nil then
if not com.isTrue(args["noattr"]) then
local geocode = frame:callParserFunction("#geocode", {args["lat"] .. "," .. args["lon"], format="float", directional="no"})
-- Geolokation/Geokoordinate setzen
if geocode ~= "Geocoding failed" then
for _, o in ipairs(geoobjects) do -- to do: obsolete, wenn sobobject genutzt
local geoobject_entry = {}
setAttr(attrlist, "Geolokation", o["Geolokation"]) -- to do: obsolete, wenn sobobject genutzt
geoobject_entry["Geokoordinate"] = geocode
setAttr(attrlist, "Geokoordinate", o["Geokoordinate"]) -- to do: obsolete, wenn sobobject genutzt
if popuptitle ~= "" then
end -- to do: obsolete, wenn sobobject genutzt
geoobject_entry["KartePopupTitle"] = popuptitle
-- GeoJson
end
if wik.pageExists(geojson_fullpagename) then
if popuptext ~= "" then
setAttr(attrlist, "GeoJson", geojson_fullpagename)
geoobject_entry["KartePopupText"] = popuptext
end
end
-- zoom
table.insert(geoobjects, geoobject_entry)
setAttr(attrlist, "Zoomlevel", args["zoom"])
-- normale Attribute setzen
mw.logObject(attrlist, "attrlist")
mw.smw.set(attrlist)
-- geoobjects als subobjects setzen
mw.logObject(geoobjects, "geoobjects")
for _, o in ipairs(geoobjects) do
o["SubObjektTyp"] = "Geo"
local id = smw.subobjectIdCleaner(o["Geolokation"] or o["Geokoordinate"])
mw.smw.subobject(o, id)
end
end
end
end
 
-- geoobjects setzen
-- Karte
mw.logObject(geoobjects, "geoobjects")
local map_args = { -- gemeinsame settings
for _, o in ipairs(geoobjects) do
["width"] = args["width"], ["height"] = args["height"],
o["SubObjektTyp"] = "Geo"
["zoom"] = args["zoom"],  
local id = smw.subobjectIdCleaner(o["Geolokation"] or o["Geokoordinate"])
["enablefullscreen"] = "yes", ["resizable"] = "yes"}
mw.smw.subobject(o, id)
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
end


-- bisherige Vorlagen-Karte
-- bisherige Vorlagen-Karte
t = t .. frame:expandTemplate{title = "Karte/Legacy", args = args}
if not display_map then
local karte_vorlage = "Karte/Legacy"
if com.isTrue(args["Work"]) then
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
 
-- Box drum herum
if com.isTrue(args["box"]) then
local headline = args["headline"] or args["geojson"] or pagename
t = box.box{headline = headline, content = t, textalign = center}
end
 
-- Kategorien setzen
kategorien["Hat Karte"] = true
-- Check "Hat Geolokation, aber keine Geokoordinate"
-- for _, o in ipairs(geoobjects) do -- Check "Hat Geolokation, aber keine Geokoordinate"
-- if o["Geolokation"] ~= nil and o["Geokoordinate"] == nil then
-- kategorien["Hat Geolokation, aber keine Geokoordinate"] = true
-- end
-- end
hat_geolokation = false -- to do: diesen Block später rausschmeißen und obigen aktivieren, wenn fertig
hat_geokoordinate = false -- to do: diesen Block später rausschmeißen und obigen aktivieren, wenn fertig
for _, o in ipairs(geoobjects) do -- to do: diesen Block später rausschmeißen und obigen aktivieren, wenn fertig
hat_geolokation = hat_geolokation or (o["Geolokation"] ~= nil) -- to do: diesen Block später rausschmeißen und obigen aktivieren, wenn fertig
hat_geokoordinate = hat_geokoordinate or (o["Geokoordinate"] ~= nil) -- to do: diesen Block später rausschmeißen und obigen aktivieren, wenn fertig
end -- to do: diesen Block später rausschmeißen und obigen aktivieren, wenn fertig
if hat_geolokation and not hat_geokoordinate then -- to do: diesen Block später rausschmeißen und obigen aktivieren, wenn fertig
kategorien["Hat Geolokation, aber keine Geokoordinate"] = true -- to do: diesen Block später rausschmeißen und obigen aktivieren, wenn fertig
end -- to do: diesen Block später rausschmeißen und obigen aktivieren, wenn fertig
-- nun setzen
for k, _ in pairs(kategorien) do
t = t .. "[[Kategorie:" .. k .. "]]"
end


mw.logObject(t, "t")
mw.logObject(t, "t")
t = frame:preprocess(t)
return t
return t
end
function getGeocode(frame, location)
return frame:callParserFunction(
"#geocode", {location, format="float", directional="no"})
end
function set_popuptitle_popuptext(geoobject_entry, popuptitle, popuptext)
if not com.isEmpty(popuptitle) then
geoobject_entry["KartePopupTitle"] = popuptitle
end
if not com.isEmpty(popuptext) then
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


return p
return p

Aktuelle Version vom 12. Dezember 2025, 18:51 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 wik = require("Modul:Wiki")
local smw = require("Modul:SMW")
local box = require("Modul:Box")

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

function p.karte(frame, args)
	mw.log("karte(frame, args)")
	mw.logObject(args, "args")
	-- Konsolenzeilen zum Debuggen:
	-- =p.karte(mw.getCurrentFrame(), args)
	-- =p.karte(mw.getCurrentFrame(), {pagename="Zum Adler", location="Restaurant Zum Adler, Fürth, Bayern, Deutschland"})
	local t = ""
	local geoobjects = {}
	local kategorien = {}
	local attrlist = {}
	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"
	local geojson_pagename = args["geojson"] or pagename
	local geojson_fullpagename = "GeoJson:" .. geojson_pagename

	-- 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
	local minimum_one_geocode_ok = false										-- Flag, dass mindestens ein geocode erfolgreich war
	-- locationlist und location zusammenführen
	local locationlist = str.splitAndStrip(args["locationlist"] or "", ";")
	table.insert(locationlist,
		(args["location"] or "") .. "~" ..
		(args["popuptitle"] or "") .. "~" ..
		(args["popuptext"] or ""))
	-- alle locations durchiterieren und für jedes ein subobject erstellen
	for _, l in ipairs(locationlist) do
		-- Aufteilung location ~ popuptitle ~ popuptext
		l = str.split2(l, "~")
		local location = str.strip(l[1] or "")
		local popuptitle = str.strip(l[2] or "")
		local popuptext = str.strip(l[3] or "")
		if location ~= "" then
			local geoobject_entry = {["Geolokation"] = location}
			-- Prüfung Koordinate (Zahl) oder textuelle Objektlokation
			-- wenn Objektlokation und Ehemals, dann nicht auswerten
			if string.match(location, "%d") == nil and -- Keine-Zahl-Erkennung
			   com.isTrue(args["Ehemals"]) then
				kategorien["Hat Objektlokation, ist aber ehemaliges Objekt"] = true
			else
				-- location geocode
				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
					geoobject_entry["Geokoordinate"] = geocode
					geoobject_entry["Quellangaben"] = "location"
					minimum_one_geocode_ok = true
				else
					-- geocode nicht erfolgreich => SMW-DB nehmen
					kategorien["Hat Geo-Kodierungsfehler"] = true
					local smw_geokoordinate = mw.smw.ask(
						"[[-Has subobject::" .. pagename .. "]]" ..
						"[[Geolokation::" .. location .. "]]" ..
						"|?Geokoordinate|limit=1") or {{}}
					smw_geokoordinate = smw_geokoordinate[1]["Geokoordinate"]
					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
						geoobject_entry["Quellangaben"] = "SMW-DB"
						minimum_one_geocode_ok = true
					end
				end -- if geocode ~= "Geocoding failed" then
			end -- if Zahlerkennung
			set_popuptitle_popuptext(geoobject_entry, popuptitle, popuptext)
			table.insert(geoobjects, geoobject_entry)
		end -- if location ~= "" then
	end -- for _, l in ipairs(locations_merged) do

	-- geocode lon/lat, nur wenn location/locationlist nicht erfolgreich oder ehemals
	if (not minimum_one_geocode_ok or com.isTrue(args["Ehemals"])) and 
	   not com.isEmpty(args["lat"]) and not com.isEmpty(args["lon"]) then
		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
			geoobject_entry["Geokoordinate"] = geocode
			geoobject_entry["Quellangaben"] = "lat/lon"
		else
			kategorien["Hat Geo-Kodierungsfehler"] = true
		end
		set_popuptitle_popuptext(geoobject_entry, popuptitle, popuptext)
		table.insert(geoobjects, geoobject_entry)
	end

	-- Attribute setzen
	if not com.isTrue(args["noattr"]) then
		-- Geolokation/Geokoordinate 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")
		for _, o in ipairs(geoobjects) do
			o["SubObjektTyp"] = "Geo"
			local id = smw.subobjectIdCleaner(o["Geolokation"] or o["Geokoordinate"])
			mw.smw.subobject(o, id)
		end
	end

	-- Karte
	local map_args = {															-- gemeinsame settings
		["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
	if not display_map then
		local karte_vorlage = "Karte/Legacy"
		if com.isTrue(args["Work"]) then
			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

	-- Box drum herum
	if com.isTrue(args["box"]) then
		local headline = args["headline"] or args["geojson"] or pagename
		t = box.box{headline = headline, content = t, textalign = center}
	end

	-- Kategorien setzen
	kategorien["Hat Karte"] = true
	-- Check "Hat Geolokation, aber keine Geokoordinate"
--	for _, o in ipairs(geoobjects) do											-- Check "Hat Geolokation, aber keine Geokoordinate"
--		if o["Geolokation"] ~= nil and o["Geokoordinate"] == nil then
--			kategorien["Hat Geolokation, aber keine Geokoordinate"] = true
--		end
--	end
	hat_geolokation = false														-- to do: diesen Block später rausschmeißen und obigen aktivieren, wenn fertig
	hat_geokoordinate = false													-- to do: diesen Block später rausschmeißen und obigen aktivieren, wenn fertig
	for _, o in ipairs(geoobjects) do											-- to do: diesen Block später rausschmeißen und obigen aktivieren, wenn fertig
		hat_geolokation = hat_geolokation or (o["Geolokation"] ~= nil)			-- to do: diesen Block später rausschmeißen und obigen aktivieren, wenn fertig
		hat_geokoordinate = hat_geokoordinate or (o["Geokoordinate"] ~= nil)	-- to do: diesen Block später rausschmeißen und obigen aktivieren, wenn fertig
	end																			-- to do: diesen Block später rausschmeißen und obigen aktivieren, wenn fertig
	if hat_geolokation and not hat_geokoordinate then							-- to do: diesen Block später rausschmeißen und obigen aktivieren, wenn fertig
		kategorien["Hat Geolokation, aber keine Geokoordinate"] = true			-- to do: diesen Block später rausschmeißen und obigen aktivieren, wenn fertig
	end																			-- to do: diesen Block später rausschmeißen und obigen aktivieren, wenn fertig
	-- nun setzen
	for k, _ in pairs(kategorien) do
		t = t .. "[[Kategorie:" .. k .. "]]"
	end

	mw.logObject(t, "t")
	t = frame:preprocess(t)
	return t
end

function getGeocode(frame, location)
	return frame:callParserFunction(
		"#geocode", {location, format="float", directional="no"})
end

function set_popuptitle_popuptext(geoobject_entry, popuptitle, popuptext)
	if not com.isEmpty(popuptitle) then
		geoobject_entry["KartePopupTitle"] = popuptitle
	end
	if not com.isEmpty(popuptext) then
		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

return p