Modul:Location map: Perbedaan antara revisi
Konten dihapus Konten ditambahkan
k uji coba |
-require('Module:No globals') |
||
(12 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 28 ⟶ 26:
else
return mapData[name]
end
end
elseif mw.title.new('Templat:Location map ' .. map).exists then
local cache = {}
if type(frame) ~= 'table' or type(frame.expandTemplate) ~= 'function' then
error('Frame harus disediakan saat menggunakan peta lokasi lama')
end
return function(name, params)
if params then
return frame:expandTemplate{title = 'Location map ' .. map, args = { name, unpack(params) }}
else
if name == nil then
return 'Templat:Location map ' .. map
elseif cache[name] == nil then
cache[name] = frame:expandTemplate{title = 'Location map ' .. map, args = { name }}
end
return cache[name]
end
end
else
error('
end
end
Baris 59 ⟶ 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 71 ⟶ 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 84 ⟶ 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 94 ⟶ 109:
local multiplier = hemisphereMultipliers[direction][hemisphere]
if not multiplier then
error('
end
decimal = decimal * multiplier
Baris 103 ⟶ 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 lat, long = mw.ustring.match(coord,'<span class="p%-latitude latitude">([^<]+)</span><span class="p%-longitude longitude">([^<]+)</span>')
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 162 ⟶ 186:
end
end
local retval = frame:extensionTag{name = 'templatestyles', args = {src = '
if args.float == 'center' then
retval = retval .. '<div class="center">'
Baris 202 ⟶ 226:
image,
width,
args.alt or ((args.label or currentTitle.text) .. '
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 243 ⟶ 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 255 ⟶ 279:
mw.logObject(args, 'args')
if currentTitle.namespace == 0 then
retval = retval .. '[[
end
end
Baris 265 ⟶ 289:
(map('crosses180') ~= '' and 'crosses180' or '') ..
(map('type') ~= '' and 'type' or '')
retval = retval .. '[[
end
end
Baris 271 ⟶ 295:
mw.log('Pipe used in name of map definition ' .. map())
if currentTitle.namespace == 0 then
retval = retval .. '[[
end
end
Baris 407 ⟶ 431:
end
if args.link and (currentTitle.namespace == 0) then
builder:wikitext('[[
end
end
if not longitude then
error('
elseif not latitude then
error('
end
if currentTitle.namespace > 0 then
if (not args.lon_deg) ~= (not args.lat_deg) then
builder:wikitext('[[
elseif (not args.lon_min) ~= (not args.lat_min) then
builder:wikitext('[[
elseif (not args.lon_sec) ~= (not args.lat_sec) then
builder:wikitext('[[
elseif (not args.lon_dir) ~= (not args.lat_dir) then
builder:wikitext('[[
elseif (not args.long) ~= (not args.lat) then
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 439 ⟶ 475:
(args.lon_shift and 'lon_shift' or '') ..
(args.markhigh and 'markhigh' or '')
builder:wikitext('[[
end
end
Baris 461 ⟶ 497:
if currentTitle.namespace == 0 then
local key = currentTitle.prefixedText
builder:wikitext('[[
end
end
Baris 520 ⟶ 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 = {}
|