15.101
Bearbeitungen
K (Schützte „Modul:Geocode“ ([Bearbeiten=Nur Administratoren erlauben] (unbeschränkt) [Verschieben=Nur Administratoren erlauben] (unbeschränkt))) |
(split in OSMlink() und osmLink()) |
||
| Zeile 1: | Zeile 1: | ||
local p = {} | local p = {} | ||
local | local com = require("Module:Common") | ||
local | local que = require("Module:Queries") | ||
local str = require("Modul:String") | local str = require("Modul:String") | ||
function p.OSMlink(frame) | function p.OSMlink(frame) | ||
local dms_coords = frame.args[1] -- Degree, Minute, Second format | local dms_coords = frame.args[1] -- Degree, Minute, Second format | ||
return p.osmLink(frame, dms_coords) | |||
end | |||
function p.osmLink(frame, dms_coords) | |||
local float_coords = frame:callParserFunction('#coordinates', {dms_coords, format='float', directional='no'}) | local float_coords = frame:callParserFunction('#coordinates', {dms_coords, format='float', directional='no'}) | ||
local coords = str.split(float_coords, ', ') | local coords = str.split(float_coords, ', ') | ||
local dms_split = str.split(dms_coords, ',') | local dms_split = str.split(dms_coords, ',') | ||
| Zeile 27: | Zeile 30: | ||
local hausnr = "" | local hausnr = "" | ||
if not | if not com.isEmpty(hausnummer) then | ||
hausnr = tonumber(string.match("0" .. hausnummer, "%d+")) | hausnr = tonumber(string.match("0" .. hausnummer, "%d+")) | ||
end | end | ||
| Zeile 53: | Zeile 56: | ||
local hausnummerZahl = 0; | local hausnummerZahl = 0; | ||
if not | if not com.isEmpty(hausnummer) then | ||
hausnummerZahl = p.getHausnummerZahl(hausnummer) | hausnummerZahl = p.getHausnummerZahl(hausnummer) | ||
end | end | ||
| Zeile 78: | Zeile 81: | ||
elseif hausnummerZahl < 9 then plz = 90762 elseif hausnummerZahl < 401 then plz = 90766 else plz = 90768 end -- ungerade H.nr. | elseif hausnummerZahl < 9 then plz = 90762 elseif hausnummerZahl < 401 then plz = 90766 else plz = 90768 end -- ungerade H.nr. | ||
else | else | ||
plz = | plz = que.getValues(strasse, "PLZ", true)[1] -- alle anderen Straßen haben nur eine PLZ, die auf deren Seite vemerkt ist | ||
end | end | ||
| Zeile 97: | Zeile 100: | ||
function p.getPLZList() | function p.getPLZList() | ||
local plzlist = | local plzlist = que.getPages("[[Kategorie:Postleitzahlen]] [[PLZ::+]]", true) | ||
table.sort(plzlist) | table.sort(plzlist) | ||
-- mw.logObject(plzlist) | -- mw.logObject(plzlist) | ||
| Zeile 107: | Zeile 110: | ||
local plzlist = "" | local plzlist = "" | ||
local stadtteile = frame.args[1] | local stadtteile = frame.args[1] | ||
if not | if not com.isEmpty(stadtteile) then | ||
local stadtteilTable = str.split(stadtteile, ";") | local stadtteilTable = str.split(stadtteile, ";") | ||
local plztable = p.stadtteil2PLZ(stadtteilTable) | local plztable = p.stadtteil2PLZ(stadtteilTable) | ||
| Zeile 119: | Zeile 122: | ||
-- gibt die Postleitzahlen der Stadtteile als table zurück | -- gibt die Postleitzahlen der Stadtteile als table zurück | ||
local plztable = {} | local plztable = {} | ||
if not | if not com.isEmpty(stadtteile) then | ||
if type(stadtteile) == "table" then | if type(stadtteile) == "table" then | ||
for _, s in pairs(stadtteile) do | for _, s in pairs(stadtteile) do | ||
for _, p in pairs( | for _, p in pairs(que.getValues(s, "PLZ", true)) do -- p ist string | ||
plztable[tonumber(p)] = true -- diese Mechanik verhindert mehrfaches Einfügen der gleichen PLZ | plztable[tonumber(p)] = true -- diese Mechanik verhindert mehrfaches Einfügen der gleichen PLZ | ||
end | end | ||
end | end | ||
else | else | ||
plztable[tonumber( | plztable[tonumber(que.getValues(stadtteile, "PLZ", true)[1])] = true | ||
end | end | ||
end | end | ||