%
--[[ Define some variables to make locating other resources easier.]]
local image = getImage( index )
local theRoot = ".."
local others = "."
local mySize = "large"
local pos = image.metadata.gps:gsub("[^%a%dNSEW'\",.]"," ")
local h,m,s,hem
local lat = nil
local long = nil
h,m,s,hem = pos:match("(%d*)%s+(%d*)'([%d.]*)\"%s+(%a)")
if hem ~= nil then
lat = h + (m / 60) + (s/3600)
if hem == "S" then lat = -lat end
lat = string.format("%.6f",lat)
h,m,s,hem = pos:match(hem .. "%s+(%d*)%s+(%d*)'([%d.]*)\"%s+(%a)")
if hem ~= nil then
long = h + (m / 60) + (s/3600)
if hem == "W" then long = -long end
long = string.format("%.6f",long)
end
end
function formatInfoText(theField)
local theText = image.metadata[theField] or ""
if not model.nonCSS.infoitem.processing then
return theText
end
local cnt, _ = string.find(theText, "^\<")
if cnt ~= nil then
return theText
end
-- Trim spaces
theText = theText:match "^%s*(.-)%s*$"
-- Remove newlines
theText = theText:gsub("\n"," ")
-- Remove double commas
repeat
local oldText = theText
theText = theText:gsub("%s*,%s*,",",")
until theText == oldText
theText = theText:gsub("
","\n")
-- Remove trailing commas
theText = theText:gsub("%s*,%s*[\n$]","")
-- Add styles to initial words
local buildText = ""
for v in theText:gmatch("([^\n]+)") do
local cPos = v:find(":")
if cPos ~= nil and cPos < 40 then
v = v:gsub('([^:]+):(.*)',"%1:%2")
end
buildText = buildText .. v .. "\n"
end
buildText = buildText:gsub("\n", "
")
-- Trim spaces again
theText = theText:match "^%s*(.-)%s*$"
return buildText
end
%>