Modul:Karte: Unterschied zwischen den Versionen
(+ subobjectIdCleaner()) |
(geocode format="float", directional="no". lat/lon mit popuptitle und popuptext) |
||
| Zeile 45: | Zeile 45: | ||
if location ~= "" then | if location ~= "" then | ||
subobject_entry["Geolokation"] = location | subobject_entry["Geolokation"] = location | ||
local geocode = frame:callParserFunction("#geocode", location) | local geocode = frame:callParserFunction("#geocode", {location, format="float", directional="no"}) | ||
if geocode ~= "Geocoding failed" then | if geocode ~= "Geocoding failed" then | ||
subobject_entry["Geokoordinate"] = geocode | subobject_entry["Geokoordinate"] = geocode | ||
| Zeile 65: | Zeile 65: | ||
-- geocode lon/lat | -- geocode lon/lat | ||
if (not minimum_one_geocode_ok or com.isTrue(args["Ehemals"])) and args["lat"] ~= nil and args["lon"] ~= nil then | if (not minimum_one_geocode_ok or com.isTrue(args["Ehemals"])) and args["lat"] ~= nil and args["lon"] ~= nil then | ||
local geocode = frame:callParserFunction("#geocode", args["lat"] .. "," .. args["lon"]) | local geocode = frame:callParserFunction("#geocode", {args["lat"] .. "," .. args["lon"], format="float", directional="no"}) | ||
if geocode ~= "Geocoding failed" then | if geocode ~= "Geocoding failed" then | ||
local subobject_entry = {} | local subobject_entry = {} | ||
subobject_entry["Geokoordinate"] = geocode | subobject_entry["Geokoordinate"] = geocode | ||
if popuptitle ~= "" then | |||
subobject_entry["KartePopupTitle"] = popuptitle | |||
end | |||
if popuptext ~= "" then | |||
subobject_entry["KartePopupText"] = popuptext | |||
end | |||
table.insert(subobjects, subobject_entry) | table.insert(subobjects, subobject_entry) | ||
end | end | ||
end | end | ||
-- subobjects setzen | -- subobjects setzen | ||
mw.logObject(subobjects, "subobjects") | |||
for _, s in ipairs(subobjects) do | for _, s in ipairs(subobjects) do | ||
s["SubObjektTyp"] = "Geo" | s["SubObjektTyp"] = "Geo" | ||
Version vom 9. Dezember 2025, 21:22 Uhr
Modul:Karte
Zusätzliche Parameter karte()
| Parameter | Beschreibung | Typ | Status | |
|---|---|---|---|---|
| Keine Attribute setzen. | noattr |
| Wahrheitswert | optional |
| Keine Karte rendern. | nomap |
| Wahrheitswert | optional |
| Keine Wartungsmeldungen ausgeben. | nowarn |
| Wahrheitswert | optional |
| Karte befindet sich in Seite mit Formular | form | keine Beschreibung
| Wahrheitswert | optional |
| Ehemals | Ehemals | keine Beschreibung
| Wahrheitswert | optional |
| location/locationlist/lat/lon Nadeln ausblenden, wenn GeoJson vorhanden | hide_loc_latlon | keine Beschreibung
| Wahrheitswert | optional |
geoobjects-Daten-table
geoobjects[]Einzel-Objekte (table)geoobjects[]["Geolokation"]geoobjects[]["Geokoordinate"]geoobjects[]["Quellangaben"]= Quelle von Geokoordinategeoobjects[]["KartePopupTitle"]geoobjects[]["KartePopupText"]
geoobjects.geojsonGeoJson-Datengeoobjects.geojson.arg= übergebenes GeoJson-Argumentgeoobjects.geojson.pagename= GeoJson-Seitenname ohne "GeoJson:"geoobjects.geojson.fullpagename= GeoJson-Seitenname mit "GeoJson:"geoobjects.geojson.url= GeoJson-URL (über diese kommt man schneller dazu, eine neue GeoJson-Karte anzulegen)geoobjects.geojson.exists= GeoJson-Karte existiertgeoobjects.geojson.missing= GeoJson-Karte explizit angegeben, aber existiert nicht
Vorlage:Karte
Diese Vorlage zeigt eine Karte wahlweise in einer oder ohne Box an.
| Parameter | Beschreibung | Typ | Status | |
|---|---|---|---|---|
| Breitengrad | lat |
| Zahlenwert | optional |
| Längengrad | lon |
| Zahlenwert | optional |
| Objekt-Lokation | location |
| Einzeiliger Text | optional |
| Objekt-Lokations-Liste | locationlist | Siehe Beispiele unten
| Einzeiliger Text | optional |
| GeoJson-Karte | geojson | Kartenname ohne 'GeoJson:' | Seitenname | optional |
| Zoom-Faktor | zoom | keine Beschreibung
| Zahlenwert | optional |
| Popup-Titel | popuptitle | Wird angezeigt, wenn Maus über location-Pin. Darf auch Links enthalten. Bei einer grafischen GeoJson-Karte wird der Popup-Titel im grafischen Editor für jedes Element (Pin, Linie, Fläche) einzeln eingetragen und dieser Parameter wird ignoriert. Nicht bei Objekt-Lokations-Liste (locationlist). | Einzeiliger Text | optional |
| Popup-Text | popuptext | Wird angezeigt, wenn Maus über location-Pin. Darf auch Links enthalten. Bei einer grafischen GeoJson-Karte wird der Popup-Titel im grafischen Editor für jedes Element (Pin, Linie, Fläche) einzeln eingetragen und dieser Parameter wird ignoriert. Nicht bei Objekt-Lokations-Liste (locationlist). | Mehrzeiliger Text | optional |
| Box-Anzeige: Karte in einer Box oder ohne. | box | Entweder 'ja' oder 'nein'
| Wahrheitswert | optional |
| Box-Überschrift | headline | Wenn eingebunden in einer Box. Darf auch Links enthalten.
| Einzeiliger Text | optional |
| Kartenbreite | width | Entweder in Prozent oder in Pixel angegeben (wenn NICHT eingebunden in einer Box)
| Zahlenwert | optional |
| Kartenhöhe | height | Entweder in Prozent oder in Pixel angegeben (wenn NICHT eingebunden in einer Box)
| Zahlenwert | optional |
Einbindung
Möglichkeiten/Parameter zur Einbindung:
- Bei Angabe einer Koordinate (
lat/lon-Wertepaar):
{{ Karte | lat=... | lon=... | zoom=... | headline=... | popuptitle=... | popuptext=... | box=... | width=... | height=... }}
- Bei Angabe von Objekt-Lokation (
location):
{{ Karte | location=... | zoom=... | headline=... | popuptitle=... | popuptext=... | box=... | width=... | height=... }}
- Bei Angabe von Liste mit Objekt-Lokationen (
locationlist):
{{ Karte | locationlist=... | zoom=... | headline=... | box=... | width=... | height=... }}
- Bei Angabe von grafischer GeoJson-Karte2) (
geojson):
{{ Karte | geojson=... | zoom=... | headline=... | box=... | width=... | height=... }}
- Bei Angabe von grafischer GeoJson-Karte und Koordinate2),3):
{{ Karte | geojson=... | lat=... | lon=... | zoom=... | headline=... | box=... | width=... | height=... }}
- Bei Angabe von grafischer GeoJson-Karte und Objekt-Lokation2),3):
{{ Karte | geojson=... | location=... | zoom=... | headline=... | box=... | width=... | height=... }}
- Grafische GeoJson-Karte mit gleichem Seitennamen1),2):
{{ Karte | zoom=... | headline=... | box=... | width=... | height=... }}
- Anmerkungen
1) Wenn weder lat/lon noch location noch locationlist noch geojson angegeben sind, dann wird implizit die GesJson-Karte mit gleichem Seitennamen wie die eigentliche Seite angenommen. Beispiel: GeoJson:Pegnitz ist die zu Pegnitz gehörende Karte.
2) Wenn die GesJson-Karte (noch) nicht existiert, erscheint eine entsprechende Meldung mit der Klick-Möglichkeit, diese neu anzulegen.
3) Wenn geojson und zusätzlich location bzw. lat/lon übergeben werden, dann wird die GeoJson-Karte angezeigt, aber location bzw. lat/lon als Geokoordinate (Semantic) gesetzt. Zweck ist, dass man der Karte eine (Mitten-)Position mitgeben kann, damit sie z. B. per Semantisches Browsen gefunden werden kann.
Beispiele
Lua-Fehler: expandTemplate: template "Karte/Legacy" does not exist
{{Karte|lat=49.4805779|lon=10.9978422|zoom=17}}
Lua-Fehler: expandTemplate: template "Karte/Legacy" does not exist
{{Karte|location=Uhrenhäusla, Fürth, Bayern, Deutschland|zoom=17}}
Lua-Fehler: expandTemplate: template "Karte/Legacy" does not exist
{{Karte|location=Uhrenhäusla, Fürth, Bayern, Deutschland|headline=Hier steht das Uhrenhäusla|zoom=17}}
Lua-Fehler: expandTemplate: template "Karte/Legacy" does not exist
{{Karte|location=Uhrenhäusla, Fürth, Bayern, Deutschland|headline=Hier steht das Uhrenhäusla|popuptitle=Uhrenhäusla|popuptext=Siehe Uhrenhäusla|zoom=17}}
Lua-Fehler: expandTemplate: template "Karte/Legacy" does not exist
{{Karte|locationlist=Uhrenhäusla, Fürth, Bayern, Deutschland|zoom=17}}
Lua-Fehler: expandTemplate: template "Karte/Legacy" does not exist
{{Karte|locationlist=Uhrenhäusla, Fürth, Bayern, Deutschland; Rathaus Rathaus, Fürth, Bayern, Deutschland|zoom=15}}
Lua-Fehler: expandTemplate: template "Karte/Legacy" does not exist
{{Karte|locationlist=Uhrenhäusla, Fürth, Bayern, Deutschland ~ Uhrenhäusla ~ Hier steht das Uhrenhäusla; Rathaus Rathaus, Fürth, Bayern, Deutschland ~ Rathaus ~ Hier steht das Rathaus|zoom=15}}
Lua-Fehler: expandTemplate: template "Karte/Legacy" does not exist
{{Karte|geojson=Südstadt|headline=Südstadt|zoom=13}}
Lua-Fehler: expandTemplate: template "Karte/Legacy" does not exist
{{Karte|lat=49.4805779|lon=10.9978422|geojson=BlaBla|zoom=17}}
Lua-Fehler: expandTemplate: template "Karte/Legacy" does not exist
{{Karte|location=Uhrenhäusla, Fürth, Bayern, Deutschland|geojson=BlaBla|zoom=17}}
Lua-Fehler: expandTemplate: template "Karte/Legacy" does not exist
{{Karte|zoom=14}}
Lua-Fehler: expandTemplate: template "Karte/Legacy" does not exist
{{Karte|geojson=BlaBla}}
Lua-Fehler: expandTemplate: template "Karte/Legacy" does not exist
{{Karte|lat=49.4805779|lon=10.9978422|box=nein}}
Lua-Fehler: expandTemplate: template "Karte/Legacy" does not exist
{{Karte|lat=49.4805779|lon=10.9978422|box=nein|width=100%|height=500}}
Siehe auch
Unterseiten
Siehe auch
p = {}
local com = require("Modul:Common")
local str = require("Modul:String")
local wik = require("Modul:Wiki")
local smw = require("Modul:SMW")
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"}
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")
local t = ""
-- geocode location and locationlist
local subobjects = {}
local minimum_one_geocode_ok = false
if not com.isTrue(args["Ehemals"]) then
-- locationlist und location zusammenführen
local locations_merged = str.splitAndStrip(args["locationlist"] or "", ";")
local location = str.strip(args["location"] or "")
if location ~= "" then
table.insert(locations_merged, args["location"] ..
"~" .. (args["popuptitle"] or "") ..
"~" .. (args["popuptext"] or ""))
end
-- alle locations durchiterieren und für jedes ein subobject erstellen
for _, l in ipairs(locations_merged) do
local subobject_entry = {}
-- 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 "")
-- location geocode
if location ~= "" then
subobject_entry["Geolokation"] = location
local geocode = frame:callParserFunction("#geocode", {location, format="float", directional="no"})
if geocode ~= "Geocoding failed" then
subobject_entry["Geokoordinate"] = geocode
minimum_one_geocode_ok = true
end
end
-- popuptitle und popuptext ablegen
if popuptitle ~= "" then
subobject_entry["KartePopupTitle"] = popuptitle
end
if popuptext ~= "" then
subobject_entry["KartePopupText"] = popuptext
end
-- subobject in Liste aufnehmen
table.insert(subobjects, subobject_entry)
end
end
-- geocode lon/lat
if (not minimum_one_geocode_ok or com.isTrue(args["Ehemals"])) and args["lat"] ~= nil and args["lon"] ~= nil then
local geocode = frame:callParserFunction("#geocode", {args["lat"] .. "," .. args["lon"], format="float", directional="no"})
if geocode ~= "Geocoding failed" then
local subobject_entry = {}
subobject_entry["Geokoordinate"] = geocode
if popuptitle ~= "" then
subobject_entry["KartePopupTitle"] = popuptitle
end
if popuptext ~= "" then
subobject_entry["KartePopupText"] = popuptext
end
table.insert(subobjects, subobject_entry)
end
end
-- subobjects setzen
mw.logObject(subobjects, "subobjects")
for _, s in ipairs(subobjects) do
s["SubObjektTyp"] = "Geo"
local id = smw.subobjectIdCleaner(s["Geolokation"] or s["Geokoordinate"])
mw.smw.subobject(s, id)
end
-- bisherige Vorlagen-Karte
t = t .. frame:expandTemplate{title = "Karte/Legacy", args = args}
mw.logObject(t, "t")
return t
end
return p