Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions apipl.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# # -*- coding: utf-8 -*-
"""
/***************************************************************************
Name : Qt API for Catalog Planet Labs
Name : Qt API for Catalog Planet Labs
Description : API for Planet Labs
Date : May, 2015, March, 2019 migrate to Qt5
copyright : (C) 2015 by Luiz Motta
Expand All @@ -20,12 +20,12 @@
***************************************************************************/
"""

import json, datetime
import json, datetime

from qgis.PyQt.QtCore import (
QObject,
pyqtSignal, pyqtSlot,
QUrl
QUrl
)
from qgis.PyQt.QtNetwork import QNetworkReply

Expand All @@ -40,8 +40,8 @@ class API_PlanetLabs(QObject):
statusNoCredential = '*None*'
urlRoot = "https://api.planet.com"
urlQuickSearch = "https://api.planet.com/data/v1/quick-search"
urlYXZImage = "https://tiles.planet.com/data/v1/{item_type}/{item_id}/%7Bz%7D/%7Bx%7D/%7By%7D.png"
urlYXZMosaicMonthly = "https://tiles.planet.com/basemaps/v1/planet-tiles/global_monthly_{year}_{month:02d}_mosaic/gmap/%7Bz%7D/%7Bx%7D/%7By%7D.png"
urlYXZImage = "https://tiles3.planet.com/data/v1/{item_type}/{item_id}/%7Bz%7D/%7Bx%7D/%7By%7D.png"
urlYXZMosaicMonthly = "https://tiles3.planet.com/basemaps/v1/planet-tiles/global_monthly_{year}_{month:02d}_mosaic/gmap/%7Bz%7D/%7Bx%7D/%7By%7D.png"
urlMetadata = "https://api.planet.com/data/v1/item-types/{item_type}/items/{item_id}"
addFeature = pyqtSignal(str)
def __init__(self):
Expand Down Expand Up @@ -249,4 +249,3 @@ def addFinishedResponse(response):
def kill(self):
self.access.isKill = True
self.access.abortReply.emit()

11 changes: 6 additions & 5 deletions metadata.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ repository:https://github.com/catalogpl_plugin/

icon:planet.svg

experimental:True
experimental:False
deprecated:False

changelog: 2.0(2019-03-19)
changelog: 2.1(2019-07-05)
Add support for different asset types (3 and 4 band, collects)
- 2.0
Migrated to QGIS 3.4
- 1.7.1
Fixed error ltgRoot in downloadImages(catalogpl.py).
Expand All @@ -37,15 +39,15 @@ changelog: 2.0(2019-03-19)
Add groups of images with same date, add menu Open Form in images, clear cache of TMS, and add action 'Add selection' to pl_scenes.
- 1.5
Reverse images order in group catalog, add directories,
tms, tif, thumbnail, inside download directory
tms, tif, thumbnail, inside download directory
- 1.4
Fix cache_path when save TMS
- 1.3
Change TMS of Tile Server XYZ to GDAL_WMS
- 1.2
Fixed when the first use of plugin(not set the directory), not show the setting
- 1.1
Changed checkbox to radiobutton for images, only one type of image for searching.
Changed checkbox to radiobutton for images, only one type of image for searching.
- 1.0
Updated to API Planet V1
- 0.8
Expand All @@ -65,4 +67,3 @@ changelog: 2.0(2019-03-19)
Add metadata in table and refactoring codes.
- 0.1
Start of plugin

31 changes: 16 additions & 15 deletions planetlabs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# # -*- coding: utf-8 -*-
"""
/***************************************************************************
Name : Planet Labs
Name : Planet Labs
Description : Class for work with Planet Labs
Date : March, 2019 migrate to Qt5
copyright : (C) 2019 by Luiz Motta
Expand Down Expand Up @@ -161,8 +161,8 @@ def getPageKey(wgtMain):
wgtPage.setObjectName('objPageKey')
lytPage = QHBoxLayout()

# SEE object names in: self.pageKey
# SEE object names in: self.pageKey

# Layout Password
lyt = QHBoxLayout()
w = QLabel("Key:")
Expand Down Expand Up @@ -230,7 +230,6 @@ def populateUi(paramsSetting):
# Page Images
assets = 'objPlanet' if paramsSetting['assets'] is None else f"obj{paramsSetting['assets']}"
w = self.findChild( QRadioButton, assets )
w.setChecked( True )
if not paramsSetting['path'] is None:
name = paramsSetting['path']
w = self.findChild( QPushButton, 'objPath')
Expand Down Expand Up @@ -306,9 +305,11 @@ def connect():
self.pl = PlanetLabs( iface, self )
self.titleLog, self.currentProcess, self.countFeatures = 'Planet', None, None
self.nameAssets = {
'Planet': 'PSScene4Band',
'Rapideye': 'REOrthoTile',
'Skysat': 'SkySatScene',
'PlanetScope 4-band': 'PSScene4Band',
'PlanetScope 3-band': 'PSScene3Band',
'RapidEye': 'REOrthoTile',
'SkySat Scene': 'SkySatScene',
'SkySat Collect': 'SkySatCollect'
}
self.titleSelectDirectory = "Select download directory"
self.btnSearchImage, self.btnMosaic, self.msgBar = None, None, None
Expand Down Expand Up @@ -356,7 +357,7 @@ def getOptionRadioButton(names):
'date1': self.findChild( QDateEdit, 'objFromMosaic').date(),
'date2': self.findChild( QDateEdit, 'objToMosaic').date()
}
#
#
key = {
'optionKey': getOptionRadioButton( self.nameOptionsKey ),
'password': self.findChild( QLineEdit, 'objPasswordEdit').text(),
Expand Down Expand Up @@ -572,7 +573,7 @@ def receivedFeature(self, item_id):
def showProgressBar(self, hasFile):
self.wgtProgressBar.setHasFile( hasFile )
self.wgtProgressBar.show()

@pyqtSlot()
def hideProgressBar(self):
self.wgtProgressBar.hide()
Expand Down Expand Up @@ -619,7 +620,7 @@ def getCoordinateTransform():
self.coordTransform = getCoordinateTransform()
self.styleFile = 'pl_scenes.qml'
self.downloadDir = '/home/lmotta/data/pl_download'
self.formatCatalogName = "{}({} .. {})"
self.formatCatalogName = "{}({} .. {})"
self.catalog = None
self.catalog_id = None
self.calculateMetadata = None
Expand Down Expand Up @@ -656,7 +657,7 @@ def _connect(self, isConnect=True):
]
if isConnect:
for item in ss:
item['signal'].connect( item['slot'] )
item['signal'].connect( item['slot'] )
else:
for item in ss:
item['signal'].disconnect( item['slot'] )
Expand Down Expand Up @@ -701,7 +702,7 @@ def setCustomProperty(layer, item_type, item_id):
layer.setCustomProperty('field_id', { 'name': 'item_id', 'value': item_id } ) # Field'type = String
layer.setCustomProperty('wkt_geom', geom.asWkt() )
self.menuXYZTiles.setLayer( layer )

def getXYZTiles(item_type, item_id):
url = self.apiPL.urlYXZImage.format( item_type=item_type, item_id=item_id )
return f"type=xyz&url={url}&username={self.apiPL.validKey}&zmax=19&zmin=0"
Expand Down Expand Up @@ -793,7 +794,7 @@ def progressImage(bytesReceived, bytesTotal):
perc = int( bytesReceived / bytesTotal * 100)
if perc % self.limitPercentImage == 0:
self.receivedBytesImage.emit( bytesReceived, bytesTotal, perc )

fileName = f"{item_type}_{item_id}.part"
self.currentImage.emit( fileName )
fileName = os.path.join( downloadDir, fileName )
Expand Down Expand Up @@ -1020,7 +1021,7 @@ def getJsonExtent():
rectCanvas = self.canvas.extent() if crsCanvas == self.crsCatalog else ct.transform( self.canvas.extent() )
geom = QgsGeometry.fromRect( rectCanvas )
return json.loads( geom.asJson() )

def getDateRangeFilter(dateGte, dateLte):
dtGte = QDateTime( dateGte )
dtLte = QDateTime( dateLte )
Expand Down Expand Up @@ -1134,7 +1135,7 @@ def searchImage(self, item_type, date1, date2):
self.message.emit( Qgis.Warning, 'No scene in map view', [] )
else:
self.message.emit( Qgis.Success, 'Finished OK', [] )

self.changeButtonApply.emit('Search')

@pyqtSlot(QDate, QDate)
Expand Down