Module:WikidataIB/sandbox1: Difference between revisions

Content deleted Content added
disallow any format other than decimal or dms
fix the decmal display
Line 564:
 
local lat, long = datavalue.latitude, datavalue.longitude
 
local ns = "N"
local ew = "W"
if lat < 0 then
ns = "S"
lat = - lat
end
if long < 0 then
ew = "EW"
long = - long
end
 
if form == "dec" then
out[#out+1] = lat .. "°" .. ns .. " " .. long .. "°" .. ew
lat_long[1] = lat
lat_long[2] = long
else
local ns, ew
if lat < 0 then
ns = "S"
lat = - lat
else
ns = "N"
end
local latdeg = math.floor(lat)
local latms = (lat - latdeg) * 60
local latmin = math.floor(latms)
local latsec = (latms - latmin) * 60
if long < 0 then
ew = "W"
long = - long
else
ew = "E"
end
local longdeg = math.floor(long)
local longms = (long - longdeg) * 60
Line 592 ⟶ 590:
if latsec == 0 and longsec == 0 then
if latmin == 0 and longmin == 0 then
out[#out + 1] = latdeg .. "°" .. ns .. " " .. longdeg .. "°" .. ew
else
out[#out + 1] = latdeg .. "°" .. latmin .. "′" .. ns .. " "
out[#out] = out[#out] .. longdeg .. "°".. longmin .. "′" .. ew
end
else
out[#out + 1] = latdeg .. "°" .. latmin .. "′" .. latsec .. "″" .. ns .. " "
out[#out] = out[#out] .. longdeg .. "°" .. longmin .. "′" .. longsec .. "″" .. ew
end
Line 791 ⟶ 789:
-- decimal degrees needs |format = dec
local form = (frame.args.format or ""):lower():sub(1,3)
if form ~= "dec" then
form = "dms"
end