「モジュール:Location map」の版間の差分
ナビゲーションに移動
検索に移動
サンドボックスを転記; WP:AN/PE (差分) による
template>Waiesu (Special:Permalink/62768046より転記; WP:AN/PE (差分)による) |
template>Waiesu |
||
119行目: | 119行目: | ||
-- Finds a parameter in a transclusion of {{Coord}}. | -- Finds a parameter in a transclusion of {{Coord}}. | ||
local function coord2text(para,coord) | local function coord2text(para,coord) -- this should be changed for languages which do not use Arabic numerals or the degree sign | ||
local result = mw.text.split(mw.ustring.match(coord,'% | 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 para == 'longitude' then result = {result[3], result[4]} end | ||
if not tonumber(result[1]) or not result[2] then return error('不正な座標指定です。', 2) end | if not tonumber(result[1]) or not result[2] then return error('不正な座標指定です。', 2) end | ||
158行目: | 158行目: | ||
end | end | ||
local width | local width | ||
local default_as_number = tonumber(mw.ustring.match(tostring(args.default_width),"%d*")) | |||
if not args.width then | if not args.width then | ||
width = round(( | width = round((default_as_number or 240) * (tonumber(map('defaultscale')) or 1)) | ||
elseif mw.ustring.sub(args.width, -2) == 'px' then | elseif mw.ustring.sub(args.width, -2) == 'px' then | ||
width = mw.ustring.sub(args.width, 1, -3) | width = mw.ustring.sub(args.width, 1, -3) | ||
165行目: | 166行目: | ||
width = args.width | width = args.width | ||
end | end | ||
local width_as_number = tonumber(mw.ustring.match(tostring(width),"%d*")) or 0; | |||
if width_as_number == 0 then | |||
-- check to see if width is junk. If it is, then use default calculation | |||
width = round((default_as_number or 240) * (tonumber(map('defaultscale')) or 1)) | |||
width_as_number = tonumber(mw.ustring.match(tostring(width),"%d*")) or 0; | |||
end | |||
if args.max_width ~= "" and args.max_width ~= nil then | |||
-- check to see if width bigger than max_width | |||
local max_as_number = tonumber(mw.ustring.match(args.max_width,"%d*")) or 0; | |||
if width_as_number>max_as_number and max_as_number>0 then | |||
width = args.max_width; | |||
end | |||
end | |||
local retval = args.float == 'center' and '<div class="center">' or '' | local retval = args.float == 'center' and '<div class="center">' or '' | ||
if args.caption and args.caption ~= '' and args.border ~= 'infobox' then | if args.caption and args.caption ~= '' and args.border ~= 'infobox' then |