Skip to content

Commit 6033bf9

Browse files
committed
-Add external extensions to ExtractedDataValidator
-Validate external extensions against basic Open Geospatial Consortium (OGC) standards
1 parent 237ea18 commit 6033bf9

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/python_osw_validation/__init__.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,17 @@ def validate(self) -> ValidationResult:
159159
self.errors.append(f"Invalid {osw_file} geometries found, id's of invalid geometries: {set(invalid_geojson['_id'])}")
160160
return ValidationResult(False, self.errors)
161161

162+
# Validate OSW external extensions
163+
for file in validator.externalExtensions:
164+
file_path = os.path.join(file)
165+
extensionFile = gpd.read_file(file_path)
166+
invalid_geojson = extensionFile[extensionFile.is_valid==False]
167+
is_valid = len(invalid_geojson) == 0
168+
if not is_valid:
169+
zip_handler.remove_extracted_files()
170+
self.errors.append(f"Invalid geometries found in extension file {file}, list of invalid geometries: {invalid_geojson.to_json()}")
171+
return ValidationResult(False, self.errors)
172+
162173
return ValidationResult(True)
163174
except Exception as e:
164175
self.errors.append(f'Unable to validate: {e}')

src/python_osw_validation/extracted_data_validator.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ class ExtractedDataValidator:
66
def __init__(self, extracted_dir: str):
77
self.extracted_dir = extracted_dir
88
self.files = []
9+
self.externalExtensions = []
910
self.error = None
1011

1112
def is_valid(self) -> bool:
@@ -43,5 +44,8 @@ def is_valid(self) -> bool:
4344
if required_files:
4445
self.error = f'Missing required .geojson files: {", ".join(required_files)}.'
4546
return False
47+
48+
# Add OSW external extensions, GeoJSON files we know nothing about
49+
self.externalExtensions.extend([item for item in geojson_files if item not in self.files])
4650

4751
return True

0 commit comments

Comments
 (0)