Skip to content

Commit 1279555

Browse files
committed
fix KeyError: 'bbox' #104
1 parent 8d5097e commit 1279555

File tree

4 files changed

+105
-1
lines changed

4 files changed

+105
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ The format is (loosely) based on [Keep a Changelog](http://keepachangelog.com/)
1212

1313
### Changed
1414

15+
### Fixed
16+
17+
- Prevented `KeyError` in `check_unlocated()` when `bbox` is unset ([#104](https://github.com/stac-utils/stac-check/pull/119))
18+
1519
### Updated
1620

1721
- Updated stac-validator to v3.6.0 ([#120](https://github.com/stac-utils/stac-check/pull/120))
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
{
2+
"stac_version": "1.0.0",
3+
"stac_extensions": [],
4+
"type": "Feature",
5+
"id": "20201211_223832_CS2",
6+
"geometry": null,
7+
"properties": {
8+
"title": "Core Item",
9+
"description": "A sample STAC Item that includes examples of all common metadata",
10+
"datetime": null,
11+
"start_datetime": "2020-12-11T22:38:32.125Z",
12+
"end_datetime": "2020-12-11T22:38:32.327Z",
13+
"created": "2020-12-12T01:48:13.725Z",
14+
"updated": "2020-12-12T01:48:13.725Z",
15+
"platform": "cool_sat1",
16+
"instruments": [
17+
"cool_sensor_v1"
18+
],
19+
"constellation": "ion",
20+
"mission": "collection 5624",
21+
"gsd": 0.512
22+
},
23+
"collection": "simple-collection",
24+
"links": [
25+
{
26+
"rel": "collection",
27+
"href": "./collection.json",
28+
"type": "application/json",
29+
"title": "Simple Example Collection"
30+
},
31+
{
32+
"rel": "root",
33+
"href": "./collection.json",
34+
"type": "application/json",
35+
"title": "Simple Example Collection"
36+
},
37+
{
38+
"rel": "parent",
39+
"href": "./collection.json",
40+
"type": "application/json",
41+
"title": "Simple Example Collection"
42+
},
43+
{
44+
"rel": "alternate",
45+
"type": "text/html",
46+
"href": "http://remotedata.io/catalog/20201211_223832_CS2/index.html",
47+
"title": "HTML version of this STAC Item"
48+
}
49+
],
50+
"assets": {
51+
"analytic": {
52+
"href": "https://storage.googleapis.com/open-cogs/stac-examples/20201211_223832_CS2_analytic.tif",
53+
"type": "image/tiff; application=geotiff; profile=cloud-optimized",
54+
"title": "4-Band Analytic",
55+
"roles": [
56+
"data"
57+
]
58+
},
59+
"thumbnail": {
60+
"href": "https://storage.googleapis.com/open-cogs/stac-examples/20201211_223832_CS2.jpg",
61+
"title": "Thumbnail",
62+
"type": "image/jpg",
63+
"roles": [
64+
"thumbnail"
65+
]
66+
},
67+
"visual": {
68+
"href": "https://storage.googleapis.com/open-cogs/stac-examples/20201211_223832_CS2.tif",
69+
"type": "image/tiff; application=geotiff; profile=cloud-optimized",
70+
"title": "3-Band Visual",
71+
"roles": [
72+
"visual"
73+
]
74+
},
75+
"udm": {
76+
"href": "https://storage.googleapis.com/open-cogs/stac-examples/20201211_223832_CS2_analytic_udm.tif",
77+
"title": "Unusable Data Mask",
78+
"type": "image/tiff; application=geotiff;"
79+
},
80+
"json-metadata": {
81+
"href": "http://remotedata.io/catalog/20201211_223832_CS2/extended-metadata.json",
82+
"title": "Extended Metadata",
83+
"type": "application/json",
84+
"roles": [
85+
"metadata"
86+
]
87+
},
88+
"ephemeris": {
89+
"href": "http://cool-sat.com/catalog/20201211_223832_CS2/20201211_223832_CS2.EPH",
90+
"title": "Satellite Ephemeris Metadata"
91+
}
92+
}
93+
}

stac_check/lint.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,9 @@ def check_unlocated(self) -> bool:
437437
bool: True if the STAC item is unlocated, False otherwise.
438438
"""
439439
if "geometry" in self.data:
440-
return self.data["geometry"] is None and self.data["bbox"] is not None
440+
return (
441+
self.data.get("geometry") is None and self.data.get("bbox") is not None
442+
)
441443
else:
442444
return False
443445

tests/test_lint.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,11 @@ def test_unlocated_item():
272272
assert linter.check_unlocated() == True
273273
assert linter.check_geometry_null() == True
274274

275+
file = "sample_files/1.0.0/core-item-unlocated-null-bbox.json"
276+
linter = Linter(file)
277+
assert linter.check_unlocated() == False
278+
assert linter.check_geometry_null() == True
279+
275280

276281
def test_bloated_item():
277282
file = "sample_files/1.0.0/core-item-bloated.json"

0 commit comments

Comments
 (0)