Skip to content

Commit

Permalink
Merge pull request #27 from WhereGroup/25_add_warning
Browse files Browse the repository at this point in the history
Add warning about buggy QGIS versions
  • Loading branch information
kannes authored Feb 15, 2024
2 parents 245bac7 + a6fc158 commit fb37297
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 14 deletions.
26 changes: 22 additions & 4 deletions helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from osgeo import ogr
from qgis.PyQt.QtCore import QCoreApplication
from qgis.core import QgsExpressionContextUtils, QgsSettings, QgsMapLayer, QgsMapLayerType, QgsVectorLayer,\
from qgis.core import Qgis, QgsExpressionContextUtils, QgsSettings, QgsMapLayer, QgsMapLayerType, QgsVectorLayer,\
QgsWkbTypes
from qgis.utils import iface

Expand Down Expand Up @@ -180,8 +180,26 @@ def warnAboutCurveGeoms(layers: Iterable[QgsMapLayer]):
for layer in layers:
if not isLayerSupported(layer):
continue
# additional exceptions due to missing support for curve geometries in ogr's spatialite-based spatial filtering
# https://github.com/WhereGroup/spatial_filter/issues/1
if layer.storageType().upper() in ['GPKG', 'SQLITE'] and QgsWkbTypes.isCurvedType(layer.wkbType()):
txt = tr('The layer "{layername}" has an unsupported geometry type: '
'"CircularString", "CompoundCurve", "CurvePolygon", "MultiCurve", "MultiSurface", '
'"Curve" or "Surface".').format(layername=layer.name())
txt = tr(
'The {layerType} layer {layerName!r} has a geometry type ({geometryType}) that is not supported by the '
'{pluginName} plugin and will be ignored for filtering.'
).format(
layerName=layer.name(),
layerType=layer.storageType(),
pluginName=LOCALIZED_PLUGIN_NAME,
geometryType=QgsWkbTypes.displayString(layer.wkbType()),
)
iface.messageBar().pushWarning(LOCALIZED_PLUGIN_NAME, txt)


def warnAboutQgisBugProjectSaving():
"""Show a warning because of https://github.com/qgis/QGIS/issues/55975"""
if Qgis.QGIS_VERSION_INT < 33404:
txt = tr(
"QGIS &lt; 3.34.4 has a bug breaking the saving of (active) filters to projects "
'(<a href="https://github.com/WhereGroup/spatial_filter/issues/24">Info</a>)'
).format(pluginName=LOCALIZED_PLUGIN_NAME)
iface.messageBar().pushWarning(LOCALIZED_PLUGIN_NAME, txt)
Binary file modified i18n/spatial_filter_de.qm
Binary file not shown.
25 changes: 15 additions & 10 deletions i18n/spatial_filter_de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,21 @@
<source>Unknown filter</source>
<translation>Unbekannter Filter</translation>
</message>
<message>
<location filename="../helpers.py" line="184"/>
<source>The layer &quot;{layername}&quot; has an unsupported geometry type: &quot;CircularString&quot;, &quot;CompoundCurve&quot;, &quot;CurvePolygon&quot;, &quot;MultiCurve&quot;, &quot;MultiSurface&quot;, &quot;Curve&quot; or &quot;Surface&quot;.</source>
<translation>Der Layer &amp;quot;{layername}&amp;quot; hat einen nicht unterstützten Geometrietyp: &amp;quot;CircularString&amp;quot;, &amp;quot;CompoundCurve&amp;quot;, &amp;quot;CurvePolygon&amp;quot;, &amp;quot;MultiCurve&amp;quot;, &amp;quot;MultiSurface&amp;quot;, &amp;quot;Curve&amp;quot; oder &amp;quot;Surface&amp;quot;.</translation>
</message>
<message>
<location filename="../settings.py" line="7"/>
<source>Spatial Filter</source>
<translation>Räumlicher Filter</translation>
</message>
<message>
<location filename="../helpers.py" line="186"/>
<source>The {layerType} layer {layerName!r} has a geometry type ({geometryType}) that is not supported by the {pluginName} plugin and will be ignored for filtering.</source>
<translation>Der {layerType}-Layer {layerName!r} hat einen vom {pluginName!r}-Plugin nicht unterstützten Geometrietyp ({geometryType}) und kann daher nicht gefiltert werden.</translation>
</message>
<message>
<location filename="../helpers.py" line="201"/>
<source>QGIS &amp;lt; 3.34.4 has a bug breaking the saving of (active) filters to projects (&lt;a href=&quot;https://github.com/WhereGroup/spatial_filter/issues/24&quot;&gt;Info&lt;/a&gt;)</source>
<translation>QGIS &amp;lt; 3.34.4 hat einen Bug, welcher beim Speichern von Projekten mit aktivem Filter zu Fehlern führt (&lt;a href=&quot;https://github.com/WhereGroup/spatial_filter/issues/24&quot;&gt;Info&lt;/a&gt;)</translation>
</message>
</context>
<context>
<name>ExtentDialog</name>
Expand All @@ -85,27 +90,27 @@
<context>
<name>FilterController</name>
<message>
<location filename="../controller.py" line="78"/>
<location filename="../controller.py" line="88"/>
<source>Select a polygon layer</source>
<translation>Polygonlayer auswählen</translation>
</message>
<message>
<location filename="../controller.py" line="81"/>
<location filename="../controller.py" line="91"/>
<source>No features selected</source>
<translation>Keine Features gewählt</translation>
</message>
<message>
<location filename="../controller.py" line="117"/>
<location filename="../controller.py" line="127"/>
<source>Geometry is not valid</source>
<translation>Geometrie ist ungültig</translation>
</message>
<message>
<location filename="../controller.py" line="86"/>
<location filename="../controller.py" line="96"/>
<source>New filter from selection</source>
<translation>Neuer Filter aus Auswahl</translation>
</message>
<message>
<location filename="../controller.py" line="120"/>
<location filename="../controller.py" line="130"/>
<source>New filter from sketch</source>
<translation>Neuer Filter aus Skizze</translation>
</message>
Expand Down
3 changes: 3 additions & 0 deletions metadata.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ hasProcessingProvider=no
tags=python, filter, vector, postgis, performance

changelog=
Version 1.6:
- Add warning on QGIS < 3.34.4 due to bug in project saving
- Improved warning message on unsupported geometry types
Version 1.5:
- Clear filter when a new project is loaded or created
Version 1.4:
Expand Down
4 changes: 4 additions & 0 deletions spatial_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,15 @@ def initGui(self):
# we import just now because we need the QCoreApplication translator
# to be installed already (e.g. for the LOCALIZED_PLUGIN_NAME)
from .controller import FilterController
from .helpers import warnAboutQgisBugProjectSaving
from .widgets import FilterToolbar

self.toolbar = FilterToolbar(FilterController(), self.iface.mainWindow())
self.iface.mainWindow().addToolBar(self.toolbar)

warnAboutQgisBugProjectSaving()


def unload(self):
self.toolbar.hideFilterGeom()
self.toolbar.controller.removeFilter()
Expand Down

0 comments on commit fb37297

Please sign in to comment.