mirror of https://github.com/aredn/aredn.git
Add <1 mile if distance to node is known but small. (#1114)
Handle kilometers
This commit is contained in:
parent
afbd22a5e6
commit
811743a7ac
|
@ -668,6 +668,12 @@ if l then
|
||||||
end
|
end
|
||||||
local now = nixio.sysinfo().uptime
|
local now = nixio.sysinfo().uptime
|
||||||
|
|
||||||
|
local metric = true
|
||||||
|
local language = os.getenv("HTTP_ACCEPT_LANGUAGE") or "en-US"
|
||||||
|
if language:match("^..%-US") or language:match("^..%-GB") then
|
||||||
|
metric = false
|
||||||
|
end
|
||||||
|
|
||||||
local rows = {}
|
local rows = {}
|
||||||
local neighservices = {}
|
local neighservices = {}
|
||||||
for ip, link in pairs(links)
|
for ip, link in pairs(links)
|
||||||
|
@ -750,12 +756,14 @@ do
|
||||||
c4c = track.quality .. "%"
|
c4c = track.quality .. "%"
|
||||||
end
|
end
|
||||||
if track.distance then
|
if track.distance then
|
||||||
if true then
|
if not metric then
|
||||||
local v = track.distance * 0.000621371
|
local v = track.distance * 0.000621371
|
||||||
if v > 1 then
|
if v > 1 then
|
||||||
c5b = math.ceil(v) .. " miles"
|
c5b = math.ceil(v) .. " miles"
|
||||||
elseif v > 0.5 then
|
elseif v > 0.5 then
|
||||||
c5b = "1 mile"
|
c5b = "1 mile"
|
||||||
|
else
|
||||||
|
c5b = "<1 mile"
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
c5b = math.ceil(track.distance * 0.001) .. " km"
|
c5b = math.ceil(track.distance * 0.001) .. " km"
|
||||||
|
|
Loading…
Reference in New Issue