Skip to content

Commit

Permalink
Merge pull request #112 from Riverscapes/jan_cleanup
Browse files Browse the repository at this point in the history
Jan cleanup
  • Loading branch information
philipbaileynar authored Apr 4, 2024
2 parents f9f8c2c + 1f79d20 commit 56f393a
Show file tree
Hide file tree
Showing 14 changed files with 63 additions and 32 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@

## 0.9.1 ***(March 27, 2024)***

### Fixed
- Bug with "Show Basemaps in Project Tree" checkbox throwing error
- Bug when adding Basemaps to versions of QGIS < 3.28
- View in Warehouse button menu item now working properly with new Riverscapes Projects version

### Changed
- removed lingering references to QRAVE
- Updated urls to riverscapes.net
- Update Settings window title

## 0.9.0 ***(December 15, 2023)***

* Refresh QRAVE as Riverscapes Viewer
Expand Down
2 changes: 1 addition & 1 deletion CHECKLIST.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ NEVER WORK DIRECTLY ON THE MASTER BRANCH
6. Tag the commit in git with the version number
7. Run `deploy.py` again. This will produce the zip file to upload
8. Test again
9. Go to https://plugins.qgis.org/plugins/qrave_toolbar/ and log in. You should be able to manage and add a new version from there.
9. Go to https://plugins.qgis.org/plugins/riverscapes_viewer/ and log in. You should be able to manage and add a new version from there.
10. Go make a release on github. This might be redundant but.... TBA
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Riverscapes Viewer

The Riverscapes Viewer (QRAVE) is a [QGIS](http://www.qgis.org/en/site/) plugin you can use to interact with riverscapes data. See the repository online documentation for more information:
The Riverscapes Viewer (formerly QRAVE) is a [QGIS](http://www.qgis.org/en/site/) plugin you can use to interact with riverscapes data. See the repository online documentation for more information:

<https://riverscapes.github.io/RiverscapesToolbar/>

Expand Down Expand Up @@ -63,7 +63,7 @@ pip install pylint autopep8 ptvsd pb-tool
* [Plugin Builder 3](http://g-sherman.github.io/Qgis-Plugin-Builder) -- Creates a QGIS plugin template for use as a starting point in plugin development. Not totally necessary but good to have if you want to build plugins.


clone this repo to `qrave_toolbar_dev` so that `qrave_toolbar` is what gets used for deployment
clone this repo to `riverscapes_viewer_dev` so that `riverscapes_viewer` is what gets used for deployment



Expand Down
2 changes: 1 addition & 1 deletion __version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.9.0"
__version__ = "0.9.1"
8 changes: 4 additions & 4 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
"basemapRegion": "United States"
},
"constants": {
"logCategory": "QRAVE",
"settingsCategory": "QRAVE",
"logCategory": "Riverscapes Viewer",
"settingsCategory": "RiverscapesViewer",
"businessLogicDir": "blXML",
"symbologyDir": "symbology",
"digestSyncFreqHours": 24,
"warehouseUrl": "https://data.riverscapes.net/#",
"webUrl": "https://rave.riverscapes.net",
"warehouseUrl": "https://data.riverscapes.net",
"webUrl": "https://viewer.riverscapes.net",
"issueUrl": "https://github.com/Riverscapes/QRAVEPlugin/issues",
"changelogUrl": "https://github.com/Riverscapes/QRAVEPlugin/releases",
"resourcesUrl": "https://xml.riverscapes.net/"
Expand Down
2 changes: 1 addition & 1 deletion metadata.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ changelog=https://github.com/Riverscapes/QRAVEPlugin/blob/master/CHANGELOG.md
# Tags are comma separated with spaces allowed
tags=python,riverscapes,rave

homepage=http://rave.riverscapes.net
homepage=https://viewer.riverscapes.net
category=Plugins
icon=icon.png

Expand Down
2 changes: 1 addition & 1 deletion pb_tool.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#/***************************************************************************
# QRAVE
# Riverscapes Viewer
#
# Configuration file for plugin builder tool (pb_tool)
# Generated by Plugin Builder: http://g-sherman.github.io/Qgis-Plugin-Builder/
Expand Down
10 changes: 5 additions & 5 deletions src/classes/net_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def finished(self, result=None):
Qgis.Warning)
else:
settings.setValue('initialized', True)
settings.msg_bar('QRAVE Sync Syccess', '{} files checked, {} updated'.format(self.total, self.downloaded), Qgis.Success)
settings.msg_bar('Riverscapes Resources Sync Syccess', '{} files checked, {} updated'.format(self.total, self.downloaded), Qgis.Success)
if result is True:
settings.setValue('lastDigestSync', int(time()))

Expand Down Expand Up @@ -158,7 +158,7 @@ def _syncFiles(self):
local_path = os.path.join(self.resource_dir, os.path.basename(remote_path))
if not os.path.isfile(local_path) or remote_md5 != md5(local_path):
requestDownload(CONSTANTS['resourcesUrl'] + remote_path, local_path, remote_md5)
QgsMessageLog.logMessage("Basemaps downloaded: {}".format(local_path), 'QRAVE', level=Qgis.Info)
QgsMessageLog.logMessage("Basemaps downloaded: {}".format(local_path), 'Riverscapes Viewer', level=Qgis.Info)

self.downloaded += 1
all_local_files = [x for x in all_local_files if x != local_path]
Expand All @@ -172,9 +172,9 @@ def _syncFiles(self):
rel_check = os.path.relpath(dfile, os.path.join(os.path.dirname(__file__), '..', '..', 'resources'))
if len(os.path.split(rel_check)) < 3:
os.remove(dfile)
QgsMessageLog.logMessage("Extraneous file removed: {}".format(dfile), 'QRAVE', level=Qgis.Warning)
QgsMessageLog.logMessage("Extraneous file removed: {}".format(dfile), 'Riverscapes Viewer', level=Qgis.Warning)
else:
QgsMessageLog.logMessage("Can't remove file because it's in the wrong place: {}".format(dfile), 'QRAVE', level=Qgis.Critical)
QgsMessageLog.logMessage("Can't remove file because it's in the wrong place: {}".format(dfile), 'QRiverscapes Viewer', level=Qgis.Critical)
except Exception as e:
QgsMessageLog.logMessage("Error deleting file: {}".format(dfile), 'QRAVE', level=Qgis.Critical)
QgsMessageLog.logMessage("Error deleting file: {}".format(dfile), 'Riverscapes Viewer', level=Qgis.Critical)
self.setProgress(100)
19 changes: 16 additions & 3 deletions src/classes/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ def load(self):
if self.load_errs is False:
self.settings.msg_bar('Project Loaded', self.project_xml_path, Qgis.Success)
else:
self.settings.msg_bar('Project Loaded with errors', "(See QRAVE logs for details)", Qgis.Critical)
self.settings.msg_bar('Project Loaded with errors', "(See Riverscapes Viewer logs for details)", Qgis.Critical)
except Exception as e:
self.settings.msg_bar("Error loading project", "Project: {}\n (See QRAVE logs for specifics)".format(self.project_xml_path),
self.settings.msg_bar("Error loading project", "Project: {}\n (See Riverscapes Viewer logs for specifics)".format(self.project_xml_path),
Qgis.Critical)
self.settings.log("Exception {}\n\nTrace: {}".format(e, traceback.format_exc()), Qgis.Critical)
else:
Expand All @@ -87,7 +87,12 @@ def _load_project(self):
self.project = lxml.etree.parse(self.project_xml_path).getroot()

self.meta = self.extract_meta(self.project.findall('MetaData/Meta'))
self.warehouse_meta = self.extract_meta(self.project.findall('Warehouse/Meta'))
if self.version == 'V1':
self.warehouse_meta = self.extract_meta(self.project.findall('Warehouse/Meta'))
else:
# Version 2 has a different warehouse structure
self.warehouse_meta = self.extract_warehouse(self.project.find('Warehouse'))

self.project_type = self.project.find('ProjectType').text

realizations = self.project.find('Realizations')
Expand All @@ -102,6 +107,14 @@ def extract_meta(self, nodelist):
type = meta_node.attrib['type'] if 'type' in meta_node.attrib else None
meta[key] = (value, type)
return meta

def extract_warehouse(self, node):
meta = {}
meta['id'] = (node.attrib['id'], 'string')
meta['apiUrl'] = (node.attrib['apiUrl'], 'string')
if 'ref' in node.attrib:
meta['ref'] = (node.attrib['ref'], 'string')
return meta

def _load_businesslogic(self):
if self.project is None or self.project_type is None:
Expand Down
4 changes: 3 additions & 1 deletion src/classes/qrave_map_layer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations
import os

from typing import Dict
from qgis.core import Qgis, QgsProject, QgsRasterLayer, QgsVectorLayer
from qgis.PyQt.QtCore import Qt
Expand Down Expand Up @@ -247,7 +248,8 @@ def add_layer_to_map(item: QStandardItem):
rOutput = None
# This might be a basemap
if map_layer.layer_type == QRaveMapLayer.LayerTypes.WEBTILE:
rOutput = QgsRasterLayer(layer_uri, map_layer.label, 'wms')
out_uri = layer_uri.replace('%3F', '?').replace('%3A', ':').replace('%2F', '/').replace('%3D', '=')
rOutput = QgsRasterLayer(out_uri, map_layer.label, 'wms')

elif map_layer.layer_type in [QRaveMapLayer.LayerTypes.LINE, QRaveMapLayer.LayerTypes.POLYGON, QRaveMapLayer.LayerTypes.POINT]:
if map_layer.layer_name is not None:
Expand Down
14 changes: 7 additions & 7 deletions src/classes/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ def requestFetch(remote_url: str, expected_md5=None):
return resp.content

except requests.exceptions.Timeout:
QgsMessageLog.logMessage("Fetching digest timed out: {}".format(remote_url), 'QRAVE', level=Qgis.Critical)
QgsMessageLog.logMessage("Fetching digest timed out: {}".format(remote_url), 'Riverscapes Viewer', level=Qgis.Critical)
return False
# Maybe set up for a retry, or continue in a retry loop
except requests.exceptions.TooManyRedirects:
# Tell the user their URL was bad and try a different one
QgsMessageLog.logMessage("Fetching digest failed with too many redirects: {}".format(remote_url), 'QRAVE', level=Qgis.Critical)
QgsMessageLog.logMessage("Fetching digest failed with too many redirects: {}".format(remote_url), 'Riverscapes Viewer', level=Qgis.Critical)
return False
except requests.exceptions.RequestException as e:
QgsMessageLog.logMessage("Unknown error downloading file: {}".format(remote_url), 'QRAVE', level=Qgis.Critical)
QgsMessageLog.logMessage("Unknown error downloading file: {}".format(remote_url), 'Riverscapes Viewer', level=Qgis.Critical)
# catastrophic error. bail.
raise SystemExit(e)
return True
Expand All @@ -54,19 +54,19 @@ def requestDownload(remote_url: str, local_path: str, expected_md5=None):
# Do an MD5 check if we need to
if os.path.isfile(local_path) and expected_md5 is not None and expected_md5 != md5(local_path):
os.remove(local_path)
QgsMessageLog.logMessage("MD5 did not match expected for file: {}".format(remote_url), 'QRAVE', level=Qgis.Warning)
QgsMessageLog.logMessage("MD5 did not match expected for file: {}".format(remote_url), 'Riverscapes Viewer', level=Qgis.Warning)
return False

except requests.exceptions.Timeout:
QgsMessageLog.logMessage("Fetching file timed out: {}".format(remote_url), 'QRAVE', level=Qgis.Critical)
QgsMessageLog.logMessage("Fetching file timed out: {}".format(remote_url), 'Riverscapes Viewer', level=Qgis.Critical)
return False
# Maybe set up for a retry, or continue in a retry loop
except requests.exceptions.TooManyRedirects:
# Tell the user their URL was bad and try a different one
QgsMessageLog.logMessage("Fetching file failed with too many redirects: {}".format(remote_url), 'QRAVE', level=Qgis.Critical)
QgsMessageLog.logMessage("Fetching file failed with too many redirects: {}".format(remote_url), 'Riverscapes Viewer', level=Qgis.Critical)
return False
except requests.exceptions.RequestException as e:
QgsMessageLog.logMessage("Unknown error downloading file: {}".format(remote_url), 'QRAVE', level=Qgis.Critical)
QgsMessageLog.logMessage("Unknown error downloading file: {}".format(remote_url), 'Riverscapes Viewer', level=Qgis.Critical)
# catastrophic error. bail.
raise SystemExit(e)
return True
4 changes: 4 additions & 0 deletions src/dock_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ def get_checked_state(idx, output=[]):
output = get_checked_state(child, output)

item = self.model.itemFromIndex(idx)
if item is None:
return output
expanded = self.treeView.isExpanded(idx)
output.append((item.text(), expanded))

Expand Down Expand Up @@ -436,6 +438,8 @@ def get_warehouse_url(self, wh_meta: Dict[str, str]):

elif '_rs_wh_id' in wh_meta and '_rs_wh_program' in wh_meta:
return '/'.join([CONSTANTS['warehouseUrl'], wh_meta['_rs_wh_program'][0], wh_meta['_rs_wh_id'][0]])
elif 'id' in wh_meta:
return '/'.join([CONSTANTS['warehouseUrl'], 'p', wh_meta['id'][0]])

return None

Expand Down
9 changes: 4 additions & 5 deletions src/qrave_toolbar.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
"""
/***************************************************************************
QRAVE
Riverscpaes Viewer
A QGIS plugin
Explore symbolized Riverscapes projects
Generated by Plugin Builder: http://g-sherman.github.io/Qgis-Plugin-Builder/
Expand Down Expand Up @@ -145,14 +145,14 @@ def initGui(self):
# self.tr('Website'),
# self.iface.mainWindow()
# )
# self.websiteAction.triggered.connect(lambda: QDesktopServices.openUrl(QUrl("http://rave.riverscapes.net")))
# self.websiteAction.triggered.connect(lambda: QDesktopServices.openUrl(QUrl("https://viewer.riverscapes.net/software-help/help-qgis/")))

self.helpAction = QAction(
QIcon(':/plugins/qrave_toolbar/Help.png'),
self.tr('Help'),
self.iface.mainWindow()
)
self.helpAction.triggered.connect(lambda: QDesktopServices.openUrl(QUrl("http://rave.riverscapes.net")))
self.helpAction.triggered.connect(lambda: QDesktopServices.openUrl(QUrl("https://viewer.riverscapes.net/software-help/help-qgis/")))

self.raveOptionsAction = QAction(
QIcon(':/plugins/qrave_toolbar/Options.png'),
Expand Down Expand Up @@ -385,8 +385,7 @@ def about_load(self):
"""
dialog = AboutDialog()
if self.acknowledgements is None:
self.acknowledgements = requests.get('http://rave.riverscapes.net/dotnetack.html').text
print('hello')
self.acknowledgements = '<a href="{0}">{0}</a>'.format('https://viewer.riverscapes.net/about/acknowledgements')

dialog.acknowledgements.setText(self.acknowledgements)
dialog.exec_()
2 changes: 1 addition & 1 deletion src/ui/options_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def setupUi(self, Dialog):

def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "Options"))
Dialog.setWindowTitle(_translate("Dialog", " Riverscapes Viewer Settings"))
self.basemapsInclude.setText(_translate("Dialog", "Include basemaps in explorer tree"))
self.label.setText(_translate("Dialog", "Region"))
self.regionHelp.setText(_translate("Dialog", "..."))
Expand Down

0 comments on commit 56f393a

Please sign in to comment.