Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 13 additions & 3 deletions stac_check/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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]

Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion tests/test_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down