Modulo:Mapkadro: Malsamoj inter versioj

[kontrolita revizio][kontrolita revizio]
Enhavo forigita Enhavo aldonita
e aldono
aktualigo laŭ la praula kataluna modulo ca:Mòdul:Map
Linio 5:
-- CSGNetwork at http://www.csgnetwork.com/degreelenllavcalc.html via @enwiki
-- OpenStreetMap
-- Version: 2020051220200730
 
local p = {}
Linio 330:
local long = tonumber(coords[2])
edges = edges or 32
local move = 2 * math.pi * (turn or 0)
local coordinates = {}
for i = 0, edges do
Linio 350:
end
return
--end
 
-- Recursively extract coord templates which have a name parameter.
-- from en:Module:Mapframe
local function extractCoordTemplates(wikitext)
local output = {}
local templates = mw.ustring.gmatch(wikitext, '{%b{}}')
local subtemplates = {}
for template in templates do
local name = mw.ustring.match(template, '{{([^}|]+)') -- get the template name
local nameParam = mw.ustring.match(template, "|%s*name%s*=%s*[^}|]+")
if not nameParam then
nameParam = mw.ustring.match(template, "|%s*nom%s*=%s*[^}|]+")
end
if mw.ustring.lower(mw.text.trim(name)) == 'coord' then
if nameParam then table.insert(output, template) end
elseif mw.ustring.find(template, 'coord') then
local subOutput = extractCoordTemplates(mw.ustring.sub(template, 2))
for _, t in pairs(subOutput) do
table.insert(output, t)
end
end
end
-- ensure coords are not using title display
for k, v in pairs(output) do
output[k] = mw.ustring.gsub(v, "|%s*display%s*=[^|}]+", "|display=inline")
end
return output
end
 
-- Gets all named coordiates from a page or a section of a page.
-- dependency: Module:Transcluder
local function getNamedCoords(page)
local parts = mw.text.split(page or "", "#", true)
local name = parts[1] == "" and mw.title.getCurrentTitle().prefixedText or parts[1]
local section = parts[2]
local pageWikitext = require('Module:Transcluder').get(section and name.."#"..section or name)
local coordTemplates = extractCoordTemplates(pageWikitext)
local frame = mw.getCurrentFrame()
local sep = "________"
local expandedContent = frame:preprocess(table.concat(coordTemplates, sep))
local expandedTemplates = mw.text.split(expandedContent, sep)
local namedCoords = {}
for _, expandedTemplate in pairs(expandedTemplates) do
local coord = mw.ustring.match(expandedTemplate, "<span class=\"geo\">(.-)</span>")
if coord then
coord = mw.ustring.gsub(coord, ";", ",")
local name = mw.ustring.match(expandedTemplate, "&title=(.-)<span") or coord
name = mw.uri.decode(name)
local description = name ~= coord and coord
table.insert(namedCoords, {coord=coord, name=name, description=description})
end
end
return namedCoords
end
 
Linio 382 ⟶ 436:
args['coordinates1'] = getCoordinatesById(wdid)
end
local par = {'title', 'image', 'description', 'geotype', 'commons', 'radius', 'radiuskm', 'edges', 'turn', 'from'}
for _, v in ipairs(par) do
args[v .. '1'] = args[v .. '1'] or args[v]
Linio 388 ⟶ 442:
end
local externalData = {['geoshape'] = true, ['geomask'] = true, ['geoline'] = true, ['page'] = true, ['none'] = true, ['named'] = true}
local featureCollection = {['Point'] = true, ['MultiPoint'] = true, ['LineString'] = true, ['Polygon'] = true, ['circle'] = true}
local myfeatures, myexternal, allpoints = {}, {}, {}
Linio 406 ⟶ 460:
else
local mystack
if externalData[geotypex or== 'named'] then
local namedCoords = getNamedCoords(args['from'..i])
mystack = myfeatures
for _, namedCoord in pairs(namedCoords) do
j = #mystack + 1
mystack[j] = {}
mystack[j]['type'] = "Feature"
mystack[j]['geometry'] = {}
mystack[j]['geometry']['type'] = "Point"
mystack[j]['geometry']['coordinates'] = parseGeoSequence(namedCoord.coord, 'Point')
allpoints = mergePoints(allpoints, mystack[j]['geometry']['coordinates'])
mystack[j]['properties'] = {}
mystack[j]['properties']['title'] = namedCoord.name
mystack[j]['properties']['description'] = namedCoord.description
mystack[j]['properties']['marker-size'] = args['marker-size'..i] or args['marker-size']
mystack[j]['properties']['marker-symbol'] = args['marker-symbol'..i] or args['marker-symbol']
mystack[j]['properties']['marker-color'] = args['marker-color'..i] or args['marker-color']
end
break
elseif externalData[geotypex or ''] then
mystack = myexternal
j = #mystack + 1
Linio 516 ⟶ 589:
 
function p.tag(frame)
--if mw.title.new(frame:getParent():getTitle()).isContentPage and not mw.title.new(frame:getTitle()).isSubpage then
-- invoked from a content page and not invoking a module subpage
-- printError('not-from-content-page')
--end
local getArgs = require('Module:Arguments').getArgs
local args = getArgs(frame)