Skip to content

Commit 7621952

Browse files
committed
Make --geometry optional for item-search conformance class
1 parent aab780c commit 7621952

File tree

2 files changed

+28
-27
lines changed

2 files changed

+28
-27
lines changed

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,10 @@ The conformance class validations to run are selected with the `--conformance` p
6666
can be used more than once to specify multiple conformance classes to validate. The `STAC API - Core` conformance
6767
class will always be validated, even if not specified.
6868

69-
If `item-search`, `collections`, and/or `features` are specified, the `--collection` and `--geometry` parameters must also
70-
be specified. The `--collection` parameter specifies the name of a collection to use for some of the validations.
71-
The `--geometry` should specify an AOI over which there are between 100 and 20,000 results for the collection (more
69+
If `item-search`, `collections`, and/or `features` are specified, the `--collection` parameter must also
70+
be set. It specifies the name of a collection to use for some of the validations.
71+
The `--geometry` parameter should also be set to perform intersection tests.
72+
It should specify an AOI over which there are between 100 and 20,000 results for the collection (more
7273
results means longer time to run).
7374

7475
## Features
@@ -127,7 +128,7 @@ Options:
127128
Conformance classes item-search, features, and collections require the `--collection` parameter with the id of a
128129
collection to run some tests on.
129130

130-
Conformance class `item-search` requires `--geometry` with a GeoJSON geometry that returns some items for
131+
Conformance class `item-search` supports `--geometry` with a GeoJSON geometry that returns some items for
131132
the specified collection.
132133

133134
Example:

src/stac_api_validator/validations.py

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -531,10 +531,9 @@ def validate_core_landing_page_body(
531531
)
532532
return False
533533
if geometry is None:
534-
logger.fatal(
535-
" Item Search configured for validation, but `--geometry` parameter not specified"
534+
logger.warning(
535+
" Item Search configured for validation, but `--geometry` parameter not specified. Intersection tests will not be run"
536536
)
537-
return False
538537

539538
if "children" in conformance_classes and not any(
540539
cc_children_regex.fullmatch(x) for x in conforms_to
@@ -677,7 +676,7 @@ def validate_api(
677676
conforms_to=conforms_to,
678677
warnings=warnings,
679678
errors=errors,
680-
geometry=geometry, # type:ignore
679+
geometry=geometry,
681680
conformance_classes=ccs_to_validate,
682681
r_session=r_session,
683682
validate_pagination=validate_pagination,
@@ -1108,8 +1107,7 @@ def validate_features(
11081107
open_assets_urls: bool = True,
11091108
) -> None:
11101109
if not geometry:
1111-
errors += f"[{Context.FEATURES}] Geometry parameter required for running Features validations."
1112-
return
1110+
warnings += f"[{Context.FEATURES}] Geometry parameter required for running Features validations."
11131111

11141112
if not collection:
11151113
errors += f"[{Context.FEATURES}] Collection parameter required for running Features validations."
@@ -1358,7 +1356,7 @@ def validate_item_search(
13581356
conforms_to: List[str],
13591357
warnings: Warnings,
13601358
errors: Errors,
1361-
geometry: str,
1359+
geometry: Optional[str],
13621360
conformance_classes: List[str],
13631361
r_session: Session,
13641362
validate_pagination: bool,
@@ -1430,14 +1428,15 @@ def validate_item_search(
14301428
validate_item_search_collections(
14311429
search_url, collections_url, methods, errors, r_session
14321430
)
1433-
validate_item_search_intersects(
1434-
search_url=search_url,
1435-
collection=collection,
1436-
methods=methods,
1437-
errors=errors,
1438-
geometry=geometry,
1439-
r_session=r_session,
1440-
)
1431+
if geometry is not None:
1432+
validate_item_search_intersects(
1433+
search_url=search_url,
1434+
collection=collection,
1435+
methods=methods,
1436+
errors=errors,
1437+
geometry=geometry,
1438+
r_session=r_session,
1439+
)
14411440

14421441
if validate_pagination:
14431442
validate_item_pagination(
@@ -2747,7 +2746,7 @@ def validate_item_pagination(
27472746
root_url: str,
27482747
search_url: str,
27492748
collection: Optional[str],
2750-
geometry: str,
2749+
geometry: Optional[str],
27512750
methods: Set[Method],
27522751
errors: Errors,
27532752
use_pystac_client: bool,
@@ -2888,14 +2887,15 @@ def validate_item_pagination(
28882887
if len(items) > len({item["id"] for item in items}):
28892888
errors += f"[{context}] POST pagination - duplicate items returned from paginating items"
28902889

2891-
search = client.search(
2892-
method="POST", collections=[collection], intersects=geometry
2893-
)
2894-
if len(list(take(20000, search.items_as_dicts()))) == 20000:
2895-
errors += (
2896-
f"[{context}] POST pagination - paged through 20,000 results. This could mean the last page "
2897-
"of results references itself, or your collection and geometry combination has too many results."
2890+
if geometry is not None:
2891+
search = client.search(
2892+
method="POST", collections=[collection], intersects=geometry
28982893
)
2894+
if len(list(take(20000, search.items_as_dicts()))) == 20000:
2895+
errors += (
2896+
f"[{context}] POST pagination - paged through 20,000 results. This could mean the last page "
2897+
"of results references itself, or your collection and geometry combination has too many results."
2898+
)
28992899
except Exception as e:
29002900
errors += f"pystac-client threw exception while testing pagination {e}"
29012901
elif collection is not None:

0 commit comments

Comments
 (0)