વિભાગ:Coordinates: આવૃત્તિઓ વચ્ચેનો તફાવત
Content deleted Content added
નાનું I missed a category |
નાનુંNo edit summary |
||
લીટી ૧૨:
Functions:
*function
**function
***function
****function
***function
****function
**function
**function
***function
*function
*function
]]
coordinates = {};
-- =======================================
Line ૩૦ ⟶ ૩૨:
-- =======================================
local i18n = require('Module:I18n/coordinates') -- get localized translations of site names
local Fallback = require('Module:Fallback') -- get fallback functions
local yesno = require('Module:Yesno')
Line ૭૦ ⟶ ૭૩:
NNW = 337.5,
NBW = 348.75,
}
Line ૧૧૨ ⟶ ૭૯:
local SiteURL = {
GeoHack = '//tools.wmflabs.org/geohack/geohack.php?pagename=$page¶ms=$lat_N_$lon_E_$attr&language=$lang',
GoogleEarth = '
Proximityrama = '
OpenStreetMap = '
GoogleMaps = {
Mars = '//www.google.com/mars/#lat=$lat&lon=$lon&zoom=8',
Moon = '//www.google.com/moon/#lat=$lat&lon=$lon&zoom=8',
Earth = 'https://maps.google.com/maps?ll=$lat,$lon&spn=0.01,0.01&t=k&q=http://tools.wmflabs.org/geocommons/web.kml&hl=$lang'
}
}
Line ૧૨૭ ⟶ ૯૪:
Gallery = '[[Category:Galleries with coordinates]]',
Category = '[[Category:Categories with coordinates]]',
globe = '[[Category:Media with %s locations]]',
default = '[[Category:Media with default locations]]',
Line ૧૩૮ ⟶ ૧૦૧:
local NoLatLonString = 'latitude, longitude'
-- =======================================
-- === Functions =========================
-- =======================================
-- parse attribute variable returning desired field
function
return string.match(mw.text.decode(frame.args[1]), mw.text.decode(frame.args[2]) .. ':' .. '([^_]*)') or ''
end
Line ૨૨૯ ⟶ ૧૧૫:
try to convert it to an angle
==============================================================================]]
function
local attributes
if frame.args[1] then
Line ૨૩૮ ⟶ ૧૨૪:
return ''
end
local hNum =
if hNum == nil then
return ''
Line ૨૪૫ ⟶ ૧૩૧:
end
-- Helper core function for getHeading.
function
if attributes == nil then
return nil
Line ૨૭૨ ⟶ ૧૫૮:
3) language used in formating of the number
==============================================================================]]
function
local deg = tonumber(frame.args[1])
local degPrec = tonumber(frame.args[2]) or 0-- precision in degrees
local
if
lang = frame
else -- get user's chosen language
lang = mw.message.new( "lang" ):plain()
end
if deg==nil then
return frame.args[1];
else
return
end
end
Line ૨૯૪ ⟶ ૧૮૨:
* lang - language to used when formating the number
==============================================================================]]
function
local dNum, mNum, sNum, dStr, mStr, sStr, formatStr, secPrec, c, k
local Lang = mw.language.new(lang)
Line ૩૪૪ ⟶ ૨૩૨:
* prec = geolocation precission in meters
==============================================================================]]
function
local lat = tonumber(frame.args.lat)
local lon = tonumber(frame.args.lon)
Line ૩૫૪ ⟶ ૨૪૨:
end
end
local
if
lang = frame
else -- get user's chosen language
lang = mw.message.new( "lang" ):plain()
end
if lat==nil or lon==nil then
return NoLatLonString
else
local nsew =
local SN, EW, latStr, lonStr, lon2m, lat2m, phi
if lat<0 then SN = nsew.S else SN = nsew.N end -- choose S or N depending on latitude degree sign
Line ૩૭૨ ⟶ ૨૬૨:
lat2m = 111000 -- average latitude degree size in meters
end
latStr =
lonStr =
return string.format('%s %s, %s %s', latStr, SN, lonStr, EW)
--return string.format('<span class="latitude">%s %s</span>, <span class="longitude">%s %s</span>', latStr, SN, lonStr, EW)
Line ૩૯૧ ⟶ ૨૮૧:
* attributes = attributes to be passed to GeoHack
==============================================================================]]
function
args = frame.args
lang = args.lang
lang = mw.message.new( "lang" ):plain()
end
return frame:preprocess(str)
end
Line ૪૧૨ ⟶ ૩૦૪:
* attributes = attributes to be passed to GeoHack
==============================================================================]]
function
local URLstr = SiteURL[site];
if site == 'GoogleMaps' then
Line ૪૩૭ ⟶ ૩૨૯:
* mode = set by each calling template
==============================================================================]]
function
-- indicate which template called it
if mode=='camera' then -- Used by {{Location}} and {{Location dec}}
Line ૪૬૮ ⟶ ૩૬૦:
* attributes = attributes to be passed to GeoHack
==============================================================================]]
function
-- create link and coordintate string
local latlon =
if latlon==NoLatLonString then
return latlon
else
frame.args.site = 'GeoHack'
local url =
return string.format('<span class="plainlinksneverexpand">[%s %s]</span>', url, latlon) --<span class="plainlinks nourlexpansion">
end
Line ૪૯૩ ⟶ ૩૮૫:
* namespace = namespace name: File, Category, (Gallery)
==============================================================================]]
function
lang = args.lang
lang = mw.message.new( "lang" ):plain()
end
if not args.namespace then
Line ૫૦૩ ⟶ ૩૯૬:
end
local str
if args.globe=='Earth' then -- Earth locations will have 3 or 4 links
str = string.format('[%s %s] - [%s %s]', -- - [%s %s]',
Fallback._langSwitch(i18n.OpenStreetMaps, lang),
-- GoogleMap link no longer works due to changes in the website software
--coordinates._externalLink('GoogleMaps' , 'Earth', args.lat, args.lon, lang, ''),
coordinates._externalLink('GoogleEarth' , 'Earth', args.lat, args.lon, lang, ''),
Fallback._langSwitch(i18n.GoogleEarth, lang))
if args.namespace=="Category" then
str = string.format('%s - [%s %s]', str,
coordinates._externalLink('Proximityrama', 'Earth', args.lat, args.lon, lang, ''),
Fallback._langSwitch(i18n.Proximityrama, lang))
end
elseif args.globe=='Mars' or args.globe=='Moon' then
coordinates._externalLink('GoogleMaps', args.globe, args.lat, args.lon, lang, ''), end
return frame:preprocess(str) -- use preprocess to expand {{#fullurl}}
--return str
end
Line ૫૩૯ ⟶ ૪૩૬:
* prec = geolocation precission in meters
==============================================================================]]
function
-- prepare arguments
args = frame.args
Line ૫૪૬ ⟶ ૪૪૩:
end
if not (args.lang and mw.language.isSupportedLanguage(args.lang)) then
args.lang =
end
if not (args.namespace) then -- if namespace not provided than look it up
Line ૫૫૯ ⟶ ૪૫૬:
Status = 'secondary'
end
args.attributes =
-- check for errors and add Geo (microformat) code for machine readability.
local lat = tonumber(args.lat)
local lon = tonumber(args.lon)
if args.wikidata and args.wikidata~='' and (not lat or not lon) then
-- if lat/lon is not provided but we are given wikidata q-code than look up the coordinates
local data = require('Module:Wikidata')
local args2 = {}
args2.property='P625'
args2.item=args.wikidata
args2.numval = 1
args2.link = '-'
args2.displayformat='latitude'
lat = data.formatStatements(args2)
args2.displayformat='longitude'
lon = data.formatStatements(args2)
end
if lon then -- get longitude to be in -180 to 180 range
lon=lon%360
if lon>180 then
Line ૫૭૦ ⟶ ૪૮૦:
end
end
args.lat = string.format('%010.6f', lat or 0)
args.lon = string.format('%011.6f', lon or 0)
frame.args = args
local Categories, geoMicroFormat, coorTag = '', '', ''
-- Categories, {{#coordinates}} and geoMicroFormat will be only added to File, Category and Gallery pages
Line ૫૮૭ ⟶ ૪૮૯:
if lat and lon then -- if lat and lon are numbers...
if lat==0 and lon==0 then -- lat=0 and lon=0 is a common issue when copying from flickr and other sources
Categories =
end
if frame.args.attributes and string.find(frame.args.attributes, '=') then
Line ૬૧૬ ⟶ ૫૧૮:
-- Call helper functions to render different parts of the template
local
heading =
if heading then
--str1 = string.format('%s <span style="{{Transform-rotate|%f}}">[[File:North Pointer.svg|20px|link=|alt=]]</span>', str1, 360-heading)
local fname = string.format('{{Compass rose file|%f|style=heading}}', heading)
end
str2 = Fallback._langSwitch(i18n.LocationTemplateLinkLabel, args.lang) -- header of the link section
str3 = coordinates.externalLinksSection(frame) or '' -- external link section
str4 = string.format('[[File:Circle-information.svg|18x18px|alt=info|link=%s]]', Fallback._langSwitch(i18n.COM_GEO, args.lang) )
inner_table = string.format('<td style="border:none;">%s</td><td style="border:none;">%s %s</td><td style="border:none;">%s%s</td>', str1, str2, str3, str4, geoMicroFormat)
-- combine strings into a table
Line ૬૪૭ ⟶ ૫૩૯:
local field_name = 'Location'
if args.mode=='camera' then
field_name =
elseif args.mode=='object' then
field_name =
elseif args.mode=='globe' then
field_list =
if args.globe and i18n.GlobeLocation['en'][args.globe] then -- verify globe is provided and is recognized
field_name = field_list[args.globe]
end
end
local style = frame:expandTemplate{ title="Infobar-Layout", args={ ["lang"] = lang, ["class"] = 'commons-file-information-table' } }
templateText = string.format('<table lang="%s" %s><tr><th class="type fileinfo-paramfield">%s</th>%s</tr></table>', lang, style, field_name, inner_table)
end
return frame:preprocess(templateText .. Categories .. coorTag)
end
return
|