diff --git a/ImportPhotos.py b/ImportPhotos.py index aadbaff..b3c3184 100644 --- a/ImportPhotos.py +++ b/ImportPhotos.py @@ -292,6 +292,7 @@ def run(self): self.dlg.out.setText('') self.dlg.imp.setText('') self.dlg.load_style_path.setText('') + self.dlg.canvas_extent.setChecked(False) self.dlg.show() def close(self): @@ -442,6 +443,7 @@ def import_photos(self, directoryPhotos, outputPath, load_style, showMessageHide self.canvas.setMapTool(self.toolMouseClick) self.truePhotosCount = 0 + self.out_of_extent_photos = 0 self.Qpr_inst = QgsProject.instance() if platform.system()=='Darwin': @@ -548,18 +550,19 @@ def completed(self, exception, result=None): self.dlg.input_load_style.setEnabled(True) self.clickPhotos.setChecked(True) - noLocationPhotosCounter = self.initphotos - self.truePhotosCount + noLocationPhotosCounter = self.initphotos - self.truePhotosCount - self.out_of_extent_photos if (self.truePhotosCount == noLocationPhotosCounter == 0 or self.truePhotosCount == 0 ) and self.showMessageHide: title = 'Import Photos' msg = 'Import Completed.\n\nDetails:\n No new photos were added.' self.showMessage(title, msg, 'Information') self.taskPhotos.destroyed() return - elif ((self.truePhotosCount == self.initphotos) or ((noLocationPhotosCounter + self.truePhotosCount) == self.initphotos) )and self.showMessageHide: + elif ((self.truePhotosCount == self.initphotos) or ((noLocationPhotosCounter + self.truePhotosCount + self.out_of_extent_photos) == self.initphotos) )and self.showMessageHide: title = 'Import Photos' msg = 'Import Completed.\n\nDetails:\n ' + str( int(self.truePhotosCount)) + ' photo(s) added without error.\n ' + str( - int(noLocationPhotosCounter)) + ' photo(s) skipped (because of missing location).' + int(noLocationPhotosCounter)) + ' photo(s) skipped (because of missing location).\n ' + str( + int(self.out_of_extent_photos)) + ' photo(s) skipped (because not in canvas extent).' self.showMessage(title, msg, 'Information') g = self.Qpr_inst.layerTreeRoot().insertGroup(0, self.lphoto) @@ -590,10 +593,13 @@ def import_photos_task(self, task, wait_time): continue lat, lon = self.get_exif_location(tags, "lonlat") - if 'GPS GPSAltitude' in tags: - altitude = float(tags["GPS GPSAltitude"].values[0].num) / float( - tags["GPS GPSAltitude"].values[0].den) - else: + try: + if 'GPS GPSAltitude' in tags: + altitude = float(tags["GPS GPSAltitude"].values[0].num) / float( + tags["GPS GPSAltitude"].values[0].den) + else: + altitude = '' + except: altitude = '' uuid_ = str(uuid.uuid4()) @@ -613,35 +619,53 @@ def import_photos_task(self, task, wait_time): time_ = '' timestamp = '' - if 'GPS GPSImgDirection' in tags: - azimuth = float(tags["GPS GPSImgDirection"].values[0].num) / float( - tags["GPS GPSImgDirection"].values[0].den) - else: + try: + if 'GPS GPSImgDirection' in tags: + azimuth = float(tags["GPS GPSImgDirection"].values[0].num) / float( + tags["GPS GPSImgDirection"].values[0].den) + else: + azimuth = '' + except: azimuth = '' - if 'GPS GPSImgDirectionRef' in tags: - north = str(tags["GPS GPSImgDirectionRef"].values) - else: + try: + if 'GPS GPSImgDirectionRef' in tags: + north = str(tags["GPS GPSImgDirectionRef"].values) + else: + north = '' + except: north = '' - if 'Image Make' in tags: - maker = tags['Image Make'] - else: + try: + if 'Image Make' in tags: + maker = tags['Image Make'] + else: + maker = '' + except: maker = '' - if 'Image Model' in tags: - model = tags['Image Model'] - else: + try: + if 'Image Model' in tags: + model = tags['Image Model'] + else: + model = '' + except: model = '' - if 'Image ImageDescription' in tags: - title = tags['Image ImageDescription'] - else: + try: + if 'Image ImageDescription' in tags: + title = tags['Image ImageDescription'] + else: + title = '' + except: title = '' - if 'EXIF UserComment' in tags: - user_comm = tags['EXIF UserComment'].printable - else: + try: + if 'EXIF UserComment' in tags: + user_comm = tags['EXIF UserComment'].printable + else: + user_comm = '' + except: user_comm = '' if CHECK_MODULE == 'PIL' and not self.exifread_module: @@ -688,18 +712,25 @@ def import_photos_task(self, task, wait_time): time_ = dt2 timestamp = dt1.replace(':', '-') + 'T' + time_ - if 6 in a['GPSInfo']: - if len(a['GPSInfo'][6]) > 1: - mAltitude = float(a['GPSInfo'][6][0]) - mAltitudeDec = float(a['GPSInfo'][6][1]) - altitude = mAltitude / mAltitudeDec - else: + try: + if 6 in a['GPSInfo']: + if len(a['GPSInfo'][6]) > 1: + mAltitude = float(a['GPSInfo'][6][0]) + mAltitudeDec = float(a['GPSInfo'][6][1]) + altitude = mAltitude / mAltitudeDec + else: + altitude = '' + except: altitude = '' - if 16 and 17 in a['GPSInfo']: - north = str(a['GPSInfo'][16]) - azimuth = float(a['GPSInfo'][17][0]) / float(a['GPSInfo'][17][1]) - else: + try: + if 16 and 17 in a['GPSInfo']: + north = str(a['GPSInfo'][16]) + azimuth = float(a['GPSInfo'][17][0]) / float(a['GPSInfo'][17][1]) + else: + north = '' + azimuth = '' + except: north = '' azimuth = '' @@ -707,8 +738,16 @@ def import_photos_task(self, task, wait_time): model = '' user_comm = '' title = '' + + if self.dlg.canvas_extent.isChecked(): + if not (self.canvas.extent().xMaximum() > lon > self.canvas.extent().xMinimum() \ + and self.canvas.extent().yMaximum() > lat > self.canvas.extent().yMinimum()): + self.out_of_extent_photos = self.out_of_extent_photos + 1 + continue + self.lon.append(lon) self.lat.append(lat) + self.truePhotosCount = self.truePhotosCount + 1 geo_info = {"type": "Feature", diff --git a/code/PhotosViewer.py b/code/PhotosViewer.py index 84b265b..3e6d75e 100644 --- a/code/PhotosViewer.py +++ b/code/PhotosViewer.py @@ -59,7 +59,7 @@ def __init__(self, selfwindow): self.leftClick.setIcon(QIcon(':/plugins/ImportPhotos/icons/arrowLeft.png')) self.leftClick.clicked.connect(self.selfwindow.leftClickButton) self.leftClick.setToolTip('Show previous photo') - self.leftClick.setStyleSheet("QPushButton{border: 0px;}") + self.leftClick.setStyleSheet("QPushButton{border: 0px; background: transparent;}") self.leftClick.setIconSize(QSize(size, size)) self.leftClick.setFocusPolicy(Qt.NoFocus) @@ -67,7 +67,7 @@ def __init__(self, selfwindow): self.rightClick.setIcon(QIcon(':/plugins/ImportPhotos/icons/arrowRight.png')) self.rightClick.clicked.connect(self.selfwindow.rightClickButton) self.rightClick.setToolTip('Show next photo') - self.rightClick.setStyleSheet("QPushButton{border: 0px;}") + self.rightClick.setStyleSheet("QPushButton{border: 0px; background: transparent;}") self.rightClick.setIconSize(QSize(size, size)) self.rightClick.setFocusPolicy(Qt.NoFocus) diff --git a/icons/photos.qml b/icons/photos.qml index 61597b1..1155cc0 100644 --- a/icons/photos.qml +++ b/icons/photos.qml @@ -1,185 +1,185 @@ - + 1 1 1 - + - + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - - @@ -197,22 +197,22 @@ 0 0 1 - - - - + + + + - + - + @@ -280,14 +280,28 @@ - + - + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - + + + + + + + + + + + + + + + + - + - @@ -409,57 +457,69 @@ def my_form_open(dialog, layer, feature): 0 generatedlayout - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - ID + Name 0 diff --git a/metadata.txt b/metadata.txt index f2ac2d7..bedaa94 100644 --- a/metadata.txt +++ b/metadata.txt @@ -11,7 +11,7 @@ name=ImportPhotos qgisMinimumVersion=2.99 qgisMaximumVersion=3.99 description=Import Photos -version=2.2.1 +version=2.2.2 author=Marios S. Kyriakou, George A. Christou, Panayiotis S. Kolios, KIOS Research and Innovation Center of Excellence (KIOS CoE) email=mariosmsk@gmail.com, george.a.christou@gmail.com, panayiotis.kolios@gmail.com @@ -23,7 +23,11 @@ repository=https://github.com/KIOS-Research/ImportPhotos/ # Recommended items: # Uncomment the following line and add your changelog: -changelog=2019-07-16 ImportPhotos 2.2.1: +changelog=2019-07-18 ImportPhotos 2.2.2: + Fix transparent left,right buttons for all themes + Fix bug with null parameters + Add option to import photos in canvas extent + 2019-07-16 ImportPhotos 2.2.1: Fix tab Filters works without Opencv 2019-07-15 ImportPhotos 2.2: Add tabs options File, Filters, Opencv, Bands diff --git a/ui/impphotos.ui b/ui/impphotos.ui index 9c81509..382d13b 100644 --- a/ui/impphotos.ui +++ b/ui/impphotos.ui @@ -9,8 +9,8 @@ 0 0 - 423 - 227 + 449 + 258 @@ -31,8 +31,8 @@ - - + + Qt::Horizontal @@ -47,8 +47,8 @@ - - + + Qt::Horizontal @@ -63,8 +63,8 @@ - - + + Qt::Horizontal @@ -79,8 +79,8 @@ - - + + Qt::Horizontal @@ -95,7 +95,37 @@ - + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + OK + + + + + + Qt::Horizontal @@ -108,6 +138,29 @@ + + + + Qt::Horizontal + + + QSizePolicy::Preferred + + + + 40 + 20 + + + + + + + + Load style (optional) + + + @@ -115,8 +168,8 @@ - - + + Qt::Horizontal @@ -131,15 +184,40 @@ - - - - Load style (optional) + + + + Qt::Horizontal - + + QSizePolicy::Preferred + + + + 40 + 20 + + + - - + + + + Qt::Horizontal + + + QSizePolicy::Preferred + + + + 40 + 20 + + + + + + Qt::Horizontal @@ -161,36 +239,6 @@ - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - OK - - - - - @@ -263,7 +311,17 @@ - + + + + Qt::LeftToRight + + + Only import photos in canvas extent + + + +