"मोड्युल:Coordinates" का संशोधनहरू बिचको अन्तर
Content deleted Content added
-- चिनो: हातले पूर्ववत |
सफाइ गरियो चिनो: फर्काई दियो |
||
पङ्क्ति १:
--[[
{{#invoke:Coordinates
coordinate values.
{{#invoke:Coordinates
degree values to DMS format.
{{#invoke:Coordinates
to decimal degree format.
{{#invoke:Coordinates
]]
require('
local math_mod = require("Module:Math")
local coordinates = {};
local current_page = mw.title.getCurrentTitle()
local page_name = mw.uri.encode( current_page.prefixedText, 'WIKI' );
local coord_link = '//geohack.toolforge.org/geohack.php?language=ne&pagename=' .. page_name .. '¶ms='
local templatestyles = 'Module:Coordinates/styles.css'
local function direction2bn(text)
text = text:gsub('[NSEW]', {
N = ' उत्तर',
S = ' दक्षिण',
E = ' पूर्व',
W = ' पश्चिम',
})
return text
end
local function translate2bn(text)
text = text:gsub('%d', {
['0'] = '०',
['1'] = '१',
['2'] = '२',
['3'] = '३',
['4'] = '४',
['5'] = '५',
['6'] = '६',
['7'] = '७',
['8'] = '८',
['9'] = '९',
})
return text
end
local function translate2en(text)
text = mw.ustring.gsub(text, '%d', {
['०'] = '0',
['१'] = '1',
['२'] = '2',
['३'] = '3',
['४'] = '4',
['५'] = '5',
['६'] = '6',
['७'] = '7',
['८'] = '8',
['९'] = '9',
})
text = text
:gsub(' *उत्तर', 'N')
:gsub(' *दक्षिण', 'S')
:gsub(' *पूर्व', 'E')
:gsub(' *पश्चिम', 'W')
return text
end
--[[ Helper function, replacement for {{coord/display/title}} ]]
local function displaytitle(s, notes)
local l = "[[भौगोलिक निर्देशाङ्क प्रणाली|
local co = '<span id="coordinates">' .. l .. notes .. '</span>'
return mw.getCurrentFrame():extensionTag{
name = 'indicator',
args = { name = 'coordinates' },
content = '<span style="font-size: small;">' .. co .. '</span>'
};
end
Line ५३ ⟶ १००:
return function (frame)
local args = require('Module:Arguments').getArgs(frame, {
wrappers = 'ढाँचा:Coordinates' -- TODO should this use the bn name? check Module:Arguments
})
for k, v in pairs(args) do
args[k] = translate2en(v)
end
return coordinates[funcName](args, frame)
end
Line ७० ⟶ १२०:
local result = ""
for i,v in ipairs(errors) do
local errorHTML = '<strong class="error">
result = result .. errorHTML .. "<br />"
end
Line १०५ ⟶ १५५:
if uriComponents == "" then
-- RETURN error, should never be empty or nil
return "त्रुटि
end
if args["name"] then
Line १११ ⟶ १६१:
end
local geodmshtml = '<span class="geo-dms" title="
.. '<span class="latitude">' ..
.. '<span class="longitude">' ..
.. '</span>'
Line १२० ⟶ १७०:
if lat < 0 then
-- FIXME this breaks the pre-existing precision
geodeclat = tostring(coordinateSpec["dec-lat"]):sub(2) .. "°
else
geodeclat = (coordinateSpec["dec-lat"] or 0) .. "°
end
Line १२९ ⟶ १७९:
if long < 0 then
-- FIXME does not handle unicode minus
geodeclong = tostring(coordinateSpec["dec-long"]):sub(2) .. "°
else
geodeclong = (coordinateSpec["dec-long"] or 0) .. "°
end
local geodechtml = '<span class="geo-dec" title="नक्सा, हवाई इमेजरी, र यस स्थानको लागि अन्य जानकारी">'
.. translate2bn(geodeclat) .. ' '
.. translate2bn(geodeclong)
.. '</span>'
Line २६७ ⟶ ३०५:
if strong then
if lat_d < 0 then
table.insert(errors, {source, "
end
if long_d < 0 then
table.insert(errors, {source, "
end
--[[
Line २७९ ⟶ ३१७:
if long_d > 180 then
table.insert(errors, {source, "
end
]]
Line २८५ ⟶ ३२३:
if lat_d > 90 then
table.insert(errors, {source, "
end
if lat_d < -90 then
table.insert(errors, {source, "
end
if lat_m >= 60 then
table.insert(errors, {source, "अक्षांश
end
if lat_m < 0 then
table.insert(errors, {source, "अक्षांश
end
if lat_s >= 60 then
table.insert(errors, {source, "अक्षांश
end
if lat_s < 0 then
table.insert(errors, {source, "अक्षांश
end
if long_d >= 360 then
table.insert(errors, {source, "
end
if long_d <= -360 then
table.insert(errors, {source, "
end
if long_m >= 60 then
table.insert(errors, {source, "
end
if long_m < 0 then
table.insert(errors, {source, "
end
if long_s >= 60 then
table.insert(errors, {source, "
end
if long_s < 0 then
table.insert(errors, {source, "
end
Line ३३५ ⟶ ३७३:
if not long then
return nil, {{"parseDec", "
elseif not tonumber(long) then
return nil, {{"parseDec", "देशान्तरलाई
end
Line ३४५ ⟶ ३८३:
local mode = coordinates.determineMode( lat, long );
coordinateSpec["dms-lat"] = convert_dec2dms( lat, "
coordinateSpec["dms-long"] = convert_dec2dms( long, "
if format then
Line ३७६ ⟶ ४१४:
errors = validate( lat_d, lat_m, lat_s, long_d, long_m, long_s, 'parseDMS', true );
if not long_d then
return nil, {{"parseDMS", "
elseif not tonumber(long_d) then
return nil, {{"parseDMS", "देशान्तरलाई
end
Line ३९४ ⟶ ४३२:
end
coordinateSpec["dms-lat"] = lat_d.."°"..optionalArg(lat_m,"′") .. optionalArg(lat_s,"″") .. direction2bn(lat_f)
coordinateSpec["dms-long"] = long_d.."°"..optionalArg(long_m,"′") .. optionalArg(long_s,"″") .. direction2bn(long_f)
coordinateSpec["dec-lat"] = convert_dms2dec(lat_f, lat_d, lat_m, lat_s) -- {{coord/dms2dec|{{{4}}}|{{{1}}}|0{{{2}}}|0{{{3}}}}}
coordinateSpec["dec-long"] = convert_dms2dec(long_f, long_d, long_m, long_s) -- {{coord/dms2dec|{{{8}}}|{{{5}}}|0{{{6}}}|0{{{7}}}}}
Line ४३८ ⟶ ४६४:
if not args[1] then
-- no lat logic
return errorPrinter( {{"formatTest", "
elseif not tonumber(args[1]) then
-- bad lat logic
return errorPrinter( {{"formatTest", "
elseif not args[4] and not args[5] and not args[6] then
-- dec logic
Line ४६२ ⟶ ४८८:
args[5], args[6], args[7], args[8], args.format)
if args[10] then
table.insert(errors, {'formatTest', '
end
if not result then
Line ४७३ ⟶ ४९९:
args[4], args[5], nil, args[6], args['format'])
if args[8] then
table.insert(errors, {'formatTest', '
end
if not result then
Line ४८४ ⟶ ५१०:
args[3], nil, nil, args[4], args.format)
if args[6] then
table.insert(errors, {'formatTest', '
end
if not result then
Line ४९२ ⟶ ५१८:
else
-- Error
return errorPrinter({{"formatTest", "अज्ञात
end
result.name = args.name
Line ४९९ ⟶ ५२५:
for _, v in ipairs(extra_param) do
if args[v] then
table.insert(errors, {'formatTest', '
end
end
Line ५०५ ⟶ ५३१:
local ret = specPrinter(args, result)
if #errors > 0 then
ret = ret .. ' ' .. errorPrinter(errors) .. '[[
end
return ret, backward
Line ५२१ ⟶ ५४७:
if snaktype == 'value' then
-- coordinates exist both here and on Wikidata, and can be compared.
ret = 'विकिडाटासँग समन्वयहरू छन्'
elseif snaktype == 'somevalue' then
ret = 'अज्ञात अर्थ विकिपिडियामा निर्देशांकहरू निर्धारण गरिन्छ'
elseif snaktype == 'novalue' then
ret = 'कुनै मतलब विकिपिडिया निर्देशांक परिभाषित गरिएको छैन'
end
else
-- We have to either import the coordinates to Wikidata or remove them here.
ret = '
end
end
if ret then
return string.format('[[
else
return ''
Line ५४५ ⟶ ५७१:
Usage:
{{#invoke:Coordinates | link }}
]]
Line ५५८ ⟶ ५८४:
Usage:
{{#invoke:Coordinates | dec2dms | decimal_coordinate | positive_suffix |
negative_suffix | precision }}
Line ५९७ ⟶ ६२३:
Usage:
{{#invoke:Coordinates | dms2dec | direction_flag | degrees |
minutes | seconds }}
Line ६२० ⟶ ६४६:
Usage:
{{#invoke:Coordinates | coord }}
{{#invoke:Coordinates | coord | lat | long }}
{{#invoke:Coordinates | coord | lat | lat_flag | long | long_flag }}
...
Line ६५३ ⟶ ६७९:
end
end
local contents, backward = formatTest(args)
Line ६९२ ⟶ ७१९:
while count <= 9 do args[count] = (args[count] or ''); count = count+1 end
end
if isInTitle(Display) and not page_title.isTalkPage and page_title.subpageText ~= '
args.notes, args.format, args.display = nil
text = text .. coord_wrapper(args)
Line ७०७ ⟶ ७३४:
Usage:
{{#invoke:Coordinates | coord2text | {{Coord}} | parameter }}
Valid values for the second parameter are strings: lat
]]
function coordinates.coord2text(frame)
if
coord = translate2en(coord)
local value, direction, long, ew = coord:match('(%-?[.%d]+)°([NS]) (%-?[.%d]+)°([EW])')
if param == 'long' then value, direction = long, ew end
value = tonumber(value)
if value then
if direction == 'S' or direction == 'W' then value = -value end
return tostring(value)
end
return nil
else
return
end
end
Line ७३८ ⟶ ७६६:
Usage:
{{#invoke:Coordinates | coordinsert | {{Coord}} | parameter:value | parameter:value | … }}
Do not make Geohack unhappy by inserting something which isn't mentioned in the {{Coord}} documentation.
|