From 647d3ed0615cb37ac23bb45cccfa23f346ce9856 Mon Sep 17 00:00:00 2001 From: Samweli Date: Tue, 11 May 2021 13:37:07 +0300 Subject: [PATCH 1/3] support of spatial extent filtering in api V2 --- src/qgis_geonode/apiclient/apiv2.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/qgis_geonode/apiclient/apiv2.py b/src/qgis_geonode/apiclient/apiv2.py index 95daa2f0..0029cc8f 100644 --- a/src/qgis_geonode/apiclient/apiv2.py +++ b/src/qgis_geonode/apiclient/apiv2.py @@ -29,6 +29,7 @@ class GeonodeApiV2Client(base.BaseGeonodeClient): models.ApiClientCapability.FILTER_BY_RESOURCE_TYPES, models.ApiClientCapability.FILTER_BY_TEMPORAL_EXTENT, models.ApiClientCapability.FILTER_BY_PUBLICATION_DATE, + models.ApiClientCapability.FILTER_BY_SPATIAL_EXTENT, ] @property @@ -96,13 +97,17 @@ def _build_search_query( "filter{date.lte}", search_params.publication_date_end.toString(QtCore.Qt.ISODate), ) - # TODO revisit once the support for spatial extent is available on - # GeoNode API V2 - if ( - search_params.spatial_extent is not None - and not search_params.spatial_extent.isNull() - ): - pass + + if search_params.spatial_extent is not None: + spatial_extent_value = ( + f"{search_params.spatial_extent.xMinimum()}," + f"{search_params.spatial_extent.yMinimum()}," + f"{search_params.spatial_extent.xMaximum()}," + f"{search_params.spatial_extent.yMaximum()}" + ) + + query.addQueryItem("extent", spatial_extent_value) + if search_params.layer_types is None: types = [ models.GeonodeResourceType.VECTOR_LAYER, From 26965dba55a5de778687ecf25aacb0e6ebbf4263 Mon Sep 17 00:00:00 2001 From: Samweli Date: Wed, 23 Jun 2021 17:37:08 +0300 Subject: [PATCH 2/3] update extent box base title --- src/qgis_geonode/gui/geonode_source_select_provider.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/qgis_geonode/gui/geonode_source_select_provider.py b/src/qgis_geonode/gui/geonode_source_select_provider.py index 25069b2c..61fa152b 100644 --- a/src/qgis_geonode/gui/geonode_source_select_provider.py +++ b/src/qgis_geonode/gui/geonode_source_select_provider.py @@ -202,6 +202,7 @@ def __init__(self, parent, fl, widgetMode): # ATTENTION: the order of initialization of the self.spatial_extent_box widget # is crucial here. Only call self.spatial_extent_box.setMapCanvas() after # having called self.spatial_extent_box.setOutputExtentFromCurrent() + self.spatial_extent_box.setTitleBase(tr("Spatial Extent")) epsg_4326 = qgis.core.QgsCoordinateReferenceSystem("EPSG:4326") self.spatial_extent_box.setOutputCrs(epsg_4326) map_canvas = iface.mapCanvas() From 75d0d169ca5b917bfebdef7a1fc3288110f6cca2 Mon Sep 17 00:00:00 2001 From: Samweli Date: Thu, 24 Jun 2021 00:32:35 +0300 Subject: [PATCH 3/3] set extent group box to be checkable --- .../gui/geonode_source_select_provider.py | 4 +++- src/qgis_geonode/ui/geonode_datasource_widget.ui | 13 +++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/qgis_geonode/gui/geonode_source_select_provider.py b/src/qgis_geonode/gui/geonode_source_select_provider.py index 61fa152b..d36b45ff 100644 --- a/src/qgis_geonode/gui/geonode_source_select_provider.py +++ b/src/qgis_geonode/gui/geonode_source_select_provider.py @@ -432,7 +432,9 @@ def search_geonode(self, reset_pagination: bool = False): if not pub_start.isNull() else None, publication_date_end=pub_end if not pub_end.isNull() else None, - spatial_extent=spatial_extent_epsg4326, + spatial_extent=spatial_extent_epsg4326 + if self.spatial_extent_box.isChecked() + else None, ) ) diff --git a/src/qgis_geonode/ui/geonode_datasource_widget.ui b/src/qgis_geonode/ui/geonode_datasource_widget.ui index ca41fb1d..927f9192 100644 --- a/src/qgis_geonode/ui/geonode_datasource_widget.ui +++ b/src/qgis_geonode/ui/geonode_datasource_widget.ui @@ -377,9 +377,18 @@ - Spatial Extent + Extent (current: none) + + + true + + + false + false + + true @@ -606,7 +615,7 @@ 0 0 708 - 366 + 226