417
edits
Chalochatu (talk | contribs) No edit summary |
Chalochatu (talk | contribs) No edit summary |
||
Line 116: | Line 116: | ||
end | end | ||
return decimal | return decimal | ||
end | |||
-- Finds a parameter in a transclusion of {{Coord}}. | |||
local function coord2text(para,coord) | |||
if not coord or coord == '' then return nil end | |||
local result = mw.text.split(mw.ustring.match(coord,'%d+%.?%d*°[NS] %d+%.?%d*°[EW]'), '[ °]') | |||
if para == 'longitude' then result = {result[3], result[4]} end | |||
return tonumber(result[1]) * hemisphereMultipliers[para][result[2]] | |||
end | end | ||
Line 335: | Line 343: | ||
end | end | ||
local x, y, longitude, latitude | local x, y, longitude, latitude | ||
longitude = decdeg(args.lon_deg, args.lon_min, args.lon_sec, args.lon_dir, args.long, 'longitude') | longitude = decdeg(args.lon_deg, args.lon_min, args.lon_sec, args.lon_dir, args.long, 'longitude') or coord2text('longitude', args.coordinates) | ||
latitude = decdeg(args.lat_deg, args.lat_min, args.lat_sec, args.lat_dir, args.lat, 'latitude') | latitude = decdeg(args.lat_deg, args.lat_min, args.lat_sec, args.lat_dir, args.lat, 'latitude') or coord2text('latitude', args.coordinates) | ||
if not longitude and not latitude and args.useWikidata then | if not longitude and not latitude and args.useWikidata then | ||
-- If they didn't provide either coordinate, try Wikidata. If they provided one but not the other, don't. | -- If they didn't provide either coordinate, try Wikidata. If they provided one but not the other, don't. |
edits