Skip to content

Commit d5e42eb

Browse files
committed
Finetune Parameter.spatial_extent docs and defaults
1 parent 47172cd commit d5e42eb

File tree

3 files changed

+35
-24
lines changed

3 files changed

+35
-24
lines changed

docs/udp.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ Some useful parameter helpers (class methods of the :py:class:`~openeo.api.proce
134134
- :py:meth:`Parameter.geojson() <openeo.api.process.Parameter.geojson>` to create
135135
a parameter for specifying a GeoJSON geometry.
136136
- :py:meth:`Parameter.spatial_extent() <openeo.api.process.Parameter.spatial_extent>` to create
137-
a spatial_extent parameter that is exactly the same as the corresponding parameter in `load_collection` and `load_stac`.
137+
a spatial_extent parameter that is exactly the same as the corresponding parameter in ``load_collection`` and ``load_stac``.
138138

139139

140140

openeo/api/process.py

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
import textwrap
34
import warnings
45
from typing import List, Optional, Union
56

@@ -279,23 +280,15 @@ def bounding_box(
279280
}
280281
return cls(name=name, description=description, schema=schema, **kwargs)
281282

282-
_spatial_extent_description = """Limits the data to process to the specified bounding box or polygons.
283-
284-
For raster data, the process loads the pixel into the data cube if the point at the pixel center intersects with the bounding box or any of the polygons (as defined in the Simple Features standard by the OGC).
285-
For vector data, the process loads the geometry into the data cube if the geometry is fully within the bounding box or any of the polygons (as defined in the Simple Features standard by the OGC). Empty geometries may only be in the data cube if no spatial extent has been provided.
286-
287-
Empty geometries are ignored.
288-
Set this parameter to null to set no limit for the spatial extent. """
289-
290283
@classmethod
291284
def spatial_extent(
292285
cls,
293286
name: str = "spatial_extent",
294-
description: str = _spatial_extent_description,
287+
description: Optional[str] = None,
295288
**kwargs,
296289
) -> Parameter:
297290
"""
298-
Helper to easily create a 'spatial_extent' parameter, which is compatible with the 'load_collection' argument of
291+
Helper to easily create a 'spatial_extent' parameter, which is compatible with the ``load_collection`` argument of
299292
the same name. This allows to conveniently create user-defined processes that can be applied to a bounding box and vector data
300293
for spatial filtering. It is also possible for users to set to null, and define spatial filtering using other processes.
301294
@@ -307,6 +300,26 @@ def spatial_extent(
307300
308301
.. versionadded:: 0.32.0
309302
"""
303+
if description is None:
304+
description = textwrap.dedent(
305+
"""
306+
Limits the data to process to the specified bounding box or polygons.
307+
308+
For raster data, the process loads the pixel into the data cube if the point
309+
at the pixel center intersects with the bounding box or any of the polygons
310+
(as defined in the Simple Features standard by the OGC).
311+
312+
For vector data, the process loads the geometry into the data cube if the geometry
313+
is fully within the bounding box or any of the polygons (as defined in the
314+
Simple Features standard by the OGC). Empty geometries may only be in the
315+
data cube if no spatial extent has been provided.
316+
317+
Empty geometries are ignored.
318+
319+
Set this parameter to null to set no limit for the spatial extent.
320+
"""
321+
).strip()
322+
310323
schema = [
311324
{
312325
"title": "Bounding Box",

tests/api/test_process.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -178,22 +178,20 @@ def test_parameter_reencode(kwargs, expected):
178178

179179
def test_parameter_spatial_extent():
180180
assert Parameter.spatial_extent().to_dict() == {
181-
"description": "Limits the data to process to the specified bounding box or "
182-
"polygons.\n"
181+
"description": "Limits the data to process to the specified bounding box or polygons.\n"
183182
"\n"
184-
"For raster data, the process loads the pixel into the data "
185-
"cube if the point at the pixel center intersects with the "
186-
"bounding box or any of the polygons (as defined in the Simple "
187-
"Features standard by the OGC).\n"
188-
"For vector data, the process loads the geometry into the data "
189-
"cube if the geometry is fully within the bounding box or any "
190-
"of the polygons (as defined in the Simple Features standard "
191-
"by the OGC). Empty geometries may only be in the data cube if "
192-
"no spatial extent has been provided.\n"
183+
"For raster data, the process loads the pixel into the data cube if the point\n"
184+
"at the pixel center intersects with the bounding box or any of the polygons \n"
185+
"(as defined in the Simple Features standard by the OGC).\n"
186+
"\n"
187+
"For vector data, the process loads the geometry into the data cube if the geometry \n"
188+
"is fully within the bounding box or any of the polygons (as defined in the \n"
189+
"Simple Features standard by the OGC). Empty geometries may only be in the \n"
190+
"data cube if no spatial extent has been provided.\n"
193191
"\n"
194192
"Empty geometries are ignored.\n"
195-
"Set this parameter to null to set no limit for the spatial "
196-
"extent. ",
193+
"\n"
194+
"Set this parameter to null to set no limit for the spatial extent.",
197195
"name": "spatial_extent",
198196
"schema": [
199197
{

0 commit comments

Comments
 (0)