Skip to content

Commit

Permalink
feat: style output layers of plugin GUI (#188)
Browse files Browse the repository at this point in the history
Style was chosen to follow the ors maps client.
Style is only overwritten on GUI usage, not for anything else. See discussion in the PR.

Fixes #149 

Co-authored-by: Jakob Schnell <Jakob.Schnell@heigit.org>
  • Loading branch information
merydian and koebi authored Dec 21, 2023
1 parent 4b05e86 commit 1d1e856
Show file tree
Hide file tree
Showing 5 changed files with 649 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ RELEASING:
- Additional parameter for the "smoothing factor" to isochrones processing algorithms ([#172](https://github.com/GIScience/orstools-qgis-plugin/issues/172))
- Mention omission of configuration options when using traveling salesman
- option to set location type for isochrones ([#191](https://github.com/GIScience/orstools-qgis-plugin/pull/191))
- Add styling of routing output in main plugin ([#149](https://github.com/GIScience/orstools-qgis-plugin/issues/149))
- make items in centroid list drag and droppable ([#144](https://github.com/GIScience/orstools-qgis-plugin/issues/144))
- Add save button for vertices ([#144](https://github.com/GIScience/orstools-qgis-plugin/issues/144))

Expand Down
16 changes: 15 additions & 1 deletion ORStools/gui/ORStoolsDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
)
from qgis.gui import QgsMapCanvasAnnotationItem

from PyQt5.QtCore import QSizeF, QPointF, QCoreApplication
from PyQt5.QtCore import QSizeF, QPointF, QCoreApplication, QSettings
from PyQt5.QtGui import QIcon, QTextDocument
from PyQt5.QtWidgets import QAction, QDialog, QApplication, QMenu, QMessageBox, QDialogButtonBox

Expand Down Expand Up @@ -243,6 +243,20 @@ def run_gui_control(self):
layer_out.dataProvider().addAttributes(directions_core.get_fields())
layer_out.updateFields()

basepath = os.path.dirname(__file__)

# add ors svg path
my_new_path = os.path.join(basepath, "img/svg")
svg_paths = QSettings().value("svg/searchPathsForSVG")
if my_new_path not in svg_paths:
svg_paths.append(my_new_path)
QSettings().setValue("svg/searchPathsForSVG", svg_paths)

# style output layer
qml_path = os.path.join(basepath, "linestyle.qml")
layer_out.loadNamedStyle(qml_path, True)
layer_out.triggerRepaint()

# Associate annotations with map layer, so they get deleted when layer is deleted
for annotation in self.dlg.annotations:
# Has the potential to be pretty cool: instead of deleting, associate with mapLayer
Expand Down
9 changes: 9 additions & 0 deletions ORStools/gui/img/svg/endpoint_marker.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions ORStools/gui/img/svg/startpoint_marker.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 1d1e856

Please sign in to comment.