diff --git a/CHANGELOG.md b/CHANGELOG.md index a825f77..3f5f55c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ The format is (loosely) based on [Keep a Changelog](http://keepachangelog.com/) ## [v0.1.3] - 2022-01-23 - ### Added - Check for bloated metadata, too many fields in properties +- Check for geometry field, recommend that STAC not be used for non-spatial data ### Changed - Changed bloated links check to a boolean to mirror bloated metadata diff --git a/stac_check/lint.py b/stac_check/lint.py index b863718..d4e29bf 100644 --- a/stac_check/lint.py +++ b/stac_check/lint.py @@ -34,7 +34,8 @@ def __post_init__(self): self.bloated_metadata = self.get_bloated_metadata() self.recursive_error_msg = "" self.datetime_null = self.check_datetime() - self.unlocated = self.check_geometry() + self.unlocated = self.check_unlocated() + self.geometry = self.check_geometry() self.validate_all = self.recursive_validation(self.load_data(self.item)) self.object_id = self.return_id() self.file_name = self.get_file_name() @@ -138,10 +139,14 @@ def check_datetime(self): else: return False - def check_geometry(self): + def check_unlocated(self): if "geometry" in self.data: return self.data["geometry"] is None and self.data["bbox"] is not None + def check_geometry(self): + if "geometry" in self.data: + return self.data["geometry"] is not None + def get_file_name(self): return os.path.basename(self.item).split('.')[0] @@ -193,7 +198,12 @@ def create_best_practices_msg(self): # best practices - check unlocated items to make sure bbox field is not set if self.unlocated: - string_1 = f" Unlocated item. Please avoid setting the bbox field when goemetry is set to null" + string_1 = f" Unlocated item. Please avoid setting the bbox field when geometry is set to null" + best_practices.extend([string_1, ""]) + + # best practices - recommend items have a geometry + if not self.geometry and self.asset_type == "ITEM": + string_1 = f" All items should have a geometry field. STAC is not meant for non-spatial data" best_practices.extend([string_1, ""]) # check to see if there are too many links diff --git a/tests/test_lint.py b/tests/test_lint.py index 7bb6dbb..2414772 100644 --- a/tests/test_lint.py +++ b/tests/test_lint.py @@ -129,11 +129,12 @@ def test_unlocated_item(): file = "sample_files/1.0.0/core-item-unlocated.json" linter = Linter(file) assert linter.unlocated == True + assert linter.geometry == False def test_bloated_item(): file = "sample_files/1.0.0/core-item-bloated.json" linter = Linter(file) - + assert linter.bloated_metadata == True assert len(linter.data["properties"]) > 20