વિભાગ:Coordinates: આવૃત્તિઓ વચ્ચેનો તફાવત
Content deleted Content added
fix some problematic use of "frame" to pass arguments around and delineate functions to be called from Wikitext from the ones to be called from other LUA codes |
નાનું correct zero padded strings in non-latin languages |
||
લીટી ૪૨:
-- =======================================
-- Angles associated with each
local compass_points = {
N = 0,
લીટી ૩૪૧:
--[[============================================================================
Convert degrees to degrees/minutes/seconds notation
coordinates.
Inputs:
1) latitude or longitude angle in degrees
2) georeference
3) language used in
==============================================================================]]
function p.deg2dms(frame)
લીટી ૩૬૫:
Inputs:
* degree - positive coordinate in degrees
* degPrec - coordinate
* lang - language to used when
==============================================================================]]
function p._deg2dms(degree, degPrec, lang)
local dNum, mNum, sNum, dStr, mStr, sStr, formatStr, secPrec, c, k, zero
local Lang = mw.language.new(lang)
-- adjust number display based on
secPrec = degPrec*3600.0 -- coordinate
if secPrec<0.05 then -- degPrec<1.3889e-05
formatStr = '%s° %s′ %s″' -- use DD° MM′ SS.SS″ format
લીટી ૪૦૦:
mStr = Lang:formatNum(mNum) -- minute string
sStr = Lang:formatNum(sNum) -- second string
zero = Lang:formatNum(0) -- zero string in local language
if mNum<10 then
mStr =
end
if sNum<10 then
sStr =
end
return string.format(formatStr, dStr, mStr, sStr);
Line ૪૧૧ ⟶ ૪૧૨:
--[[============================================================================
Format coordinate location string, by creating and joining DMS strings for
INPUTS:
* lat = latitude in degrees
* lon = longitude in degrees
* lang = language code
* prec = geolocation
==============================================================================]]
function p._lat_lon(lat, lon, prec, lang)
Line ૪૨૨ ⟶ ૪૨૩:
lon = tonumber(lon)
prec = math.abs(tonumber(prec) or 0)
if lon then -- get longitude
lon=lon%360
if lon>180 then
Line ૪૩૭ ⟶ ૪૩૮:
lat2m=1
lon2m=1
if prec>0 then -- if user specified the
phi = math.abs(lat)*math.pi/180 -- latitude in radiants
lon2m = 6378137*math.cos(phi)*math.pi/180 -- see https://en.wikipedia.org/wiki/Longitude
Line ૪૫૭ ⟶ ૪૫૮:
Create URL for different sites.
INPUTS:
* site =
OpenStreetMap, GoogleMaps (for Earth, Mars and Moon)
* globe = Possible options: Earth, Mars or Moon. Venus, Mercury, Titan,
Line ૪૭૪ ⟶ ૪૭૫:
Helper core function for externalLink. Create URL for different sites:
INPUTS:
* site =
OpenStreetMap, GoogleMaps (for Earth, Mars and Moon)
* globe = Possible options: Earth, Mars or Moon. Venus, Mercury, Titan,
Line ૫૪૨ ⟶ ૫૪૩:
* lon = longitude in degrees
* lang = language code
* prec = geolocation
* attributes = attributes to be passed to GeoHack
==============================================================================]]
Line ૬૧૦ ⟶ ૬૧૧:
--[[============================================================================
Core section of template:Location, template:Object location and template:Globe location.
This method requires several arguments to be passed to it or it's parent
* globe = Possible options: Earth, Mars or Moon. Venus, Mercury, Titan, Ganymede are also supported but are unused as of 2013.
* mode = Possible options:
Line ૬૨૧ ⟶ ૬૨૨:
* lang = language code
* namespace = namespace: File, Category, Gallery
* prec = geolocation
==============================================================================]]
function p.LocationTemplateCore(frame)
|