Modul:Karte: Unterschied zwischen den Versionen

Fehlermeldungen von Vorlage:Karte hierher portiert
(location/locationlist von Vorlage:Karte hierher verschoben)
(Fehlermeldungen von Vorlage:Karte hierher portiert)
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 args = {
local args = {"lat", "lon", "location", "locationlist", "geojson", "zoom",
"lat", "lon", "location", "locationlist", "geojson", "geocode",
"popuptitle", "popuptext", "box", "headline", "width", "height",
"zoom", "popuptitle", "popuptext",
"noattr", "Work"}
"box", "headline", "width", "height",
"noattr", "form",
"Work", "Debug"}
local args = wik.getArgs(frame.args, args)
local args = wik.getArgs(frame.args, args)
return p.karte(frame, args)
return p.karte(frame, args)
Zeile 34: Zeile 31:
args["box"] = args["box"] or "Ja"
args["box"] = args["box"] or "Ja"
args["zoom"] = args["zoom"] or "16"
args["zoom"] = args["zoom"] or "16"
args["form"] = args["form"] or "nein"
-- geojson-Angabe auswerten
local geojson_pagename = args["geojson"] or pagename
local geojson_pagename = args["geojson"] or pagename
local geojson_fullpagename = "GeoJson:" .. geojson_pagename
local geojson_fullpagename = "GeoJson:" .. geojson_pagename
local geojson_url = "{{canonicalurl:" .. geojson_fullpagename .. "}}"


-- width/height
-- width/height
Zeile 71: Zeile 72:
  com.isTrue(args["Ehemals"]) then
  com.isTrue(args["Ehemals"]) then
kategorien["Hat Objektlokation, ist aber ehemaliges Objekt"] = true
kategorien["Hat Objektlokation, ist aber ehemaliges Objekt"] = true
else
elseif args["lat"] == nil or args["lon"] == nil then -- to do: dieses if später rausschmeißen nach Aufbau nominatim.fuerthwiki.de
-- location geocode
geocode = getGeocode(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 97: Zeile 94:
end -- if geocode ~= "Geocoding failed" then
end -- if geocode ~= "Geocoding failed" then
end -- if Zahlerkennung
end -- if Zahlerkennung
set_popuptitle_popuptext(geoobject_entry, popuptitle, popuptext)
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 ~= "" then
Zeile 104: Zeile 102:
-- geocode lon/lat, nur wenn location/locationlist nicht erfolgreich oder ehemals
-- geocode 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  
  not com.isEmpty(args["lat"]) and not com.isEmpty(args["lon"]) then
  args["lat"] ~= nil and args["lon"] ~= nil then
local geoobject_entry = {}
local geoobject_entry = {}
-- local geocode = getGeocode(frame, args["lat"] .. "," .. args["lon"])
-- local geocode = getGeocode(frame, args["lat"] .. "," .. args["lon"])
Zeile 114: Zeile 112:
kategorien["Hat Geo-Kodierungsfehler"] = true
kategorien["Hat Geo-Kodierungsfehler"] = true
end
end
set_popuptitle_popuptext(geoobject_entry, popuptitle, popuptext)
geoobject_entry["KartePopupTitle"] = popuptitle
geoobject_entry["KartePopupText"] = popuptext
table.insert(geoobjects, geoobject_entry)
table.insert(geoobjects, geoobject_entry)
end
end
Zeile 143: Zeile 142:
end
end


-- Karte
-- Karten-Argumente (display_map) erstellen
local map_args = { "", ["zoom"] = args["zoom"], -- gemeinsame settings
local map_args = { "", ["zoom"] = args["zoom"], -- gemeinsame settings
["width"] = args["width"], ["height"] = args["height"],
["width"] = args["width"], ["height"] = args["height"],
Zeile 171: Zeile 170:
end
end
end
end
-- Karte (display_map)
if map_args[1] ~= "" or map_args["geojson"] ~= nil then
if map_args[1] ~= "" or map_args["geojson"] ~= nil then
mw.logObject(map_args, "map_args")
mw.logObject(map_args, "map_args")
t = t .. frame:callParserFunction("#display_map", map_args)
t = t .. frame:callParserFunction("#display_map", map_args)
if args["geojson"] ~= nil and map_args["geojson"] == nil then
t = t .. "<small>Karte [" .. geojson_url .. " " .. args["geojson"] .. "] nicht gefunden</small>"
end
else
else
-- bisherige Vorlagen-Karte
if com.isTrue(args["form"]) then
local karte_vorlage = "Karte/Legacy"
t = t .. "Positionsangabe fehlt oder fehlende Karte<br>" .. geojson_fullpagename .. "<br>Bitte Position in Formular eintragen oder"
if com.isTrue(args["Work"]) then
else
karte_vorlage = karte_vorlage .. "/Work"
t = t .. "Breiten-/Längengrad (lat/lon) fehlt, Objekt-Lokation (location) fehlt oder fehlende Karte<br>" .. geojson_fullpagename
-- args["Debug"] = "Ja"
end
end
mw.logObject(args, "args zur Vorlage " .. karte_vorlage)
t = t .. "<br>[" .. geojson_url .. " Hier klicken zum Anlegen der Karte<br>" .. geojson_fullpagename .. "].<br>Siehe auch [[Hilfe:Karten]]"
t = t .. frame:expandTemplate{title = karte_vorlage, args = args}
kategorien["Ohne Position"] = true
end
end


-- Box drum herum
-- Box um Karte
if com.isTrue(args["box"]) then
if com.isTrue(args["box"]) then
local headline = args["headline"] or args["geojson"] or pagename
local headline = args["headline"] or args["geojson"] or pagename
Zeile 212: Zeile 215:
return frame:callParserFunction(
return frame:callParserFunction(
"#geocode", {location, format="float", directional="no"})
"#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
end