વિભાગ: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 abriviationabbreviation of compass point names. See [[:en:Points of the compass]]
local compass_points = {
N = 0,
લીટી ૩૪૧:
 
--[[============================================================================
Convert degrees to degrees/minutes/seconds notation comonlycommonly used when displaying
coordinates.
Inputs:
1) latitude or longitude angle in degrees
2) georeference precissionprecision in degrees
3) language used in formatingformatting of the number
==============================================================================]]
function p.deg2dms(frame)
લીટી ૩૬૫:
Inputs:
* degree - positive coordinate in degrees
* degPrec - coordinate precissionprecision in degrees will result in different angle format
* lang - language to used when formatingformatting the number
==============================================================================]]
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 precissionprecision
secPrec = degPrec*3600.0 -- coordinate precissionprecision in seconds
if secPrec<0.05 then -- degPrec<1.3889e-05
formatStr = '%s°&nbsp;%s′&nbsp;%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 = '0'zero .. mStr -- pad with zero if a single digit
end
if sNum<10 then
sStr = '0'zero .. sStr -- pad with zero if less than ten
end
return string.format(formatStr, dStr, mStr, sStr);
Line ૪૧૧ ⟶ ૪૧૨:
--[[============================================================================
Format coordinate location string, by creating and joining DMS strings for
latutudelatitude and longitude. Also convert precissionprecision from meters to degrees.
INPUTS:
* lat = latitude in degrees
* lon = longitude in degrees
* lang = language code
* prec = geolocation precissionprecision in meters
==============================================================================]]
function p._lat_lon(lat, lon, prec, lang)
Line ૪૨૨ ⟶ ૪૨૩:
lon = tonumber(lon)
prec = math.abs(tonumber(prec) or 0)
if lon then -- get longitude t0to be in -180 to 180 range
lon=lon%360
if lon>180 then
Line ૪૩૭ ⟶ ૪૩૮:
lat2m=1
lon2m=1
if prec>0 then -- if user specified the precissionprecision of the geo location...
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 = PossinlePossible sites: GeoHack, GoogleEarth, Proximityrama,
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 = PossinlePossible sites: GeoHack, GoogleEarth, Proximityrama,
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 precissionprecision in meters
* 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 metchodmethod/template:
* 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 precissionprecision in meters
==============================================================================]]
function p.LocationTemplateCore(frame)