15.381
Bearbeitungen
Keine Bearbeitungszusammenfassung |
Keine Bearbeitungszusammenfassung |
||
| Zeile 31: | Zeile 31: | ||
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 und location zusammenführen | ||
local | local locationlist = str.splitAndStrip(args["locationlist"] or "", ";") | ||
table.insert(locationlist, | |||
(args["location"] or "") .. "~" .. | (args["location"] or "") .. "~" .. | ||
(args["popuptitle"] or "") .. "~" .. | (args["popuptitle"] or "") .. "~" .. | ||
(args["popuptext"] or "")) | (args["popuptext"] or "")) | ||
-- alle locations durchiterieren und für jedes ein subobject erstellen | -- alle locations durchiterieren und für jedes ein subobject erstellen | ||
for _, l in ipairs( | for _, l in ipairs(locationlist) do | ||
-- Aufteilung location ~ popuptitle ~ popuptext | -- Aufteilung location ~ popuptitle ~ popuptext | ||
l = str.split2(l, "~") | l = str.split2(l, "~") | ||
| Zeile 47: | Zeile 47: | ||
-- Prüfung Koordinate (Zahl) oder textuelle Objektlokation | -- Prüfung Koordinate (Zahl) oder textuelle Objektlokation | ||
-- wenn Objektlokation und Ehemals, dann nicht auswerten | -- wenn Objektlokation und Ehemals, dann nicht auswerten | ||
if | if string.match(location, "%d") == nil and -- Keine-Zahl-Erkennung | ||
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 | ||
| Zeile 59: | Zeile 59: | ||
-- geocode nicht erfolgreich => SMW-DB nehmen | -- geocode nicht erfolgreich => SMW-DB nehmen | ||
kategorien["Hat Geo-Kodierungsfehler"] = true | kategorien["Hat Geo-Kodierungsfehler"] = true | ||
smw_geokoordinate = mw.smw.ask( | local smw_geokoordinate = mw.smw.ask( | ||
"[[-Has subobject::" .. pagename .. "]]" .. | "[[-Has subobject::" .. pagename .. "]]" .. | ||
"[[Geolokation::" .. location .. "]]" .. | "[[Geolokation::" .. location .. "]]" .. | ||
"|?Geokoordinate|limit=1") or {{}} | "|?Geokoordinate|limit=1") or {{}} | ||
smw_geokoordinate = smw_geokoordinate[1]["Geokoordinate"] | smw_geokoordinate = smw_geokoordinate[1]["Geokoordinate"] | ||
if smw_geokoordinate ~= nil then | if smw_geokoordinate ~= nil then -- SMW-DB Geokoordinate vorhanden? | ||
kategorien["Hat Geo-Kodierungsfehler, aber | kategorien["Hat Geo-Kodierungsfehler, aber Geokoordinate in SMW-DB noch vorhanden"] = true | ||
geoobject_entry["Geokoordinate"] = smw_geokoordinate | geoobject_entry["Geokoordinate"] = smw_geokoordinate | ||
minimum_one_geocode_ok = true | minimum_one_geocode_ok = true | ||
| Zeile 72: | Zeile 72: | ||
end -- if Zahlerkennung | end -- if Zahlerkennung | ||
set_popuptitle_popuptext(geoobject_entry, popuptitle, popuptext) | set_popuptitle_popuptext(geoobject_entry, popuptitle, popuptext) | ||
table.insert(geoobjects, geoobject_entry) | |||
end -- if location ~= "" then | end -- if location ~= "" then | ||
end -- for _, l in ipairs(locations_merged) do | end -- for _, l in ipairs(locations_merged) do | ||
-- geocode lon/lat | -- 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 | ||
args["lat"] | not com.isEmpty(args["lat"]) and not com.isEmpty(args["lon"]) then | ||
local geoobject_entry = {} | |||
local geocode = geocode(frame, args["lat"] .. "," .. args["lon"]) | local geocode = geocode(frame, args["lat"] .. "," .. args["lon"]) | ||
if geocode ~= "Geocoding failed" then | if geocode ~= "Geocoding failed" then | ||
geoobject_entry["Geokoordinate"] = geocode | |||
else | else | ||
kategorien["Hat Geo-Kodierungsfehler"] = true | kategorien["Hat Geo-Kodierungsfehler"] = true | ||
end | end | ||
set_popuptitle_popuptext(geoobject_entry, popuptitle, popuptext) | |||
table.insert(geoobjects, geoobject_entry) | |||
end | end | ||
| Zeile 101: | Zeile 102: | ||
-- Kategorien setzen | -- Kategorien setzen | ||
for _ | for k, _ in pairs(kategorien) do | ||
t = t .. "[[Kategorie:" .. k .. "]]" | t = t .. "[[Kategorie:" .. k .. "]]" | ||
end | end | ||
| Zeile 109: | Zeile 110: | ||
end | end | ||
function geocode(frame, | function geocode(frame, location) | ||
return frame:callParserFunction( | return frame:callParserFunction( | ||
"#geocode", { | "#geocode", {location, format="float", directional="no"}) | ||
end | end | ||