Modul:Location map: Perbedaan antara revisi
Konten dihapus Konten ditambahkan
k ~ |
-require('Module:No globals') |
||
(13 revisi perantara oleh 3 pengguna tidak ditampilkan) | |||
Baris 1:
local p = {}
Baris 12 ⟶ 10:
function p.getMapParams(map, frame)
if not map then
error('
end
local moduletitle = mw.title.new('Module:Location map/data/' .. map)
if not moduletitle then
error(string.format('%q
elseif moduletitle.exists then
local mapData = mw.loadData('Module:Location map/data/' .. map)
Baris 30 ⟶ 28:
end
end
elseif mw.title.new('
local cache = {}
if type(frame) ~= 'table' or type(frame.expandTemplate) ~= 'function' then
error('
end
return function(name, params)
Baris 40 ⟶ 38:
else
if name == nil then
return '
elseif cache[name] == nil then
cache[name] = frame:expandTemplate{title = 'Location map ' .. map, args = { name }}
Baris 48 ⟶ 46:
end
else
error('
end
end
Baris 76 ⟶ 74:
if decimal then
if degrees then
error('
elseif minutes then
error('
elseif seconds then
error('
elseif hemisphere then
error('
end
local retval = tonumber(decimal)
Baris 88 ⟶ 86:
return retval
end
error('
elseif seconds and not minutes then
error('
elseif not degrees then
if minutes then
error('
elseif hemisphere then
error('
end
return nil
Baris 101 ⟶ 99:
decimal = tonumber(degrees)
if not decimal then
error('
elseif minutes and not tonumber(minutes) then
error('
elseif seconds and not tonumber(seconds) then
error('
end
decimal = decimal + (minutes or 0)/60 + (seconds or 0)/3600
Baris 111 ⟶ 109:
local multiplier = hemisphereMultipliers[direction][hemisphere]
if not multiplier then
error('
end
decimal = decimal * multiplier
Baris 120 ⟶ 118:
-- Finds a parameter in a transclusion of {{Coord}}.
local function coord2text(para,coord) -- this should be changed for languages which do not use Arabic numerals or the degree sign
local
if lat then
return tonumber(para == 'longitude' and long or lat)
end
local result = mw.text.split(mw.ustring.match(coord,'%-?[%.%d]+°[NS] %-?[%.%d]+°[EW]') or '', '[ °]')
if para == 'longitude' then result = {result[3], result[4]} end
if not tonumber(result[1]) or not result[2] then
mw.log('Malformed coordinates value' mw.logObject(para, 'para')
mw.logObject(coord, 'coord')
return error('Kesalahan format nilai koordinat', 2)
end
return tonumber(result[1]) * hemisphereMultipliers[para][result[2]]
end
Baris 179 ⟶ 186:
end
end
local retval =
if args.float == 'center' then
retval = retval .. '<div class="center">'
end
if args.caption and args.caption ~= '' and args.border ~= 'infobox' then
retval = retval .. '<div class="locmap noviewer thumb '
if args.float == '"left"' or args.float == 'left' then
retval = retval .. 'tleft'
Baris 197 ⟶ 207:
retval = retval .. '"><div style="position:relative;width:' .. width .. 'px' .. (args.border ~= 'none' and ';border:1px solid lightgray">' or '">')
else
retval = retval .. '<div class="locmap" style="width:' .. width .. 'px;'
if args.float == '"left"' or args.float == 'left' then
retval = retval .. 'float:left;clear:left'
Baris 210 ⟶ 220:
end
local image = getContainerImage(args, map)
local currentTitle = mw.title.getCurrentTitle()
retval = string.format(
'%s[[File:%s|%spx|%s%s]]',
Baris 215 ⟶ 226:
image,
width,
args.alt or ((args.label or
args.maplink and ('|link=' .. args.maplink) or ''
)
if args.caption and args.caption ~= '' then
if (currentTitle.namespace == 0) and mw.ustring.find(args.caption, '##') then
retval = retval .. '[[
end
end
Baris 238 ⟶ 249:
end
local retval = '</div>'
local currentTitle = mw.title.getCurrentTitle()
if not args.caption or args.border == 'infobox' then
if args.border then
retval = retval .. '<div style="padding-top:0.2em">'
else
retval = retval .. '<div style="font-size:
end
retval = retval
.. (args.caption or (args.label or
.. '</div>'
elseif args.caption ~= '' then
Baris 256 ⟶ 267:
retval = retval .. '<span class="switcher-label" style="display:none">' .. args.switcherLabel .. '</span>'
elseif args.autoSwitcherLabel then
retval = retval .. '<span class="switcher-label" style="display:none">
end
Baris 267 ⟶ 278:
end
mw.logObject(args, 'args')
if currentTitle.namespace == 0 then
retval = retval .. '[[
end
end
if map('skew') ~= '' or map('lat_skew') ~= '' or map('crosses180') ~= '' or map('type') ~= '' then
mw.log('Removed parameter used in map definition ' .. map())
if currentTitle.namespace == 0 then
local key = (map('skew') ~= '' and 'skew' or '') ..
(map('lat_skew') ~= '' and 'lat_skew' or '') ..
(map('crosses180') ~= '' and 'crosses180' or '') ..
(map('type') ~= '' and 'type' or '')
retval = retval .. '[[
end
end
if string.find(map('name'), '|', 1, true) then
mw.log('Pipe used in name of map definition ' .. map())
if currentTitle.namespace == 0 then
retval = retval .. '[[Kategori:Peta lokasi dengan nama yang mengandung pipa]]'
end
end
if args.float == 'center' then
Baris 289 ⟶ 306:
local function markOuterDiv(x, y, imageDiv, labelDiv)
return mw.html.create('div')
:addClass('od')
:cssText('
:node(imageDiv)
:node(labelDiv)
Baris 296 ⟶ 314:
local function markImageDiv(mark, marksize, label, link, alt, title)
local builder = mw.html.create('div')
:addClass('id')
:cssText('
:attr('title', title)
if marksize ~= 0 then
Baris 314 ⟶ 333:
local function markLabelDiv(label, label_size, label_width, position, background, x, marksize)
if tonumber(label_size) == 0 then
return mw.html.create('div'):
end
local builder = mw.html.create('div')
:cssText('font-size:' .. label_size .. '%
local distance = round(marksize / 2 + 1)
if position == 'top' then -- specified top
builder:addClass('pv'):cssText('bottom:' .. distance .. 'px;left:' .. (-label_width / 2) .. 'em
elseif position == 'bottom' then -- specified bottom
builder:addClass('pv'):cssText('top:' .. distance .. 'px;left:' .. (-label_width / 2) .. 'em
elseif position == 'left' or (tonumber(x) > 70 and position ~= 'right') then -- specified left or autodetected to left
builder:
else -- specified right or autodetected to right
builder:
end
builder = builder:tag('div')
:wikitext(label)
if background then
Baris 400 ⟶ 413:
end
local builder = mw.html.create()▼
local currentTitle = mw.title.getCurrentTitle()
if args.coordinates then
-- Temporarily removed to facilitate infobox conversion. See [[Wikipedia:Coordinates in infoboxes]]
Baris 414 ⟶ 429:
local value = entity.claims.P625[1].mainsnak.datavalue.value
longitude, latitude = value.longitude, value.latitude
end
if args.link and (currentTitle.namespace == 0) then
builder:wikitext('[[Kategori:Peta lokasi menggunakan penanda tertaut dengan koordinat dari Wikidata]]')
end
end
if not longitude then
error('
elseif not latitude then
error('
end
if currentTitle.namespace > 0 then
▲ local builder = mw.html.create()
builder:wikitext('[[
builder:wikitext('[[
builder:wikitext('[[
builder:wikitext('[[
builder:wikitext('[[
end
end
if ((tonumber(args.lat_deg) or 0) < 0) and ((tonumber(args.lat_min) or 0) ~= 0 or (tonumber(args.lat_sec) or 0) ~= 0 or (args.lat_dir and args.lat_dir ~='')) then
builder:wikitext('[[Kategori:Peta lokasi dengan derajat dan menit atau detik negatif]]')
end
if ((tonumber(args.lon_deg) or 0) < 0) and ((tonumber(args.lon_min) or 0) ~= 0 or (tonumber(args.lon_sec) or 0) ~= 0 or (args.lon_dir and args.lon_dir ~= '')) then
builder:wikitext('[[Kategori:Peta lokasi dengan derajat dan menit atau detik negatif]]')
end
if (((tonumber(args.lat_min) or 0) < 0) or ((tonumber(args.lat_sec) or 0) < 0)) then
builder:wikitext('[[Kategori:Peta lokasi dengan derajat dan menit atau detik negatif]]')
end
if (((tonumber(args.lon_min) or 0) < 0) or ((tonumber(args.lon_sec) or 0) < 0)) then
builder:wikitext('[[Kategori:Peta lokasi dengan derajat dan menit atau detik negatif]]')
end
if args.skew or args.lon_shift or args.markhigh then
Baris 440 ⟶ 471:
end
mw.logObject(args, 'args')
if currentTitle.namespace == 0 then
local key = (args.skew and 'skew' or '') ..▼
(args.
builder:wikitext('[[
end
end
if map('x') ~= '' then
Baris 462 ⟶ 495:
end
mw.logObject(args, 'args')
if currentTitle.namespace == 0 then
local key = currentTitle.prefixedText
builder:wikitext('[[
end
end
local mark = args.mark or map('mark')
Baris 473 ⟶ 508:
local labelDiv
if args.label and args.position ~= 'none' then
labelDiv = markLabelDiv(args.label, args.label_size or
end
return builder:node(markOuterDiv(x, y, imageDiv, labelDiv))
Baris 521 ⟶ 556:
local altmaps = switcherSeparate(args.AlternativeMap)
if #altmaps > #map then
error(string.format('%d
end
local overlays = switcherSeparate(args.overlay_image)
if #overlays > #map then
error(string.format('%d overlay_images
end
if #caption_list > #map then
error(string.format('%d captions
end
local outputs = {}
|