File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed
src/python_osw_validation Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff 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 } ' )
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments