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, diff --git a/src/qgis_geonode/gui/geonode_source_select_provider.py b/src/qgis_geonode/gui/geonode_source_select_provider.py index 25069b2c..d36b45ff 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() @@ -431,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