diff --git a/contrib/geo_uri.lua b/contrib/geo_uri.lua index 12ac1e1..57f58bf 100644 --- a/contrib/geo_uri.lua +++ b/contrib/geo_uri.lua @@ -33,63 +33,59 @@ local dt = require "darktable" dt.configuration.check_version(...,{2,0,1}) local function checkIfBinExists(bin) - local handle = io.popen("which "..bin) - local result = handle:read() - local ret - handle:close() - if (not result) then - dt.print_error(bin.." not found") - ret = false - end - ret = true - return ret + local handle = io.popen("which "..bin) + local result = handle:read() + local ret + handle:close() + if (not result) then + dt.print_error(bin.." not found") + ret = false + end + ret = true + return ret end local function openLocationInGnomeMaps() - if not checkIfBinExists("gnome-maps") then - darktable.print_error("gnome-maps not found") - return - end + if not checkIfBinExists("gnome-maps") then + darktable.print_error("gnome-maps not found") + return + end - local sel_images = dt.gui.selection() - - local lat1 = 0; - local lon1 = 0; - local i = 0; - - local sel_images = dt.gui.selection() - --- Use the first image with geo information - for _,image in ipairs(sel_images) do - if ((image.longitude and image.latitude) and - (image.longitude ~= 0 and image.latitude ~= 90) -- Sometimes the north-pole but most likely just wrong data - ) then - - i = i + 1; - - if (i == 1) then - lat1 = image.latitude; - lon1 = image.longitude; - end - + local sel_images = dt.gui.selection() + + local lat1 = 0; + local lon1 = 0; + local i = 0; + + local sel_images = dt.gui.selection() + + -- Use the first image with geo information + for _,image in ipairs(sel_images) do + if ((image.longitude and image.latitude) and + (image.longitude ~= 0 and image.latitude ~= 90) -- Sometimes the north-pole but most likely just wrong data + ) then + + i = i + 1; + + if (i == 1) then + lat1 = image.latitude; + lon1 = image.longitude; end + + end end if (lat1 and lon1) then - - local startCommand - - startCommand = "gnome-maps \"geo:" .. lat1 .. "," .. lon1 .."\"" - end - + local startCommand + startCommand = "gnome-maps \"geo:" .. lat1 .. "," .. lon1 .."\"" dt.print_error(startCommand) - if coroutine.yield("RUN_COMMAND", startCommand) - then + if coroutine.yield("RUN_COMMAND", startCommand) then dt.print("Command failed ...") end - end + + end end -- Register