From 71e726992774fb31ab4b7327a5c6b3d09acde119 Mon Sep 17 00:00:00 2001 From: supertobi Date: Sun, 8 Jan 2017 20:54:12 +0100 Subject: [PATCH 01/12] geo toolbox this script replaces: calcDistance.lua geo_uri.lua gps_select.lua --- contrib/geoToolbox.lua | 590 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 590 insertions(+) create mode 100644 contrib/geoToolbox.lua diff --git a/contrib/geoToolbox.lua b/contrib/geoToolbox.lua new file mode 100644 index 0000000..33b95ca --- /dev/null +++ b/contrib/geoToolbox.lua @@ -0,0 +1,590 @@ +--[[ + This file is part of darktable, + copyright (c) 2016 Tobias Jakobs + + darktable is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + darktable is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with darktable. If not, see . +]] +--[[ + +USAGE +* require this script from your main lua file + To do this add this line to the file .config/darktable/luarc: +require "geoToolbox" + +* it creates a new geoToolbox lighttable module +]] + +local dt = require "darktable" +local df = require "lib/dtutils.file" +local gettext = dt.gettext + +dt.configuration.check_version(...,{3,0,0},{4,0,0}) + +-- Tell gettext where to find the .mo file translating messages for a particular domain +gettext.bindtextdomain("geoToolbox",dt.configuration.config_dir.."/lua/") + +local function _(msgid) + return gettext.dgettext("geoToolbox", msgid) +end + +-- +local labelDistance = dt.new_widget("label") +labelDistance.label = "Distance:" + +local labelCopyGPSlat = dt.new_widget("check_button") +{ + label = "latitude:", + value = true +} +local labelCopyGPSlon = dt.new_widget("check_button") +{ + label = "longitude:", + value = true +} +local labelCopyGPSele = dt.new_widget("check_button") +{ + label = "elevation:", + value = true +} +-- + +local function selectWithGPS() + local selection = {} + for _,image in ipairs(dt.database) do + if (image.longitude and image.latitude) then + table.insert(selection,image) + end + end + dt.gui.selection(selection) +end + +local function selectWithoutGPS() + local selection = {} + for _,image in ipairs(dt.database) do + if (not image.longitude and not image.latitude) then + table.insert(selection,image) + end + end + dt.gui.selection(selection) +end + +-- This is used for older images in the DB +function isnan(x) return x ~= x end + +-- Function from: +-- https://forums.coronalabs.com/topic/29019-convert-string-to-date/ +-- This looks much scarier than it really is. The goal is to turn that string +-- into a Unix timestamp (number of seconds since Jan 1, 1970, the standard +-- used by most systems). So we use the string.match() method to fetch the +-- various date and time parts into their own variables: xyear, xmonth,etc. +function makeTimeStamp(dateString) + local convertedTimestamp +--dt.print_error(dateString) + if (dateString) then + local pattern = "(%d+)%:(%d+)%:(%d+) (%d+):(%d+):(%d+)" + local xyear, xmonth, xday, xhour, xminute, xseconds = dateString:match(pattern) +--dt.print_error(xyear) + convertedTimestamp = os.time({ + year = xyear, + month = xmonth, + day = xday, + hour = xhour, + min = xminute, + sec = xseconds}) + else + convertedTimestamp = 0 + end + + return convertedTimestamp +end + +local first_have_data = false +local first_latitude = '' +local first_longitude = '' +local first_elevation = '' +local first_image_date = 0 + +local function getFirstCoordinate() + local sel_images = dt.gui.selection() + + first_latitude = '' + first_longitude = '' + first_elevation = '' + first_image_date = 0 + + for _,image in ipairs(sel_images) do + if not image then + first_have_data = false + else + image_date = image.exif_datetime_taken + first_have_data = true + if (image.latitude) then + first_latitude = image.latitude + end + if (image.longitude) then + first_longitude = image.longitude + end + if (image.elevation) then + first_elevation = image.elevation + end + if (image.exif_datetime_taken) then + first_image_date = makeTimeStamp(image.exif_datetime_taken) +--dt.print_error(image.exif_datetime_taken) +--dt.print_error(first_image_date) + end + end + return + end +end + +local second_have_data = false +local second_latitude = '' +local second_longitude = '' +local second_elevation = '' +local second_image_date = 0 + +local function getSecondCoordinate() + local sel_images = dt.gui.selection() + + second_latitude = '' + second_longitude = '' + second_elevation = '' + second_image_date = 0 + + for _,image in ipairs(sel_images) do + if not image then + second_have_data = false + else + image_date = image.exif_datetime_taken + second_have_data = true + if (image.latitude) then + second_latitude = image.latitude + end + if (image.longitude) then + second_longitude = image.longitude + end + if (image.elevation) then + second_elevation = image.elevation + end + if (image.exif_datetime_taken) then + second_image_date = makeTimeStamp(image.exif_datetime_taken) + end + end + return + end +end + +local calcInBetweenSlider = dt.new_widget("slider") +{ + label = "Position between", + soft_min = 0, -- The soft minimum value for the slider, the slider can't go beyond this point + soft_max = 100, -- The soft maximum value for the slider, the slider can't go beyond this point + hard_min = -100, -- The hard minimum value for the slider, the user can't manually enter a value beyond this point + hard_max = 200, -- The hard maximum value for the slider, the user can't manually enter a value beyond this point + value = 50 -- The current value of the slider +} + +--ToDo: this needs more love +local function calcInBetween() + local sel_images = dt.gui.selection() + for _,image in ipairs(sel_images) do + if image then + image_date = makeTimeStamp(image.exif_datetime_taken) + if (first_have_data and second_have_data) then + local start_new = 0 + local end_new = second_image_date - first_image_date + local image_date_new = image_date - first_image_date + + local percent_in_between + if (end_new == 0) then + percent_in_between = 1 + else + percent_in_between = image_date_new/end_new + end + calcInBetweenSlider.value = percent_in_between * 100 +dt.print_error(percent_in_between) + local in_between_latitude = first_latitude + (second_latitude - first_latitude) * percent_in_between + local in_between_longitude = first_longitude + (second_longitude - first_longitude) * percent_in_between + + if (first_elevation and second_elevation) then + local in_between_elevation = first_elevation + (second_elevation - first_elevation) * percent_in_between + +dt.print_error(first_image_date) +dt.print_error(second_image_date) +dt.print_error(image_date) +dt.print_error(first_elevation) +dt.print_error(second_elevation) +dt.print_error(in_between_elevation) + + end + end + end + end +end + +local copyGPS_have_data = false +local copyGPS_latitude = '' +local copyGPS_longitude = '' +local copyGPS_elevation = '' + +local function copyGPS() + local sel_images = dt.gui.selection() + + copyGPS_latitude = '' + copyGPS_longitude = '' + copyGPS_elevation = '' + + for _,image in ipairs(sel_images) do + if not image then + copyGPS_have_data = false + else + copyGPS_have_data = true + if (image.latitude and labelCopyGPSlat.value) then + copyGPS_latitude = image.latitude + end + if (image.longitude and labelCopyGPSlon.value) then + copyGPS_longitude = image.longitude + end + if (image.elevation and labelCopyGPSele.value) then + copyGPS_elevation = image.elevation + end + end + + labelCopyGPSlat.label = "latitude: " .. copyGPS_latitude + labelCopyGPSlon.label = "longitude: " ..copyGPS_longitude + labelCopyGPSele.label = "elevation: " .. copyGPS_elevation + + return + end +end + +local function pastGPS(image) + local sel_images = dt.gui.selection() + + for _,image in ipairs(sel_images) do + if (labelCopyGPSlat.value) then + image.latitude = copyGPS_latitude + end + if (labelCopyGPSlon.value) then + image.longitude = copyGPS_longitude + end + if (labelCopyGPSele.value) then + image.elevation = copyGPS_elevation + end + end +end + +local function openLocationInGnomeMaps() + + if not df.check_if_bin_exists("gnome-maps") then + dt.print_error(_("gnome-maps not found")) + return + end + + local sel_images = dt.gui.selection() + + local lat1 = 0; + local lon1 = 0; + local i = 0; + + -- 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 + lat1 = image.latitude; + lon1 = image.longitude; + break + end + + local startCommand + startCommand = "gnome-maps \"geo:" .. lat1 .. "," .. lon1 .."\"" + dt.print_error(startCommand) + + if coroutine.yield("RUN_COMMAND", startCommand) then + dt.print(_("Command failed ...")) + end + + end + +end + + +-- I used code from here: +-- http://stackoverflow.com/questions/27928/how-do-i-calculate-distance-between-two-latitude-longitude-points +local function getDistance(lat1, lon1, ele1, lat2, lon2, ele2) + + local earthRadius = 6371; -- Radius of the earth in km + local dLat = math.rad(lat2-lat1); -- deg2rad below + local dLon = math.rad(lon2-lon1); + local a = + math.sin(dLat/2) * math.sin(dLat/2) + + math.cos(math.rad(lat1)) * math.cos(math.rad(lat2)) * + math.sin(dLon/2) * math.sin(dLon/2) + ; + local angle = 2 * math.atan2(math.sqrt(a), math.sqrt(1-a)); + local distance = earthRadius * angle; -- Distance in km + + -- Add the elevation to the calculation + local elevation = 0 + elevation = math.abs(ele1 - ele2) / 1000; --in km + + if (elevation > 0) then + distance = math.sqrt(math.pow(elevation,2) + math.pow(distance,2) ) + end + return distance +end + +local function calcDistance() + + local sel_images = dt.gui.selection() + + local lat1 = 0; + local lon1 = 0; + local lat2 = 0; + local lon2 = 0; + local ele1 = 0; + local ele2 = 0; + local i = 0; + + local sel_images = dt.gui.selection() + + 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 + if (image.elevation) then + ele1 = image.elevation + else + ele1 = 0 + end + end + + lat2 = image.latitude + lon2 = image.longitude + if (image.elevation) then + ele2 = image.elevation + else + ele2 = 0; + end + + end + end + + local distance = getDistance(lat1, lon1, ele1, lat2, lon2, ele2) + + if (distance < 1) then + distance = distance * 1000 + distanceUnit = "m" + else + distanceUnit = "km" + end + + return string.format("Distance: %.2f %s", distance, distanceUnit) +end + +local function printCalcDistance() + dt.print(calcDistance()) +end + +local function toolboxCalcDistance() + labelDistance.label = calcDistance() +end + +local altitude_file_chooser_button = dt.new_widget("file_chooser_button") + { + title = "export altitude CSV", -- The title of the window when choosing a file + value = "", -- The currently selected file + is_directory = true -- True if the file chooser button only allows directories to be selecte + } +local altitude_filename = dt.new_widget("entry") + { + text = "altitude.csv", + placeholder = "altitude.csv", + editable = true, + tooltip = "Name of the exported file", + reset_callback = function(self) self.text = "text" end + } + +local function altitudeProfile() + dt.print("Start export") + local sel_images = dt.gui.selection() + + local lat1 = 0; + local lon1 = 0; + local lat2 = 0; + local lon2 = 0; + local ele1 = 0; + local ele2 = 0; + local i = 0; + local csv_file = ''; + csv_file = "km;m".."\n"; + + local distance = 0; + local distanceFromStart = 0; + local elevation = 0; + local elevationAdd = 0; + + local sel_images = dt.gui.selection() + for _,image in ipairs(sel_images) do + if ((not isnan(image.longitude) and not isnan(image.latitude) and not isnan(image.elevation) and image.elevation) 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 + ele1 = image.elevation + else + lat1 = lat2 + lon1 = lon2 + ele1 = ele2 + end + + lat2 = image.latitude + lon2 = image.longitude + ele2 = image.elevation + + if (i == 1) then + distanceFromStart = 0 + else + local distance = getDistance(lat1, lon1, ele1, lat2, lon2, ele2) + distanceFromStart = distanceFromStart + distance; + end + + csv_file = csv_file .. distanceFromStart..";"..image.elevation.."\n"; + + end + + end --for + + local exportDirectory = altitude_file_chooser_button.value + local exportFilename = altitude_filename.text + if (exportFilename == '') then + exportFilename = altitude_filename.placeholder + end + file = io.open(exportDirectory.."/"..exportFilename, "w") + file:write(csv_file) + file:close() + dt.print("File created in "..exportDirectory) + +end + + +local separator = dt.new_widget("separator"){} +local separator2 = dt.new_widget("separator"){} +local separator3 = dt.new_widget("separator"){} +local separator4 = dt.new_widget("separator"){} + +dt.register_lib( + "geoToolbox", -- Module name + "geo toolbox", -- name + true, -- expandable + false, -- resetable + {[dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER", 100}}, -- containers + dt.new_widget("box") + { + orientation = "vertical", + dt.new_widget("button") + { + label = "select geo images", + tooltip = "Select all images with GPS information", + clicked_callback = selectWithGPS + }, + dt.new_widget("button") + { + label = "select not geo images", + tooltip = "Select all images without GPS information", + clicked_callback = selectWithoutGPS + }, + separator,-------------------------------------------------------- + dt.new_widget("button") + { + label = "copy GPS data", + tooltip = "Copy the GPS data", + clicked_callback = copyGPS + }, + labelCopyGPSlat, + labelCopyGPSlon, + labelCopyGPSele, + dt.new_widget("button") + { + label = "past GPS data", + tooltip = "Past the GPS data", + clicked_callback = pastGPS + }, + separator2,-------------------------------------------------------- +--ToDo: This need a better UI +--[[ + dt.new_widget("button") + { + label = "get 1st coordinate", + tooltip = "Select first image and click this button", + clicked_callback = getFirstCoordinate + }, + dt.new_widget("button") + { + label = "get 2nd coordinate", + tooltip = "Select second image and click this button", + clicked_callback = getSecondCoordinate + }, + dt.new_widget("button") + { + label = "calc in between", + tooltip = "Select third image and click this button", + clicked_callback = calcInBetween + }, + calcInBetweenSlider, + separator3,-------------------------------------------------------- +]] + dt.new_widget("button") + { + label = "Open in Gnome Maps", + tooltip = "Open Location in Gnome Maps", + clicked_callback = openLocationInGnomeMaps + }, + separator4,-------------------------------------------------------- + dt.new_widget("label"){label = "altitude CSV export"}, + altitude_file_chooser_button, + altitude_filename, + dt.new_widget("button") + { + label = "export altitude CSV file", + tooltip = "create an altitude profile using the GPS data in the metadata", + clicked_callback = altitudeProfile + }, + labelDistance + }, + nil,-- view_enter + nil -- view_leave +) + + +-- Register +dt.register_event("shortcut",printCalcDistance,_("Calculate the distance from latitude and longitude in km")) +dt.register_event("mouse-over-image-changed",toolboxCalcDistance) + +dt.register_event("shortcut", selectWithGPS, _("Select all images with GPS information")) +dt.register_event("shortcut", selectWithoutGPS, _("Select all images without GPS information")) + +-- vim: shiftwidth=2 expandtab tabstop=2 cindent syntax=lua +-- kate: hl Lua; From 56925c1eed634fb24af5486b80448fde50e33381 Mon Sep 17 00:00:00 2001 From: supertobi Date: Sun, 8 Jan 2017 21:04:49 +0100 Subject: [PATCH 02/12] Delete gps_select.lua replaced by geoToolbox.lua --- contrib/gps_select.lua | 60 ------------------------------------------ 1 file changed, 60 deletions(-) delete mode 100644 contrib/gps_select.lua diff --git a/contrib/gps_select.lua b/contrib/gps_select.lua deleted file mode 100644 index b1c47ca..0000000 --- a/contrib/gps_select.lua +++ /dev/null @@ -1,60 +0,0 @@ ---[[ - This file is part of darktable, - Copyright 2014 by Tobias Jakobs. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -]] ---[[ -darktable select images with or without GPS informations - -USAGE -* require this script from your main lua file -* register a shortcuts -]] - -local dt = require "darktable" -local gettext = dt.gettext -dt.configuration.check_version(...,{2,0,1},{3,0,0}) - --- Tell gettext where to find the .mo file translating messages for a particular domain -gettext.bindtextdomain("gps_select",dt.configuration.config_dir.."/lua/") - -local function _(msgid) - return gettext.dgettext("gps_select", msgid) -end - -table = require "table" - -local function selectWithGPS() - local selection = {} - for _,image in ipairs(dt.database) do - if (image.longitude and image.latitude) then - table.insert(selection,image) - end - end - dt.gui.selection(selection) -end - -local function selectWithoutGPS() - local selection = {} - for _,image in ipairs(dt.database) do - if (not image.longitude and not image.latitude) then - table.insert(selection,image) - end - end - dt.gui.selection(selection) -end - -dt.register_event("shortcut", selectWithGPS, _("Select all images with GPS information")) -dt.register_event("shortcut", selectWithoutGPS, _("Select all images without GPS information")) From 4ea3a500e8e7062ff2fb2ac901f570a1b21f7696 Mon Sep 17 00:00:00 2001 From: supertobi Date: Sun, 8 Jan 2017 21:05:04 +0100 Subject: [PATCH 03/12] Delete geo_uri.lua replaced by geoToolbox.lua --- contrib/geo_uri.lua | 88 --------------------------------------------- 1 file changed, 88 deletions(-) delete mode 100644 contrib/geo_uri.lua diff --git a/contrib/geo_uri.lua b/contrib/geo_uri.lua deleted file mode 100644 index 04ad553..0000000 --- a/contrib/geo_uri.lua +++ /dev/null @@ -1,88 +0,0 @@ ---[[ - This file is part of darktable, - Copyright 2016 by Tobias Jakobs. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -]] ---[[ -darktable script to open a geo uri in gnome-maps - -ADDITIANAL SOFTWARE NEEDED FOR THIS SCRIPT -* gnome-maps >= 3.20 - -USAGE -* require this script from your main lua file -* register a shortcut -]] - -local dt = require "darktable" -local gettext = dt.gettext -dt.configuration.check_version(...,{3,0,0}) - --- Tell gettext where to find the .mo file translating messages for a particular domain -gettext.bindtextdomain("geo_uri",dt.configuration.config_dir.."/lua/") - -local function _(msgid) - return gettext.dgettext("geo_uri", msgid) -end - -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 -end - -local function openLocationInGnomeMaps() - if not checkIfBinExists("gnome-maps") then - dt.print_error(_("gnome-maps not found")) - return - end - - local sel_images = dt.gui.selection() - - local lat1 = 0; - local lon1 = 0; - local i = 0; - - -- 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 - lat1 = image.latitude; - lon1 = image.longitude; - break - end - end - - local startCommand - startCommand = "gnome-maps \"geo:" .. lat1 .. "," .. lon1 .."\"" - dt.print_error(startCommand) - - if coroutine.yield("RUN_COMMAND", startCommand) then - dt.print(_("Command failed ...")) - end - - end -end - --- Register -dt.register_event("shortcut", openLocationInGnomeMaps, _("Open Location in Gnome Maps")) From 0bd5b6ba5d7d0088ef4ecb45044d4dbd76e4938e Mon Sep 17 00:00:00 2001 From: supertobi Date: Sun, 8 Jan 2017 21:05:23 +0100 Subject: [PATCH 04/12] Delete calcDistance.lua replaced by geoToolbox.lua --- contrib/calcDistance.lua | 93 ---------------------------------------- 1 file changed, 93 deletions(-) delete mode 100644 contrib/calcDistance.lua diff --git a/contrib/calcDistance.lua b/contrib/calcDistance.lua deleted file mode 100644 index ea1c4b4..0000000 --- a/contrib/calcDistance.lua +++ /dev/null @@ -1,93 +0,0 @@ ---[[ - This file is part of darktable, - Copyright 2014-2016 by Tobias Jakobs. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -]] ---[[ -darktable calc distance script - -This script calcs the distance between two images using the GPS data in the metadata - -USAGE -* require this script from your main lua file -* register a shortcut -]] - -local dt = require "darktable" -local gettext = dt.gettext -dt.configuration.check_version(...,{3,0,0}) - --- Tell gettext where to find the .mo file translating messages for a particular domain -gettext.bindtextdomain("calcDistance",dt.configuration.config_dir.."/lua/") - -local function _(msgid) - return gettext.dgettext("calcDistance", msgid) -end - -local function calcDistance() - local sel_images = dt.gui.selection() - - local lat1 = 0; - local lon1 = 0; - local lat2 = 0; - local lon2 = 0; - local i = 0; - - local sel_images = dt.gui.selection() - - 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 - - lat2 = image.latitude; - lon2 = image.longitude; - - end - end - --- I used code from here: --- http://stackoverflow.com/questions/27928/how-do-i-calculate-distance-between-two-latitude-longitude-points - - local earthRadius = 6371; -- Radius of the earth in km - local dLat = math.rad(lat2-lat1); -- deg2rad below - local dLon = math.rad(lon2-lon1); - local a = - math.sin(dLat/2) * math.sin(dLat/2) + - math.cos(math.rad(lat1)) * math.cos(math.rad(lat2)) * - math.sin(dLon/2) * math.sin(dLon/2) - ; - local angle = 2 * math.atan2(math.sqrt(a), math.sqrt(1-a)); - local distance = earthRadius * angle; -- Distance in km - - -- Add the elevation to the calculation - local elevation = 0; - elevation = math.abs(ele1 - ele2) / 1000; --in km - distance = math.sqrt(math.pow(elevation,2) + math.pow(distance,2) ); - - dt.print(distance.." km") - - -end - --- Register -dt.register_event("shortcut",calcDistance,_("Calculate the distance from latitude and longitude in km")) From a30c4d6be553ece27dbebb0b554cb51b18f2aff0 Mon Sep 17 00:00:00 2001 From: supertobi Date: Mon, 9 Jan 2017 13:53:23 +0100 Subject: [PATCH 05/12] Update geoToolbox.lua changed camel case to "_" --- contrib/geoToolbox.lua | 134 ++++++++++++++++++++--------------------- 1 file changed, 67 insertions(+), 67 deletions(-) diff --git a/contrib/geoToolbox.lua b/contrib/geoToolbox.lua index 33b95ca..f0e33ff 100644 --- a/contrib/geoToolbox.lua +++ b/contrib/geoToolbox.lua @@ -42,24 +42,24 @@ end local labelDistance = dt.new_widget("label") labelDistance.label = "Distance:" -local labelCopyGPSlat = dt.new_widget("check_button") +local label_copy_gps_lat = dt.new_widget("check_button") { label = "latitude:", value = true } -local labelCopyGPSlon = dt.new_widget("check_button") +local label_copy_gps_lon = dt.new_widget("check_button") { label = "longitude:", value = true } -local labelCopyGPSele = dt.new_widget("check_button") +local label_copy_gps_ele = dt.new_widget("check_button") { label = "elevation:", value = true } -- -local function selectWithGPS() +local function select_with_gps() local selection = {} for _,image in ipairs(dt.database) do if (image.longitude and image.latitude) then @@ -69,7 +69,7 @@ local function selectWithGPS() dt.gui.selection(selection) end -local function selectWithoutGPS() +local function select_without_gps() local selection = {} for _,image in ipairs(dt.database) do if (not image.longitude and not image.latitude) then @@ -88,7 +88,7 @@ function isnan(x) return x ~= x end -- into a Unix timestamp (number of seconds since Jan 1, 1970, the standard -- used by most systems). So we use the string.match() method to fetch the -- various date and time parts into their own variables: xyear, xmonth,etc. -function makeTimeStamp(dateString) +function make_time_stamp(dateString) local convertedTimestamp --dt.print_error(dateString) if (dateString) then @@ -115,7 +115,7 @@ local first_longitude = '' local first_elevation = '' local first_image_date = 0 -local function getFirstCoordinate() +local function get_first_coordinate() local sel_images = dt.gui.selection() first_latitude = '' @@ -139,7 +139,7 @@ local function getFirstCoordinate() first_elevation = image.elevation end if (image.exif_datetime_taken) then - first_image_date = makeTimeStamp(image.exif_datetime_taken) + first_image_date = make_time_stamp(image.exif_datetime_taken) --dt.print_error(image.exif_datetime_taken) --dt.print_error(first_image_date) end @@ -154,7 +154,7 @@ local second_longitude = '' local second_elevation = '' local second_image_date = 0 -local function getSecondCoordinate() +local function get_second_coordinate() local sel_images = dt.gui.selection() second_latitude = '' @@ -178,14 +178,14 @@ local function getSecondCoordinate() second_elevation = image.elevation end if (image.exif_datetime_taken) then - second_image_date = makeTimeStamp(image.exif_datetime_taken) + second_image_date = make_time_stamp(image.exif_datetime_taken) end end return end end -local calcInBetweenSlider = dt.new_widget("slider") +local calc_in_between_slider = dt.new_widget("slider") { label = "Position between", soft_min = 0, -- The soft minimum value for the slider, the slider can't go beyond this point @@ -196,11 +196,11 @@ local calcInBetweenSlider = dt.new_widget("slider") } --ToDo: this needs more love -local function calcInBetween() +local function calc_in_between() local sel_images = dt.gui.selection() for _,image in ipairs(sel_images) do if image then - image_date = makeTimeStamp(image.exif_datetime_taken) + image_date = make_time_stamp(image.exif_datetime_taken) if (first_have_data and second_have_data) then local start_new = 0 local end_new = second_image_date - first_image_date @@ -212,7 +212,7 @@ local function calcInBetween() else percent_in_between = image_date_new/end_new end - calcInBetweenSlider.value = percent_in_between * 100 + calc_in_between_slider.value = percent_in_between * 100 dt.print_error(percent_in_between) local in_between_latitude = first_latitude + (second_latitude - first_latitude) * percent_in_between local in_between_longitude = first_longitude + (second_longitude - first_longitude) * percent_in_between @@ -233,59 +233,59 @@ dt.print_error(in_between_elevation) end end -local copyGPS_have_data = false -local copyGPS_latitude = '' -local copyGPS_longitude = '' -local copyGPS_elevation = '' +local copy_gps_have_data = false +local copy_gps_latitude = '' +local copy_gps_longitude = '' +local copy_gps_elevation = '' -local function copyGPS() +local function copy_gps() local sel_images = dt.gui.selection() - copyGPS_latitude = '' - copyGPS_longitude = '' - copyGPS_elevation = '' + copy_gps_latitude = '' + copy_gps_longitude = '' + copy_gps_elevation = '' for _,image in ipairs(sel_images) do if not image then - copyGPS_have_data = false + copy_gps_have_data = false else - copyGPS_have_data = true - if (image.latitude and labelCopyGPSlat.value) then - copyGPS_latitude = image.latitude + copy_gps_have_data = true + if (image.latitude and label_copy_gps_lat.value) then + copy_gps_latitude = image.latitude end - if (image.longitude and labelCopyGPSlon.value) then - copyGPS_longitude = image.longitude + if (image.longitude and label_copy_gps_lon.value) then + copy_gps_longitude = image.longitude end - if (image.elevation and labelCopyGPSele.value) then - copyGPS_elevation = image.elevation + if (image.elevation and label_copy_gps_ele.value) then + copy_gps_elevation = image.elevation end end - labelCopyGPSlat.label = "latitude: " .. copyGPS_latitude - labelCopyGPSlon.label = "longitude: " ..copyGPS_longitude - labelCopyGPSele.label = "elevation: " .. copyGPS_elevation + label_copy_gps_lat.label = "latitude: " .. copy_gps_latitude + label_copy_gps_lon.label = "longitude: " ..copy_gps_longitude + label_copy_gps_ele.label = "elevation: " .. copy_gps_elevation return end end -local function pastGPS(image) +local function past_gps(image) local sel_images = dt.gui.selection() for _,image in ipairs(sel_images) do - if (labelCopyGPSlat.value) then - image.latitude = copyGPS_latitude + if (label_copy_gps_lat.value) then + image.latitude = copy_gps_latitude end - if (labelCopyGPSlon.value) then - image.longitude = copyGPS_longitude + if (label_copy_gps_lon.value) then + image.longitude = copy_gps_longitude end - if (labelCopyGPSele.value) then - image.elevation = copyGPS_elevation + if (label_copy_gps_ele.value) then + image.elevation = copy_gps_elevation end end end -local function openLocationInGnomeMaps() +local function open_location_in_gnome_maps() if not df.check_if_bin_exists("gnome-maps") then dt.print_error(_("gnome-maps not found")) @@ -323,7 +323,7 @@ end -- I used code from here: -- http://stackoverflow.com/questions/27928/how-do-i-calculate-distance-between-two-latitude-longitude-points -local function getDistance(lat1, lon1, ele1, lat2, lon2, ele2) +local function get_distance(lat1, lon1, ele1, lat2, lon2, ele2) local earthRadius = 6371; -- Radius of the earth in km local dLat = math.rad(lat2-lat1); -- deg2rad below @@ -346,7 +346,7 @@ local function getDistance(lat1, lon1, ele1, lat2, lon2, ele2) return distance end -local function calcDistance() +local function calc_distance() local sel_images = dt.gui.selection() @@ -388,7 +388,7 @@ local function calcDistance() end end - local distance = getDistance(lat1, lon1, ele1, lat2, lon2, ele2) + local distance = get_distance(lat1, lon1, ele1, lat2, lon2, ele2) if (distance < 1) then distance = distance * 1000 @@ -400,12 +400,12 @@ local function calcDistance() return string.format("Distance: %.2f %s", distance, distanceUnit) end -local function printCalcDistance() - dt.print(calcDistance()) +local function print_calc_distance() + dt.print(calc_distance()) end -local function toolboxCalcDistance() - labelDistance.label = calcDistance() +local function toolbox_calc_distance() + labelDistance.label = calc_distance() end local altitude_file_chooser_button = dt.new_widget("file_chooser_button") @@ -423,7 +423,7 @@ local altitude_filename = dt.new_widget("entry") reset_callback = function(self) self.text = "text" end } -local function altitudeProfile() +local function altitude_profile() dt.print("Start export") local sel_images = dt.gui.selection() @@ -467,7 +467,7 @@ local function altitudeProfile() if (i == 1) then distanceFromStart = 0 else - local distance = getDistance(lat1, lon1, ele1, lat2, lon2, ele2) + local distance = get_distance(lat1, lon1, ele1, lat2, lon2, ele2) distanceFromStart = distanceFromStart + distance; end @@ -508,29 +508,29 @@ dt.register_lib( { label = "select geo images", tooltip = "Select all images with GPS information", - clicked_callback = selectWithGPS + clicked_callback = select_with_gps }, dt.new_widget("button") { label = "select not geo images", tooltip = "Select all images without GPS information", - clicked_callback = selectWithoutGPS + clicked_callback = select_without_gps }, separator,-------------------------------------------------------- dt.new_widget("button") { label = "copy GPS data", tooltip = "Copy the GPS data", - clicked_callback = copyGPS + clicked_callback = copy_gps }, - labelCopyGPSlat, - labelCopyGPSlon, - labelCopyGPSele, + label_copy_gps_lat, + label_copy_gps_lon, + label_copy_gps_ele, dt.new_widget("button") { label = "past GPS data", tooltip = "Past the GPS data", - clicked_callback = pastGPS + clicked_callback = past_gps }, separator2,-------------------------------------------------------- --ToDo: This need a better UI @@ -539,28 +539,28 @@ dt.register_lib( { label = "get 1st coordinate", tooltip = "Select first image and click this button", - clicked_callback = getFirstCoordinate + clicked_callback = get_first_coordinate }, dt.new_widget("button") { label = "get 2nd coordinate", tooltip = "Select second image and click this button", - clicked_callback = getSecondCoordinate + clicked_callback = get_second_coordinate }, dt.new_widget("button") { label = "calc in between", tooltip = "Select third image and click this button", - clicked_callback = calcInBetween + clicked_callback = calc_in_between }, - calcInBetweenSlider, + calc_in_between_slider, separator3,-------------------------------------------------------- ]] dt.new_widget("button") { label = "Open in Gnome Maps", tooltip = "Open Location in Gnome Maps", - clicked_callback = openLocationInGnomeMaps + clicked_callback = open_location_in_gnome_maps }, separator4,-------------------------------------------------------- dt.new_widget("label"){label = "altitude CSV export"}, @@ -570,7 +570,7 @@ dt.register_lib( { label = "export altitude CSV file", tooltip = "create an altitude profile using the GPS data in the metadata", - clicked_callback = altitudeProfile + clicked_callback = altitude_profile }, labelDistance }, @@ -580,11 +580,11 @@ dt.register_lib( -- Register -dt.register_event("shortcut",printCalcDistance,_("Calculate the distance from latitude and longitude in km")) -dt.register_event("mouse-over-image-changed",toolboxCalcDistance) +dt.register_event("shortcut",print_calc_distance,_("Calculate the distance from latitude and longitude in km")) +dt.register_event("mouse-over-image-changed",toolbox_calc_distance) -dt.register_event("shortcut", selectWithGPS, _("Select all images with GPS information")) -dt.register_event("shortcut", selectWithoutGPS, _("Select all images without GPS information")) +dt.register_event("shortcut", select_with_gps, _("Select all images with GPS information")) +dt.register_event("shortcut", select_without_gps, _("Select all images without GPS information")) -- vim: shiftwidth=2 expandtab tabstop=2 cindent syntax=lua -- kate: hl Lua; From abc8061cd778ce21fb0fd48d6d259d2efbbd2b99 Mon Sep 17 00:00:00 2001 From: supertobi Date: Mon, 9 Jan 2017 14:00:14 +0100 Subject: [PATCH 06/12] Update geoToolbox.lua gettext translations --- contrib/geoToolbox.lua | 56 +++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/contrib/geoToolbox.lua b/contrib/geoToolbox.lua index f0e33ff..ee7713a 100644 --- a/contrib/geoToolbox.lua +++ b/contrib/geoToolbox.lua @@ -40,21 +40,21 @@ end -- local labelDistance = dt.new_widget("label") -labelDistance.label = "Distance:" +labelDistance.label = _("Distance:") local label_copy_gps_lat = dt.new_widget("check_button") { - label = "latitude:", + label = _("latitude:"), value = true } local label_copy_gps_lon = dt.new_widget("check_button") { - label = "longitude:", + label = _("longitude:"), value = true } local label_copy_gps_ele = dt.new_widget("check_button") { - label = "elevation:", + label = _("elevation:"), value = true } -- @@ -261,9 +261,9 @@ local function copy_gps() end end - label_copy_gps_lat.label = "latitude: " .. copy_gps_latitude - label_copy_gps_lon.label = "longitude: " ..copy_gps_longitude - label_copy_gps_ele.label = "elevation: " .. copy_gps_elevation + label_copy_gps_lat.label = _("latitude: ") .. copy_gps_latitude + label_copy_gps_lon.label = _("longitude: ") ..copy_gps_longitude + label_copy_gps_ele.label = _("elevation: ") .. copy_gps_elevation return end @@ -392,9 +392,9 @@ local function calc_distance() if (distance < 1) then distance = distance * 1000 - distanceUnit = "m" + distanceUnit = _("m") else - distanceUnit = "km" + distanceUnit = _("km") end return string.format("Distance: %.2f %s", distance, distanceUnit) @@ -410,7 +410,7 @@ end local altitude_file_chooser_button = dt.new_widget("file_chooser_button") { - title = "export altitude CSV", -- The title of the window when choosing a file + title = _("export altitude CSV"), -- The title of the window when choosing a file value = "", -- The currently selected file is_directory = true -- True if the file chooser button only allows directories to be selecte } @@ -419,12 +419,12 @@ local altitude_filename = dt.new_widget("entry") text = "altitude.csv", placeholder = "altitude.csv", editable = true, - tooltip = "Name of the exported file", + tooltip = _("Name of the exported file"), reset_callback = function(self) self.text = "text" end } local function altitude_profile() - dt.print("Start export") + dt.print(_("Start export")) local sel_images = dt.gui.selection() local lat1 = 0; @@ -485,7 +485,7 @@ local function altitude_profile() file = io.open(exportDirectory.."/"..exportFilename, "w") file:write(csv_file) file:close() - dt.print("File created in "..exportDirectory) + dt.print(_("File created in ")..exportDirectory) end @@ -506,21 +506,21 @@ dt.register_lib( orientation = "vertical", dt.new_widget("button") { - label = "select geo images", - tooltip = "Select all images with GPS information", + label = _("select geo images"), + tooltip = _("Select all images with GPS information"), clicked_callback = select_with_gps }, dt.new_widget("button") { - label = "select not geo images", - tooltip = "Select all images without GPS information", + label = _("select not geo images"), + tooltip = _("Select all images without GPS information"), clicked_callback = select_without_gps }, separator,-------------------------------------------------------- dt.new_widget("button") { - label = "copy GPS data", - tooltip = "Copy the GPS data", + label = _("copy GPS data"), + tooltip = _("Copy the GPS data"), clicked_callback = copy_gps }, label_copy_gps_lat, @@ -528,8 +528,8 @@ dt.register_lib( label_copy_gps_ele, dt.new_widget("button") { - label = "past GPS data", - tooltip = "Past the GPS data", + label = _("past GPS data"), + tooltip = _("Past the GPS data"), clicked_callback = past_gps }, separator2,-------------------------------------------------------- @@ -558,18 +558,18 @@ dt.register_lib( ]] dt.new_widget("button") { - label = "Open in Gnome Maps", - tooltip = "Open Location in Gnome Maps", + label = _("Open in Gnome Maps"), + tooltip = _("Open Location in Gnome Maps"), clicked_callback = open_location_in_gnome_maps }, separator4,-------------------------------------------------------- - dt.new_widget("label"){label = "altitude CSV export"}, + dt.new_widget("label"){label = _("altitude CSV export")}, altitude_file_chooser_button, altitude_filename, dt.new_widget("button") { - label = "export altitude CSV file", - tooltip = "create an altitude profile using the GPS data in the metadata", + label = _("export altitude CSV file"), + tooltip = _("create an altitude profile using the GPS data in the metadata"), clicked_callback = altitude_profile }, labelDistance @@ -580,8 +580,8 @@ dt.register_lib( -- Register -dt.register_event("shortcut",print_calc_distance,_("Calculate the distance from latitude and longitude in km")) -dt.register_event("mouse-over-image-changed",toolbox_calc_distance) +dt.register_event("shortcut", print_calc_distance, _("Calculate the distance from latitude and longitude in km")) +dt.register_event("mouse-over-image-changed", toolbox_calc_distance) dt.register_event("shortcut", select_with_gps, _("Select all images with GPS information")) dt.register_event("shortcut", select_without_gps, _("Select all images without GPS information")) From 2816c2bcf5dc4cea20fdabbb31f372e2488e6874 Mon Sep 17 00:00:00 2001 From: supertobi Date: Thu, 12 Jan 2017 12:30:45 +0100 Subject: [PATCH 07/12] changed label to lower case --- contrib/geoToolbox.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/contrib/geoToolbox.lua b/contrib/geoToolbox.lua index ee7713a..3d7e554 100644 --- a/contrib/geoToolbox.lua +++ b/contrib/geoToolbox.lua @@ -558,8 +558,8 @@ dt.register_lib( ]] dt.new_widget("button") { - label = _("Open in Gnome Maps"), - tooltip = _("Open Location in Gnome Maps"), + label = _("open in Gnome Maps"), + tooltip = _("Open location in Gnome Maps"), clicked_callback = open_location_in_gnome_maps }, separator4,-------------------------------------------------------- @@ -569,7 +569,7 @@ dt.register_lib( dt.new_widget("button") { label = _("export altitude CSV file"), - tooltip = _("create an altitude profile using the GPS data in the metadata"), + tooltip = _("Create an altitude profile using the GPS data in the metadata"), clicked_callback = altitude_profile }, labelDistance From cc6006e2263dd329d495e7440b845ad52a6035a2 Mon Sep 17 00:00:00 2001 From: supertobi Date: Thu, 12 Jan 2017 12:32:42 +0100 Subject: [PATCH 08/12] removed "the" from "Past the GPS data" --- contrib/geoToolbox.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/geoToolbox.lua b/contrib/geoToolbox.lua index 3d7e554..42907e4 100644 --- a/contrib/geoToolbox.lua +++ b/contrib/geoToolbox.lua @@ -520,7 +520,7 @@ dt.register_lib( dt.new_widget("button") { label = _("copy GPS data"), - tooltip = _("Copy the GPS data"), + tooltip = _("Copy GPS data"), clicked_callback = copy_gps }, label_copy_gps_lat, @@ -529,7 +529,7 @@ dt.register_lib( dt.new_widget("button") { label = _("past GPS data"), - tooltip = _("Past the GPS data"), + tooltip = _("Past GPS data"), clicked_callback = past_gps }, separator2,-------------------------------------------------------- From f7c2abdcd796b67cc1584133ff5ec1f4166a5e58 Mon Sep 17 00:00:00 2001 From: supertobi Date: Thu, 12 Jan 2017 12:56:41 +0100 Subject: [PATCH 09/12] dt.gui.action_images -> dt.gui.selection() --- contrib/geoToolbox.lua | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/contrib/geoToolbox.lua b/contrib/geoToolbox.lua index 42907e4..5881e9d 100644 --- a/contrib/geoToolbox.lua +++ b/contrib/geoToolbox.lua @@ -116,7 +116,7 @@ local first_elevation = '' local first_image_date = 0 local function get_first_coordinate() - local sel_images = dt.gui.selection() + local sel_images = dt.gui.action_images first_latitude = '' first_longitude = '' @@ -155,7 +155,7 @@ local second_elevation = '' local second_image_date = 0 local function get_second_coordinate() - local sel_images = dt.gui.selection() + local sel_images = dt.gui.action_images second_latitude = '' second_longitude = '' @@ -197,7 +197,7 @@ local calc_in_between_slider = dt.new_widget("slider") --ToDo: this needs more love local function calc_in_between() - local sel_images = dt.gui.selection() + local sel_images = dt.gui.action_images for _,image in ipairs(sel_images) do if image then image_date = make_time_stamp(image.exif_datetime_taken) @@ -239,7 +239,7 @@ local copy_gps_longitude = '' local copy_gps_elevation = '' local function copy_gps() - local sel_images = dt.gui.selection() + local sel_images = dt.gui.action_images copy_gps_latitude = '' copy_gps_longitude = '' @@ -270,7 +270,7 @@ local function copy_gps() end local function past_gps(image) - local sel_images = dt.gui.selection() + local sel_images = dt.gui.action_images for _,image in ipairs(sel_images) do if (label_copy_gps_lat.value) then @@ -292,7 +292,7 @@ local function open_location_in_gnome_maps() return end - local sel_images = dt.gui.selection() + local sel_images = dt.gui.action_images local lat1 = 0; local lon1 = 0; @@ -348,9 +348,7 @@ end local function calc_distance() - local sel_images = dt.gui.selection() - - local lat1 = 0; + local lat1 = 0; local lon1 = 0; local lat2 = 0; local lon2 = 0; @@ -397,7 +395,7 @@ local function calc_distance() distanceUnit = _("km") end - return string.format("Distance: %.2f %s", distance, distanceUnit) + return string.format(_("Distance: %.2f %s"), distance, distanceUnit) end local function print_calc_distance() @@ -425,7 +423,7 @@ local altitude_filename = dt.new_widget("entry") local function altitude_profile() dt.print(_("Start export")) - local sel_images = dt.gui.selection() + local sel_images = dt.gui.action_images local lat1 = 0; local lon1 = 0; @@ -442,7 +440,7 @@ local function altitude_profile() local elevation = 0; local elevationAdd = 0; - local sel_images = dt.gui.selection() + local sel_images = dt.gui.action_images for _,image in ipairs(sel_images) do if ((not isnan(image.longitude) and not isnan(image.latitude) and not isnan(image.elevation) and image.elevation) and (image.longitude ~= 0 and image.latitude ~= 90) -- Sometimes the north-pole but most likely just wrong data From 3fb4ef34f4e1c8a190a6b585d848dc0c69b9d75c Mon Sep 17 00:00:00 2001 From: supertobi Date: Thu, 12 Jan 2017 12:58:17 +0100 Subject: [PATCH 10/12] past -> paste --- contrib/geoToolbox.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/contrib/geoToolbox.lua b/contrib/geoToolbox.lua index 5881e9d..3ac8a35 100644 --- a/contrib/geoToolbox.lua +++ b/contrib/geoToolbox.lua @@ -269,7 +269,7 @@ local function copy_gps() end end -local function past_gps(image) +local function paste_gps(image) local sel_images = dt.gui.action_images for _,image in ipairs(sel_images) do @@ -526,9 +526,9 @@ dt.register_lib( label_copy_gps_ele, dt.new_widget("button") { - label = _("past GPS data"), - tooltip = _("Past GPS data"), - clicked_callback = past_gps + label = _("paste GPS data"), + tooltip = _("Paste GPS data"), + clicked_callback = paste_gps }, separator2,-------------------------------------------------------- --ToDo: This need a better UI From 3bd76b4fb5e119435095796f105c8fa32d651b45 Mon Sep 17 00:00:00 2001 From: supertobi Date: Thu, 12 Jan 2017 13:16:59 +0100 Subject: [PATCH 11/12] added a progress bar added a progress bar to elect_without_gps() and select_with_gps() --- contrib/geoToolbox.lua | 43 ++++++++++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/contrib/geoToolbox.lua b/contrib/geoToolbox.lua index 3ac8a35..c01ae87 100644 --- a/contrib/geoToolbox.lua +++ b/contrib/geoToolbox.lua @@ -60,23 +60,46 @@ local label_copy_gps_ele = dt.new_widget("check_button") -- local function select_with_gps() - local selection = {} - for _,image in ipairs(dt.database) do + local selection = {} + job = dt.gui.create_job(_("GPS selection"), true, stop_selection) + + for key,image in ipairs(dt.database) do + if job.valid then + job.percent = (key-1)/#dt.database + if (image.longitude and image.latitude) then - table.insert(selection,image) + table.insert(selection,image) end - end - dt.gui.selection(selection) + else + break + end + end + + dt.gui.selection(selection) + job.valid = false end local function select_without_gps() - local selection = {} - for _,image in ipairs(dt.database) do + local selection = {} + job = dt.gui.create_job(_("GPS selection"), true, stop_selection) + + for key,image in ipairs(dt.database) do + if job.valid then + job.percent = (key-1)/#dt.database + if (not image.longitude and not image.latitude) then - table.insert(selection,image) + table.insert(selection,image) end - end - dt.gui.selection(selection) + else + break + end + end + dt.gui.selection(selection) + job.valid = false +end + +local function stop_selection(job) + job.valid = false end -- This is used for older images in the DB From 99e1141446bab89ca211d1aa787a5e15be8b8412 Mon Sep 17 00:00:00 2001 From: supertobi Date: Thu, 12 Jan 2017 13:27:29 +0100 Subject: [PATCH 12/12] dt.database -> dt.collection select only images in the collection, not in the database --- contrib/geoToolbox.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/contrib/geoToolbox.lua b/contrib/geoToolbox.lua index c01ae87..7b69131 100644 --- a/contrib/geoToolbox.lua +++ b/contrib/geoToolbox.lua @@ -63,9 +63,9 @@ local function select_with_gps() local selection = {} job = dt.gui.create_job(_("GPS selection"), true, stop_selection) - for key,image in ipairs(dt.database) do + for key,image in ipairs(dt.collection) do if job.valid then - job.percent = (key-1)/#dt.database + job.percent = (key-1)/#dt.collection if (image.longitude and image.latitude) then table.insert(selection,image) @@ -83,9 +83,9 @@ local function select_without_gps() local selection = {} job = dt.gui.create_job(_("GPS selection"), true, stop_selection) - for key,image in ipairs(dt.database) do + for key,image in ipairs(dt.collection) do if job.valid then - job.percent = (key-1)/#dt.database + job.percent = (key-1)/#dt.collection if (not image.longitude and not image.latitude) then table.insert(selection,image)