diff --git a/README.md b/README.md index 6170cb8..a1d4755 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ![logo](logo/logo.png) -# QGIS2Wegue +# QGIS2Wegue A QGIS plugin for creating [Wegue](https://github.com/meggsimum/wegue) configurations based on a QGIS project. Supported formats are: `WMS`, `XYZ`, `KML`, `GeoJSON`, `WFS` @@ -10,7 +10,7 @@ A QGIS plugin for creating [Wegue](https://github.com/meggsimum/wegue) configura - Add all your desired layers to QGIS - Open the plugin, chose a filepath and click `OK` -- Now you have a configuration file that works with Wegue +- Now you have a configuration file that works with Wegue ## Installation @@ -37,11 +37,20 @@ Update the plugin with `git pull https://github.com/meggsimum/qgis2wegue` and re ## Development Snippets +Install `pyqt5-dev-tools`. On Debian/Ubuntu: + +```shell +sudo apt-get install pyqt5-dev-tools +``` + Check code quality and errors: ```shell +# installation if needed +pip install --user pylint pycodestyle + pylint --reports=n --rcfile=pylintrc . -pycodestyle --repeat --ignore=E203,E121,E122,E123,E124,E125,E126,E127,E128 --exclude=resources.py . +pycodestyle --repeat --ignore=W504,E203,E121,E122,E123,E124,E125,E126,E127,E128 --exclude=resources.py . ``` Compile resources e.g. when logo has changed: @@ -58,7 +67,6 @@ TARGET_DIR=your/custom/path TMP_PLUGIN_DIR=${TARGET_DIR}/qgis2wegue -rm -rf ${TMP_PLUGIN_DIR} mkdir ${TMP_PLUGIN_DIR} cp -r \ *.py \ diff --git a/metadata.txt b/metadata.txt index 6ea0927..1417d83 100644 --- a/metadata.txt +++ b/metadata.txt @@ -1,7 +1,7 @@ [general] name=QGIS2Wegue qgisMinimumVersion=3.4 -version=1.0.0 +version=1.1.0 author=Jakob Miksch email=info@jakobmiksch.eu tracker=https://github.com/meggsimum/qgis2wegue/issues diff --git a/qgis2wegue.py b/qgis2wegue.py index 6c00b0f..aebc6fb 100644 --- a/qgis2wegue.py +++ b/qgis2wegue.py @@ -14,7 +14,9 @@ from .wegue_util import (center2webmercator, scale2zoom, - extract_wegue_layer_config) + extract_wegue_layer_config, + rgb2hex + ) class qgis2wegue: @@ -136,12 +138,8 @@ def check_path_and_handle_submit_button(self, path): dir_exists = os.path.exists(base_dir) - # wegue config files must match this pattern - file_is_valid = ( - file == 'app-conf.json') | (file.startswith('app-conf-') & file.endswith('.json')) - enabled = False - if (file != "") & dir_exists & file_is_valid: + if (file != "") & dir_exists & file.endswith('.json'): # output path valid enabled = True @@ -149,7 +147,7 @@ def check_path_and_handle_submit_button(self, path): def store_wegue_conf_to_file(self): """ - Collects all paramters from QGIS and the plugin form + Collects all parameters from QGIS and the plugin form and creates the Wegue configuration """ @@ -176,12 +174,6 @@ def store_wegue_conf_to_file(self): if result_layer: self.wegue_conf.mapLayers.append(result_layer) - # optional properties - self.wegue_conf.title = self.dlg.q2w_title_widget.text() - self.wegue_conf.footerTextLeft = self.dlg.q2w_footer_left_widget.text() - self.wegue_conf.footerTextRight = \ - self.dlg.q2w_footer_right_widget.text() - # add checkbox properties self.wegue_conf.showCopyrightYear = \ self.dlg.q2w_copyright_year.isChecked() @@ -203,21 +195,38 @@ def store_wegue_conf_to_file(self): if self.dlg.q2w_geocoder.isChecked(): self.wegue_conf.add_geocoder() - + if self.dlg.q2w_geodata_drag_drop.isChecked(): self.wegue_conf.add_map_geodata_drag_drop() - + if self.dlg.q2w_permalink.isChecked(): self.wegue_conf.add_permalink() - + if self.dlg.q2w_geolocator.isChecked(): self.wegue_conf.add_geolocator() + if self.dlg.q2w_overview_map.isChecked(): + self.wegue_conf.add_overview_map() + + if self.dlg.q2w_view_animation.isChecked(): + self.wegue_conf.add_view_animation() + + if self.dlg.q2w_map_recorder.isChecked(): + self.wegue_conf.add_maprecorder() + + if self.dlg.q2w_attribute_table.isChecked(): + self.wegue_conf.add_attribute_table() + # color - color_rgb = self.dlg.q2w_color_widget.color().getRgb() - # drop alpha value - color_rgb = color_rgb[0:3] - self.wegue_conf.baseColor = "rgb" + str(color_rgb) + qt_color = self.dlg.q2w_color_widget.color() + hex_color = rgb2hex(qt_color.red(), qt_color.green(), qt_color.blue()) + self.wegue_conf.colorTheme = { + "themes": { + "light": { + "primary": hex_color + } + } + } # path for config user_input = self.dlg.q2w_file_widget.filePath() diff --git a/qgis2wegue_dialog.py b/qgis2wegue_dialog.py index af39d33..f19ade3 100644 --- a/qgis2wegue_dialog.py +++ b/qgis2wegue_dialog.py @@ -12,4 +12,4 @@ class qgis2wegueDialog(QtWidgets.QDialog, FORM_CLASS): def __init__(self, parent=None): """Constructor.""" super(qgis2wegueDialog, self).__init__(parent) - self.setupUi(self) \ No newline at end of file + self.setupUi(self) diff --git a/qgis2wegue_dialog_base.ui b/qgis2wegue_dialog_base.ui index b581af2..4882749 100644 --- a/qgis2wegue_dialog_base.ui +++ b/qgis2wegue_dialog_base.ui @@ -9,8 +9,8 @@ 0 0 - 803 - 754 + 801 + 623 @@ -34,7 +34,7 @@ 10 10 781 - 731 + 591 @@ -48,7 +48,10 @@ <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } </style></head><body style=" font-family:'Noto Sans'; font-size:9pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Cantarell'; font-size:11pt;">This plugin creates a </span><a href="https://github.com/meggsimum/wegue"><span style=" font-family:'Cantarell'; font-size:11pt; text-decoration: underline; color:#0000ff;">Wegue</span></a><span style=" font-family:'Cantarell'; font-size:11pt;"> configuration from a QGIS project. It automatically takes the zoom level and map position. Moreover it converts all layers of the project to Wegue. This file can either be used directly with Wegue or may serve as a basis for manual customization. <br /><br />The final file must be called &quot;app-conf.json&quot; or &quot;app-conf-</span><span style=" font-family:'Cantarell'; font-size:11pt; color:#4e9a06;">yourCustomName</span><span style=" font-family:'Cantarell'; font-size:11pt;">.json&quot;<br /><br />Supported layer formats: </span><span style=" font-family:'Cantarell'; font-size:11pt; font-weight:600; color:#000000;">WMS</span><span style=" font-family:'Cantarell'; font-size:11pt; color:#000000;">, </span><span style=" font-family:'Cantarell'; font-size:11pt; font-weight:600; color:#000000;">XYZ</span><span style=" font-family:'Cantarell'; font-size:11pt; color:#000000;">, </span><span style=" font-family:'Cantarell'; font-size:11pt; font-weight:600; color:#000000;">KML</span><span style=" font-family:'Cantarell'; font-size:11pt; color:#000000;">, </span><span style=" font-family:'Cantarell'; font-size:11pt; font-weight:600; color:#000000;">GeoJSON</span><span style=" font-family:'Cantarell'; font-size:11pt; color:#000000;">, </span><span style=" font-family:'Cantarell'; font-size:11pt; font-weight:600; color:#000000;">WFS</span><span style=" font-family:'Cantarell'; font-size:11pt;"><br /><br /></span><span style=" font-family:'Cantarell'; font-size:11pt; color:#000000;">Let us know if there is something not working as expected. Either open an </span><a href="https://github.com/meggsimum/qgis2wegue/issues/new"><span style=" font-family:'Cantarell'; font-size:11pt; text-decoration: underline; color:#0000ff;">issue on GitHub</span></a><span style=" font-family:'Cantarell'; font-size:11pt; color:#000000;"> or write us an </span><a href="mailto:info@jakobmiksch.eu"><span style=" font-family:'Cantarell'; font-size:11pt; text-decoration: underline; color:#0000ff;">email</span></a><span style=" font-family:'Cantarell'; font-size:11pt; color:#000000;">. Thanks!</span></p></body></html> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Cantarell'; font-size:11pt; color:#000000;">This plugin creates a </span><a href="https://github.com/meggsimum/wegue"><span style=" font-family:'Cantarell'; font-size:11pt; text-decoration: underline; color:#0000ff;">Wegue </span></a><span style=" font-family:'Cantarell'; font-size:11pt; color:#000000;">configuration from a QGIS project. It automatically reads the zoom level and the position from the map. Moreover it converts all layers of the project to Wegue. This file can either be used directly with Wegue or may serve as a basis for manual customization. </span></p> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Cantarell'; font-size:11pt; color:#000000;">Note: This plugin targets </span><a href="https://github.com/meggsimum/wegue/releases/tag/v1.0.0"><span style=" font-size:11pt; text-decoration: underline; color:#0000ff;">Wegue v1.0.0</span></a><span style=" font-family:'Cantarell'; font-size:11pt; color:#000000;"> and might need adaptation for other versions.</span></p> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Cantarell'; font-size:11pt; color:#000000;"><br />Supported layer formats: </span><span style=" font-family:'Cantarell'; font-size:11pt; font-weight:600; color:#000000;">WMS</span><span style=" font-family:'Cantarell'; font-size:11pt; color:#000000;">, </span><span style=" font-family:'Cantarell'; font-size:11pt; font-weight:600; color:#000000;">XYZ</span><span style=" font-family:'Cantarell'; font-size:11pt; color:#000000;">, </span><span style=" font-family:'Cantarell'; font-size:11pt; font-weight:600; color:#000000;">KML</span><span style=" font-family:'Cantarell'; font-size:11pt; color:#000000;">, </span><span style=" font-family:'Cantarell'; font-size:11pt; font-weight:600; color:#000000;">GeoJSON</span><span style=" font-family:'Cantarell'; font-size:11pt; color:#000000;">, </span><span style=" font-family:'Cantarell'; font-size:11pt; font-weight:600; color:#000000;">WFS</span></p> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Cantarell'; font-size:11pt;"><br /></span><span style=" font-family:'Cantarell'; font-size:11pt; color:#000000;">Let us know if there is something not working as expected. Either open an </span><a href="https://github.com/meggsimum/qgis2wegue/issues/new"><span style=" font-family:'Cantarell'; font-size:11pt; text-decoration: underline; color:#0000ff;">issue on GitHub</span></a><span style=" font-family:'Cantarell'; font-size:11pt; color:#000000;"> or write us an </span><a href="mailto:info@meggsimum.de"><span style=" font-family:'Cantarell'; font-size:11pt; text-decoration: underline; color:#0000ff;">email</span></a><span style=" font-family:'Cantarell'; font-size:11pt; color:#000000;">. Also have a look at the </span><a href="http://www.wegue.org"><span style=" font-size:11pt; text-decoration: underline; color:#0000ff;">documention of Wegue</span></a><span style=" font-family:'Cantarell'; font-size:11pt; color:#000000;">.</span></p></body></html> true @@ -58,142 +61,152 @@ p, li { white-space: pre-wrap; } - - - - Title (optional) - - - - - - - - - - Footer Left (optional) - - - - - - - - - - Footer Right (optional) - - - - - - - - - - Map Options: - - - - - + + - Feature Info + Permalink - true + false - - + + - Copyright Year + MapRecorder - true + false - - + + - Help Window + GeoLocator - true + false - - + + - Measure Tool + Geocoder - true + false - - + + - Zoom To Maximum Extent + Attribute Table - true + false - + Layer List - true + false + + + + + + + View Animation + + + false - + - Permalink + Zoom To Maximum Extent - true + false - + + + + Overview Map + + + false + + + + + + + Measure Tool + + + false + + + + Geodata DragDrop - true + false - - + + - Geocoder + Feature Info - true + false - - + + - GeoLocator + Help Window - true + false + + + + + + + Copyright Year + + + false + + + + + + + Map Modules: diff --git a/resources.py b/resources.py index faf0dfe..5497ec9 100644 --- a/resources.py +++ b/resources.py @@ -2,7 +2,7 @@ # Resource object code # -# Created by: The Resource Compiler for PyQt5 (Qt v5.9.5) +# Created by: The Resource Compiler for PyQt5 (Qt v5.12.8) # # WARNING! All changes made in this file will be lost! @@ -342,8 +342,8 @@ \x00\x00\x01\x76\x87\x19\x7a\xdc\ " -qt_version = QtCore.qVersion().split('.') -if qt_version < ['5', '8', '0']: +qt_version = [int(v) for v in QtCore.qVersion().split('.')] +if qt_version < [5, 8, 0]: rcc_version = 1 qt_resource_struct = qt_resource_struct_v1 else: diff --git a/screenshot_gui.png b/screenshot_gui.png index f16e133..cd0dbbc 100644 Binary files a/screenshot_gui.png and b/screenshot_gui.png differ diff --git a/wegueConf.py b/wegueConf.py index 8c60dca..d48f565 100644 --- a/wegueConf.py +++ b/wegueConf.py @@ -5,12 +5,15 @@ class WegueConfiguration: """Contains parameters of a Wegue configuration""" def __init__(self): - self.title = "Vue.js / OpenLayers WebGIS" - self.baseColor = "green darken-3" + self.colorTheme = { + "themes": { + "light": { + "primary": "#fdbf6f" + } + } + } self.logo = "https://dummyimage.com/100x100/aaa/fff&text=Wegue" self.logoSize = 100 - self.footerTextLeft = "Powered by Wegue WebGIS" - self.footerTextRight = "meggsimum" self.showCopyrightYear = True self.mapZoom = 2 self.mapCenter = (0, 0) @@ -33,26 +36,43 @@ def add_map_geodata_drag_drop(self): } def add_permalink(self): - self.permalink = { + self.permalink = { "location": "hash", "layers": True, "extent": False, "projection": "EPSG:4326", "paramPrefix": "", "history": True - } + } + + def add_overview_map(self): + self.overviewMap = { + "visible": False + } + + def add_view_animation(self): + self.viewAnimation = { + "type": "fly", + "options": { + "duration": 3000, + "zoom": 15, + "maxZoom": 15 + } + } def add_layer_list(self): self.modules["wgu-layerlist"] = { "target": "menu", - "win": True, - "draggable": False + "icon": "layers", + "win": "floating", + "draggable": False, } def add_measuretool(self): self.modules["wgu-measuretool"] = { "target": "menu", - "win": True, + "win": "floating", + "icon": "photo_size_select_small", "draggable": False, "strokeColor": "#c62828", "fillColor": "rgba(198,40,40,0.2)", @@ -65,7 +85,8 @@ def add_measuretool(self): def add_infoclick(self): self.modules["wgu-infoclick"] = { "target": "menu", - "win": True, + "win": "floating", + "icon": "info", "draggable": False, "initPos": { "left": 8, @@ -108,3 +129,22 @@ def add_geolocator(self): "darkLayout": True } + def add_maprecorder(self): + self.modules["wgu-maprecorder"] = { + "target": "toolbar", + "win": "floating", + "icon": "mdi-video", + "draggable": False, + "initPos": { + "left": 8, + "top": 230 + } + } + + def add_attribute_table(self): + self.modules["wgu-attributetable"] = { + "target": "menu", + "win": "floating", + "icon": "table_chart", + "syncTableMapSelection": True + } diff --git a/wegue_util.py b/wegue_util.py index c4d3e56..9f14385 100644 --- a/wegue_util.py +++ b/wegue_util.py @@ -9,6 +9,15 @@ QgsCoordinateReferenceSystem) +def rgb2hex(r, g, b): + """ + Converts a RGB color to hex code + + Taken from https://stackoverflow.com/a/43572620 + """ + return "#{:02x}{:02x}{:02x}".format(r, g, b) + + def center2webmercator(center_point, qgis_instance): """Converts a point geometry to EPSG:3857"""