「モジュール:Location map」の版間の差分

13版 をインポートしました
template>Rxy
(モジュール:Location map/sandbox 2016-07-24T15:59:36‎ UTC (←継承元: en:Module:Location map 2016年7月4日 (月) 16:32(UTC)より) の版より。 WP:AN/PE (差分) に基づく。)
(13版 をインポートしました)
 
(他の1人の利用者による、間の2版が非表示)
116行目: 116行目:
end
end
return decimal
return decimal
end
-- 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 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 return error('不正な座標指定です。', 2) end
return tonumber(result[1]) * hemisphereMultipliers[para][result[2]]
end
end


150行目: 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((args.default_width or 240) * (tonumber(map('defaultscale')) or 1))
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)
157行目: 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
337行目: 359行目:
longitude = decdeg(args.lon_deg, args.lon_min, args.lon_sec, args.lon_dir, args.long, 'longitude')
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')
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.useWikidata then
if args.coordinates then
-- Temporarily removed to facilitate infobox conversion.
 
-- if longitude or latitude then
-- error('[[Module:Coordinates]]からの座標とローカル指定座標の両方を提供できません。')
-- end
longitude = coord2text('longitude', args.coordinates)
latitude = coord2text('latitude', args.coordinates)
elseif not longitude and not latitude and args.useWikidata then
-- If they didn't provide either coordinate, try Wikidata. If they provided one but not the other, don't.
-- If they didn't provide either coordinate, try Wikidata. If they provided one but not the other, don't.
local entity = mw.wikibase.getEntity()
local entity = mw.wikibase.getEntity()
347行目: 377行目:
if not longitude then
if not longitude then
error('緯度の値が指定されていません。')
error('緯度の値が指定されていません。')
end
elseif not latitude then
if not latitude then
error('経度の値が指定されていません。')
error('経度の値が指定されていません。')
end
end