Skip to content

Commit

Permalink
Raise QGIS minimum version to 3.10
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustry committed May 11, 2022
1 parent 68bbc21 commit 5e34554
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 48 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
* First version of the plugin after the split between Lizmap desktop and server plugin
* The source code is the same as Lizmap plugin version 3.7.7
* Fix Python exception when GetFeatureInfo does not have a feature ID
* Raise QGIS minimum version to QGIS 3.10
13 changes: 5 additions & 8 deletions lizmap_server/filter_by_polygon.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,25 @@
__license__ = 'GPL version 3'
__email__ = '[email protected]'

import binascii

from functools import lru_cache
from typing import Tuple, Union

from qgis.core import (
Qgis,
QgsCoordinateReferenceSystem,
QgsCoordinateTransform,
QgsDataSourceUri,
QgsFeatureRequest,
QgsGeometry,
QgsProject,
QgsProviderConnectionException,
QgsProviderRegistry,
QgsSpatialIndex,
QgsVectorLayer,
)
from qgis.PyQt.QtCore import QVariant

if Qgis.QGIS_VERSION_INT > 31000:
import binascii

from qgis.core import QgsProviderRegistry

from lizmap_server.logger import Logger, profiling

# TODO implement LRU cache with this variable
Expand Down Expand Up @@ -161,7 +158,7 @@ def subset_sql(self, groups: tuple) -> Tuple[str, str]:

# We need to have a cache for this, valid for the combo polygon layer id & user_groups
# as it will be done for each WMS or WFS query
if self.polygon.providerType() == 'postgres' and Qgis.QGIS_VERSION_INT > 31000:
if self.polygon.providerType() == 'postgres':
polygon = self._polygon_for_groups_with_sql_query(groups)
else:
polygon = self._polygon_for_groups_with_qgis_api(groups)
Expand All @@ -178,7 +175,7 @@ def subset_sql(self, groups: tuple) -> Tuple[str, str]:
)

if self.layer.providerType() == 'postgres':
if self.use_st_relationship or Qgis.QGIS_VERSION_INT > 31000:
if self.use_st_relationship:
uri = QgsDataSourceUri(self.layer.source())
use_st_intersect = False if self.spatial_relationship == 'contains' else True
st_relation = self._format_sql_st_relationship(
Expand Down
2 changes: 1 addition & 1 deletion lizmap_server/metadata.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[general]
name=Lizmap server
qgisMinimumVersion=3.4
qgisMinimumVersion=3.10
qgisMaximumVersion=3.99
author=3Liz
[email protected]
Expand Down
30 changes: 11 additions & 19 deletions lizmap_server/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
__license__ = 'GPL version 3'
__email__ = '[email protected]'

from qgis.core import Qgis
from qgis.server import QgsServerInterface, QgsServerOgcApi

from lizmap_server.expression_service import ExpressionService
Expand All @@ -11,11 +10,9 @@
from lizmap_server.lizmap_filter import LizmapFilter
from lizmap_server.lizmap_service import LizmapService
from lizmap_server.logger import Logger
from lizmap_server.server_info_handler import ServerInfoHandler
from lizmap_server.tools import check_environment_variable, version

if Qgis.QGIS_VERSION_INT >= 31000:
from lizmap_server.server_info_handler import ServerInfoHandler


class LizmapServer:
"""Plugin for QGIS server
Expand All @@ -30,22 +27,17 @@ def __init__(self, server_iface: QgsServerInterface) -> None:
service_registry = server_iface.serviceRegistry()

# Register API
if Qgis.QGIS_VERSION_INT < 31000:
self.logger.warning(
'Not possible to register the API needed for Lizmap Web Client ≥ 3.5. '
'QGIS Server/Desktop must be 3.10 minimum.')
else:
lizmap_api = QgsServerOgcApi(
self.server_iface,
'/lizmap',
'Lizmap',
'The Lizmap API endpoint',
self.version)
service_registry.registerApi(lizmap_api)
lizmap_api.registerHandler(ServerInfoHandler())
self.logger.info('API "/lizmap" loaded with the server info handler')
lizmap_api = QgsServerOgcApi(
self.server_iface,
'/lizmap',
'Lizmap',
'The Lizmap API endpoint',
self.version)
service_registry.registerApi(lizmap_api)
lizmap_api.registerHandler(ServerInfoHandler())
self.logger.info('API "/lizmap" loaded with the server info handler')

check_environment_variable()
check_environment_variable()

# Register service
try:
Expand Down
25 changes: 8 additions & 17 deletions lizmap_server/tooltip.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from typing import Union

from qgis.core import (
Qgis,
QgsAttributeEditorContainer,
QgsAttributeEditorElement,
QgsAttributeEditorField,
Expand Down Expand Up @@ -304,22 +303,14 @@ def _generate_external_resource(widget_config: dict, name: str, fname: str):
)'''.format(name, fname)

elif dview == QgsExternalResourceWidget.NoContent:
if Qgis.QGIS_VERSION_INT >= 30800:
field_view = '''
concat(
'<a href="',
"{0}",
'" target="_blank">',
base_file_name({0}),
'</a>'
)'''.format(name)
else:
field_view = '''
concat(
'<a href="',
"{}",
'" target="_blank">{}</a>'
)'''.format(name, fname)
field_view = '''
concat(
'<a href="',
"{0}",
'" target="_blank">',
base_file_name({0}),
'</a>'
)'''.format(name)

else:
raise Exception('Unknown external resource widget')
Expand Down
3 changes: 0 additions & 3 deletions test/test_filter_by_polygon.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import unittest

from qgis.core import (
Qgis,
QgsCoordinateReferenceSystem,
QgsFeature,
QgsGeometry,
Expand All @@ -21,7 +20,6 @@

class TestFilterByPolygon(unittest.TestCase):

@unittest.skipIf(Qgis.QGIS_VERSION_INT < 31000, 'Memory layer does not work well with 3.4')
def test_not_filtered_layer(self):
""" Test for not filtered layer. """
json = {
Expand All @@ -43,7 +41,6 @@ def test_not_filtered_layer(self):
self.assertFalse(FilterByPolygon(json, points).is_valid())

# noinspection PyArgumentList
@unittest.skipIf(Qgis.QGIS_VERSION_INT < 31000, 'Memory layer does not work well with 3.4')
def test_filter_by_polygon_filter(self):
""" Test the generation of filter by polygon. """
polygon = QgsVectorLayer('Polygon?field=id:integer&field=groups:string', 'polygon', 'memory')
Expand Down

0 comments on commit 5e34554

Please sign in to comment.