Skip to content

Commit

Permalink
[Fixes #233] [GPKG] must specify native_crs
Browse files Browse the repository at this point in the history
  • Loading branch information
mattiagiupponi committed Apr 17, 2024
1 parent 269ec25 commit 9b80331
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions importer/handlers/common/vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,8 @@ def import_resource(self, files: dict, execution_id: str, **kwargs) -> str:
Internally will call the steps required to import the
data inside the geonode_data database
"""
layers = self.get_ogr2ogr_driver().Open(files.get("base_file"))
all_layers = self.get_ogr2ogr_driver().Open(files.get("base_file"))
layers = self._select_valid_layers(all_layers)
# for the moment we skip the dyanamic model creation
layer_count = len(layers)
logger.info(f"Total number of layers available: {layer_count}")
Expand All @@ -320,7 +321,7 @@ def import_resource(self, files: dict, execution_id: str, **kwargs) -> str:
# start looping on the layers available
for index, layer in enumerate(layers, start=1):
layer_name = self.fixup_name(layer.GetName())

should_be_overwritten = _exec.input_params.get(
"overwrite_existing_layer"
)
Expand Down Expand Up @@ -397,6 +398,17 @@ def import_resource(self, files: dict, execution_id: str, **kwargs) -> str:
raise e
return

def _select_valid_layers(self, all_layers):
layers = []
for layer in all_layers:
try:
self.identify_authority(layer)
layers.append(layer)
except:
logger.error(f"The following layer {layer.GetName()} does not have a Coordinate Reference System (CRS) and will be skipped.")
pass
return layers

def find_alternate_by_dataset(self, _exec_obj, layer_name, should_be_overwritten):
workspace = DataPublisher(None).workspace
dataset_available = Dataset.objects.filter(
Expand Down

0 comments on commit 9b80331

Please sign in to comment.