"मोड्युल:Coordinates" का संशोधनहरू बिचको अन्तर

Content deleted Content added
--
चिनो: हातले पूर्ववत
सफाइ गरियो
चिनो: फर्काई दियो
पङ्क्ति १:
--[[
This module is intended to replace the functionality of {{Coord}} and related
templates. It provides several methods, including
 
{{#invoke:Coordinates | coord }} : General function formatting and displaying
coordinate values.
 
{{#invoke:Coordinates | dec2dms }} : Simple function for converting decimal
degree values to DMS format.
 
{{#invoke:Coordinates | dms2dec }} : Simple function for converting DMS format
to decimal degree format.
 
{{#invoke:Coordinates | link }} : Export the link used to reach the tools
 
]]
 
require('strictModule:No globals')
 
local math_mod = require("Module:Math")
local convert = require( "Module:Numeral converter" ).convert;
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 .. '&params='
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 = "[[भौगोलिक निर्देशाङ्क प्रणाली|निर्देशाङ्कहरूनिर्देशाङ्क]]: " .. s
local co = '<span id="coordinates">' .. l .. notes .. '</span>';
return mw.getCurrentFrame():extensionTag{
return '<span style="font-size: small;">' .. co .. '</span>';
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
wrappers = 'Template:Coord'
})
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">निर्देशाङ्कहरूनिर्देशाङ्क: ' .. v[2] .. '</strong>'
result = result .. errorHTML .. "<br />"
end
Line १०५ ⟶ १५५:
if uriComponents == "" then
-- RETURN error, should never be empty or nil
return "त्रुटि प्यारामिटरparam खाली थियो"
end
if args["name"] then
Line १११ ⟶ १६१:
end
 
local geodmshtml = '<span class="geo-dms" title="यस स्थानको लागि नक्शाहरूनक्सा, हवाइहवाई तस्वीरहरूइमेजरी, र यस स्थानको लागि अन्य तस्वीरहरूजानकारी">'
.. '<span class="latitude">' .. converttranslate2bn("ne", coordinateSpec["dms-lat"]) .. '</span> '
.. '<span class="longitude">' .. converttranslate2bn("ne", coordinateSpec["dms-long"]) .. '</span>'
.. '</span>'
 
Line १२० ⟶ १७०:
if lat < 0 then
-- FIXME this breaks the pre-existing precision
geodeclat = tostring(coordinateSpec["dec-lat"]):sub(2) .. "°S दक्षिण"
else
geodeclat = (coordinateSpec["dec-lat"] or 0) .. "°N उत्तर"
end
 
Line १२९ ⟶ १७९:
if long < 0 then
-- FIXME does not handle unicode minus
geodeclong = tostring(coordinateSpec["dec-long"]):sub(2) .. "°W पश्चिम"
else
geodeclong = (coordinateSpec["dec-long"] or 0) .. "°E पूर्व"
end
 
local geodechtml = '<span class="geo-dec" title="नक्सा, हवाई इमेजरी, र यस स्थानको लागि अन्य जानकारी">'
local function devanagariChars(enChar)
.. translate2bn(geodeclat) .. ' '
if enChar == "°W" then
.. translate2bn(geodeclong)
return "°प"
elseif enChar == "°N" then
return "°उ"
elseif enChar == "°S" then
return "°द"
elseif enChar == "°E" then
return "°पू"
end
end
 
local geodechtml = '<span class="geo-dec" title="यस स्थानको लागि नक्शाहरू, हवाइ तस्वीरहरू, र अन्य तस्वीरहरू">'
.. convert("ne", geodeclat) .. ' '
.. convert("ne", geodeclong)
.. '</span>'
 
Line २६७ ⟶ ३०५:
if strong then
if lat_d < 0 then
table.insert(errors, {source, "latitudeगोलार्ध degreesझन्डा <सहितको 0अक्षांशको withडिग्री hemisphere< flag"})
end
if long_d < 0 then
table.insert(errors, {source, "longitudeगोलार्ध degreesझन्डा <सहित 0देशान्तरको withडिग्री hemisphere< flag"})
end
--[[
Line २७९ ⟶ ३१७:
 
if long_d > 180 then
table.insert(errors, {source, "longitudeगोलार्ध degreesझन्डा >सहित 180देशान्तरको withडिग्री hemisphere> flag१८०"})
end
]]
Line २८५ ⟶ ३२३:
 
if lat_d > 90 then
table.insert(errors, {source, "अक्षांशअक्षांशको डिग्री > 90९०"})
end
if lat_d < -90 then
table.insert(errors, {source, "अक्षांशअक्षांशको डिग्री < -90९०"})
end
if lat_m >= 60 then
table.insert(errors, {source, "अक्षांश मिनेटन्यूनतम >= 60६०"})
end
if lat_m < 0 then
table.insert(errors, {source, "अक्षांश मिनेटन्यूनतम < 0"})
end
if lat_s >= 60 then
table.insert(errors, {source, "अक्षांश सेकेण्डसेकेन्ड >= 60६०"})
end
if lat_s < 0 then
table.insert(errors, {source, "अक्षांश सेकेण्डसेकेन्ड < 0"})
end
if long_d >= 360 then
table.insert(errors, {source, "देशान्तरदेशान्तरको डिग्री >= 360३६०"})
end
if long_d <= -360 then
table.insert(errors, {source, "देशान्तरदेशान्तरको डिग्री <= -360३६०"})
end
if long_m >= 60 then
table.insert(errors, {source, "देशान्तरदेशान्तरको मिनेटडिग्री >= 60६०"})
end
if long_m < 0 then
table.insert(errors, {source, "देशान्तरदेशान्तरको मिनेटडिग्री < 0"})
end
if long_s >= 60 then
table.insert(errors, {source, "देशान्तरदेशान्तरको सेकेण्डडिग्री >= 60६०"})
end
if long_s < 0 then
table.insert(errors, {source, "देशान्तरदेशान्तरको सेकेण्डडिग्री < 0"})
end
 
Line ३३५ ⟶ ३७३:
 
if not long then
return nil, {{"parseDec", "छुटेको देशान्तर छैन"}}
elseif not tonumber(long) then
return nil, {{"parseDec", "देशान्तरलाई अङ्ककोसङ्ख्याको रूपमा पार्स गर्न सकिएनसकिँदैन: " .. long}}
end
 
Line ३४५ ⟶ ३८३:
 
local mode = coordinates.determineMode( lat, long );
coordinateSpec["dms-lat"] = convert_dec2dms( lat, "N उत्तर", "S दक्षिण", mode) -- {{coord/dec2dms|{{{1}}}|N|S|{{coord/prec dec|{{{1}}}|{{{2}}}}}}}
coordinateSpec["dms-long"] = convert_dec2dms( long, "E पूर्व", "W पश्चिम", mode) -- {{coord/dec2dms|{{{2}}}|E|W|{{coord/prec dec|{{{1}}}|{{{2}}}}}}}
 
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", "देशान्तरलाई अङ्ककोसङ्ख्याको रूपमा पार्स गर्न सकिएनसकिँदैन:" .. long_d }}
end
 
Line ३९४ ⟶ ४३२:
end
 
coordinateSpec["dms-lat"] = lat_d.."°"..optionalArg(lat_m,"′") .. optionalArg(lat_s,"″") .. direction2bn(lat_f)
local function devanagariChars(enChar)
coordinateSpec["dms-long"] = long_d.."°"..optionalArg(long_m,"′") .. optionalArg(long_s,"″") .. direction2bn(long_f)
if enChar == "W" then
return "प॰"
elseif enChar == "N" then
return "उ॰"
elseif enChar == "S" then
return "द॰"
elseif enChar == "E" then
return "पू॰"
end
end
 
coordinateSpec["dms-lat"] = lat_d.."°"..optionalArg(lat_m,"′") .. optionalArg(lat_s,"″") .. devanagariChars(lat_f)
coordinateSpec["dms-long"] = long_d.."°"..optionalArg(long_m,"′") .. optionalArg(long_s,"″") .. devanagariChars(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", "अक्षांशलाई अङ्ककोसङ्ख्याको रूपमा अक्षांश पार्स गर्न सकिएनअसफल:" .. args[1]}} )
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", "अज्ञात आर्गुमेन्टतर्क ढाँचा"}}) .. '[[Category:विकृत निर्देशाङ्क ट्यागहरू भएका पानाहरू]]'
end
result.name = args.name
Line ४९९ ⟶ ५२५:
for _, v in ipairs(extra_param) do
if args[v] then
table.insert(errors, {'formatTest', 'Parameterप्यारामिटर: "' .. v .. '=" should beहुनुपर्छ "' .. v .. ':"' })
end
end
Line ५०५ ⟶ ५३१:
local ret = specPrinter(args, result)
if #errors > 0 then
ret = ret .. ' ' .. errorPrinter(errors) .. '[[Categoryश्रेणी:विकृतगलत निर्देशाङ्कअनुक्रमणिका ट्यागहरू भएका पानाहरूपृष्ठहरू]]'
end
return ret, backward
Line ५२१ ⟶ ५४७:
if snaktype == 'value' then
-- coordinates exist both here and on Wikidata, and can be compared.
ret = 'विकिडाटासँग समन्वयहरू छन्'
ret = 'विकिडाटामा निर्देशाङ्कहरू'
elseif snaktype == 'somevalue' then
ret = 'अज्ञात अर्थ विकिपिडियामा निर्देशांकहरू निर्धारण गरिन्छ'
ret = 'विकिडाटामा निर्देशाङ्कको अज्ञात मान राखिएको छ'
elseif snaktype == 'novalue' then
ret = 'कुनै मतलब विकिपिडिया निर्देशांक परिभाषित गरिएको छैन'
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('[[Categoryश्रेणी:%s]]', ret)
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 ~= 'docकागजात' and page_title.subpageText ~= 'testcasesपरीक्षण पृष्ठ' then args[10] = 'primary' end
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 (signed integer), long (signed integer), type, scale, dim, region, globe, source
 
]]
function coordinates.coord2text(frame)
iflocal frame.args[1]coord == '' or mw.text.trim(frame.args[21] ==or '' or not frame.args[2] then return nil end)
frame.args[2]local param = mw.text.trim(frame.args[2] or '')
if frame.args[2]coord == 'lat' or frame.args[2]param == 'long' then return nil end
coord = translate2en(coord)
local result, negative = mw.text.split((mw.ustring.match(frame.args[1],'[%.%d]+°[NS] [%.%d]+°[EW]') or ''), ' ')
if frame.args[2]param == 'lat' or param == 'long' then
local value, direction, long, ew = coord:match('(%-?[.%d]+)°([NS]) (%-?[.%d]+)°([EW])')
result, negative = result[1], 'S'
if param == 'long' then value, direction = long, ew end
else
value = tonumber(value)
result, negative = result[2], 'W'
if value then
if direction == 'S' or direction == 'W' then value = -value end
return tostring(value)
end
return nil
result = mw.text.split(result, '°')
if result[2] == negative then result[1] = '-'..result[1] end
return result[1]
else
return mw.ustring.coord:match(frame.args[1], 'params=.-_'..frame.args[2]param..':(.-)[ _]')
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.
"https://ne.wikipedia.org/wiki/मोड्युल:Coordinates" बाट अनुप्रेषित