Skip to content

Commit 8ef59bd

Browse files
authored
Merge pull request #92 from stac-utils/pv/validate-response-matches-aoi
add aoi result validation
2 parents 042c6da + e4efff5 commit 8ef59bd

File tree

6 files changed

+218
-45
lines changed

6 files changed

+218
-45
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
- Validation that using the `ids` parameter does not override all other parameters, as was the behavior
1313
prior to v1.0.0-beta.1.
14+
- Add validation that the footprint of each Item returned from Item Search intersects the AOI provided
15+
through the intersect parameter
16+
- Add validation that Collection has items link relation
1417

1518
### Changed
1619

README.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,18 +94,31 @@ Options:
9494
--root-url TEXT STAC API Root / Landing Page URL [required]
9595
--post / --no-post Test all validations with POST method for
9696
requests in addition to GET
97+
--collection TEXT The name of the collection to use for some
98+
tests.
99+
--geometry TEXT The geometry to use for intersection tests.
97100
--conformance [core|browseable|item-search|features|collections|children]
98101
Conformance class URIs to validate
99102
[required]
100103
--help Show this message and exit.
101104
```
102105

106+
Conformance classes item-search, features, and collections require the `--collection` parameter with the id of a
107+
collection to run some tests on.
108+
109+
Conformance class `item-search` requires `--geometry` with a GeoJSON geometry that returns some items for
110+
the specified collection.
111+
103112
Example:
104113

105114
```
106115
stac-api-validator \
107-
--root-url https://cmr.earthdata.nasa.gov/stac/LARC_ASDC \
108-
--conformance core --conformance item-search --conformance features
116+
--root-url https://planetarycomputer.microsoft.com/api/stac/v1/ \
117+
--conformance core \
118+
--conformance item-search \
119+
--conformance features \
120+
--collection sentinel-2-l2a \
121+
--geometry '{"type": "Polygon", "coordinates": [[[100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0]]]}'
109122
```
110123

111124
Example output:

poetry.lock

Lines changed: 53 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ requests = "^2.28.1"
2323
pystac = {extras = ["orjson"], version = "^1.6.1"}
2424
jsonschema = "^4.16.0"
2525
PyYAML = "6.0"
26+
Shapely = "1.8.4"
2627

2728
[tool.poetry.dev-dependencies]
2829
Pygments = ">=2.10.0"
@@ -77,6 +78,11 @@ pretty = true
7778
show_column_numbers = true
7879
show_error_codes = true
7980
show_error_context = true
81+
#ignore_missing_imports = true
82+
83+
[[tool.mypy.overrides]]
84+
module = ["shapely.geometry"]
85+
ignore_missing_imports = true
8086

8187
[build-system]
8288
requires = ["poetry-core>=1.0.0"]

src/stac_api_validator/__main__.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import sys
44
import traceback
55
from typing import List
6+
from typing import Optional
67

78
import click
89

@@ -28,9 +29,12 @@
2829
)
2930
@click.option(
3031
"--collection",
31-
required=True,
3232
help="The name of the collection to use for some tests.",
3333
)
34+
@click.option(
35+
"--geometry",
36+
help="The geometry to use for intersection tests.",
37+
)
3438
@click.option(
3539
"--conformance",
3640
"conformance_classes",
@@ -54,7 +58,8 @@ def main(
5458
root_url: str,
5559
post: bool,
5660
conformance_classes: List[str],
57-
collection: str,
61+
collection: Optional[str],
62+
geometry: Optional[str],
5863
) -> int:
5964
"""STAC API Validator."""
6065

@@ -64,7 +69,11 @@ def main(
6469

6570
try:
6671
(warnings, errors) = validate_api(
67-
root_url, post, conformance_classes, collection
72+
root_url=root_url,
73+
post=post,
74+
conformance_classes=conformance_classes,
75+
collection=collection,
76+
geometry=geometry,
6877
)
6978
except Exception as e:
7079
print(f"Failed.\nError {root_url}: {type(e)} {str(e)}")

0 commit comments

Comments
 (0)