Content deleted Content added
Minor optimisation |
Another Wikidata bug in geo coordinates has been fixed |
||
Line 636:
return value
elseif snak.datavalue.type == 'globecoordinate' then
-- logic from https://github.com/DataValues/Geo
local precision, numDigits, strFormat, value, globe
local latValue, latitude, latDegrees, latMinutes, latSeconds
Line 671 ⟶ 673:
longitude = math.floor(longitude / precision + 0.5) * precision
lonDegrees = math.floor(longitude)▼
-- use string.format() to strip decimal point followed by a zero (.0) for whole numbers
latSeconds = tonumber(string.format(strFormat, math.floor(latitude * 3600 * 10^numDigits + 0.5) / 10^numDigits))
lonSeconds = tonumber(string.format(strFormat, math.floor(longitude * 3600 * 10^numDigits + 0.5) / 10^numDigits))
lonMinutes = math.floor(lonSeconds / 60)
latSeconds = latSeconds - (latMinutes * 60)
lonSeconds = lonSeconds - (lonMinutes * 60)
latValue = latDegrees .. degSymbol
Line 689 ⟶ 706:
if precision < (1 / 60) then
▲ if numDigits < 0 or numDigits == -0 then
▲ numDigits = 0
▲ end
▲ strFormat = "%." .. numDigits .. "f"
latSeconds = string.format(strFormat, latSeconds)
lonSeconds = string.format(strFormat, lonSeconds)
|