Module:Location map: Difference between revisions
m
1 revision imported
Vivaporius (talk | contribs) m (1 revision imported) |
Vivaporius (talk | contribs) m (1 revision imported) |
||
(One intermediate revision by one other user not shown) | |||
Line 16:
local moduletitle = mw.title.new('Module:Location map/data/' .. map)
if not moduletitle then
error(
elseif moduletitle.exists then
local mapData = mw.loadData('Module:Location map/data/' .. map)
Line 74:
local function decdeg(degrees, minutes, seconds, hemisphere, decimal, direction)
if
if
return nil
end
local retval = tonumber(decimal)
if not retval then
error('The value "' .. decimal .. '" provided for ' .. direction .. ' is not valid', 2)
end
return retval
end
decimal = tonumber(degrees)
if not decimal then
error('The degree value "' .. degrees .. '" provided for ' .. direction .. ' is not valid', 2)
end
if minutes and not tonumber(minutes) then
error('The minute value "' .. minutes .. '" provided for ' .. direction .. ' is not valid', 2)
end
if seconds and not tonumber(seconds) then
error('The second value "' .. seconds .. '" provided for ' .. direction .. ' is not valid', 2)
end
Line 116 ⟶ 103:
end
return decimal
end
Line 166 ⟶ 145:
end
local retval = args.float == 'center' and '<div class="center">' or ''
if args.caption and args.caption ~= '
retval = retval .. '<div class="noviewer thumb '
if args.float == '"left"' or args.float == 'left' then
Line 220 ⟶ 199:
local retval = '</div>'
if not args.caption
retval = retval .. '<div style="font-size:90%;padding-top:3px">'
.. ((args.label or mw.title.getCurrentTitle().text) .. ' (' .. map('name') .. ')')
.. '</div>'
elseif args.caption
retval = retval .. '<div style="font-size:90%;padding-top:3px"></div>'
else
-- This is not the pipe trick. We're creating a link with no text on purpose, so that CSS can give us a nice image
retval = retval .. '<div class="thumbcaption"><div class="magnify">[[:File:' .. getContainerImage(args, map) .. '| ]]</div>' .. args.caption .. '</div>'
Line 249 ⟶ 225:
mw.logObject(args, 'args')
retval = retval .. '[[Category:Location maps with possible errors|Page using removed parameter]]'
end
if args.float == 'center' then
Line 266 ⟶ 234:
local function markOuterDiv(x, y, imageDiv, labelDiv)
return mw.html.create('div')
:cssText('position:absolute;top:' .. round(y, 3) .. '%;left:' .. round(x, 3) .. '%;height:0;width:0;margin:0;padding:0')
:node(imageDiv)
:node(labelDiv)
Line 273 ⟶ 241:
local function markImageDiv(mark, marksize, label, link, alt, title)
local builder = mw.html.create('div')
:cssText('position:absolute;text-align:center;left:-' .. round(marksize / 2) .. 'px;top:-' .. round(marksize / 2) .. 'px;width:' .. marksize .. 'px;font-size:' .. marksize .. 'px;line-height:0')
:attr('title', title)
if marksize ~= 0 then
Line 290 ⟶ 258:
local function markLabelDiv(label, label_size, label_width, position, background, x, marksize)
local builder = mw.html.create('div')
:cssText('font-size:' .. label_size .. '%;line-height:110%;position:absolute;width:' .. label_width .. 'em')
Line 345 ⟶ 310:
longitude = decdeg(args.lon_deg, args.lon_min, args.lon_sec, args.lon_dir, args.long, 'longitude')
latitude = decdeg(args.lat_deg, args.lat_min, args.lat_sec, args.lat_dir, args.lat, 'latitude')
if not longitude and not latitude and args.
-- If they didn't provide either coordinate, try Wikidata. If they provided one but not the other, don't.
local entity = mw.wikibase.getEntity()
if entity and entity.claims and entity.claims.
local value = entity.claims.
longitude, latitude = value.longitude, value.latitude
end
Line 363 ⟶ 320:
if not longitude then
error('No value was provided for longitude')
end
if not latitude then
error('No value was provided for latitude')
end
local builder = mw.html.create()
if args.skew or args.lon_shift or args.markhigh then
mw.log('Removed parameter used in invocation.')
Line 386 ⟶ 333:
mw.logObject(args, 'args')
builder:wikitext('[[Category:Location maps with possible errors|Page using removed parameter]]')
end
if map('skew') ~= '' or map('lat_skew') ~= '' or map('crosses180') ~= '' or map('type') ~= '' then
mw.log('Removed parameter used in map definition ' .. map())
builder:wikitext('[[Category:Location maps with possible errors|Map using removed parameter]]')
end
if map('x') ~= '' then
Line 417 ⟶ 368:
end
return builder:node(markOuterDiv(x, y, imageDiv, labelDiv))
end
Line 448 ⟶ 389:
end
if type(map) == 'table' then
local outputs = {}
args.autoSwitcherLabel = true
for k,v in ipairs(map) do
outputs[k] = p.main(frame, args, v)
end
|