Skip to content

Commit 3b0c16e

Browse files
mattiagiupponigiohappy
authored andcommitted
Fix 3dtile handling
1 parent a135441 commit 3b0c16e

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

geonode/upload/handlers/base.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ def delete_resource(instance):
309309
def _get_execution_request_object(self, execution_id: str):
310310
return ExecutionRequest.objects.filter(exec_id=execution_id).first()
311311

312-
def create_asset_and_link(self, resource, files, action=None, asset_name=None):
312+
def create_asset_and_link(self, resource, files, action=None, asset_name=None, asset_type=None, **kwargs):
313313
if not files:
314314
return
315315
asset_name = asset_name or (
@@ -318,10 +318,11 @@ def create_asset_and_link(self, resource, files, action=None, asset_name=None):
318318
asset, _ = create_asset_and_link(
319319
resource=resource,
320320
owner=resource.owner,
321-
files=files.values(),
321+
files=list(set(files.values())),
322322
title=asset_name,
323-
asset_type=Path(files.get("base_file")).suffix.replace(".", ""),
323+
asset_type=asset_type or Path(files.get("base_file")).suffix.replace(".", ""),
324324
clone_files=True,
325+
**kwargs,
325326
)
326327
return asset
327328

geonode/upload/handlers/tiles3d/handler.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,17 @@ def import_resource(self, files: dict, execution_id: str, **kwargs) -> str:
228228
)
229229
return layer_name, alternate, execution_id
230230

231+
def pre_processing(self, files, execution_id, **kwargs):
232+
_data, execution_id = super().pre_processing(files, execution_id, **kwargs)
233+
# removing the content file from the files location
234+
if "content_file" in _data["files"]:
235+
_data["files"].pop("content_file")
236+
237+
_exec_obj = orchestrator.get_execution_object(execution_id)
238+
orchestrator.update_execution_request_obj(_exec_obj, {"input_params": _data})
239+
240+
return _data, execution_id
241+
231242
def create_geonode_resource(
232243
self,
233244
layer_name: str,
@@ -236,13 +247,16 @@ def create_geonode_resource(
236247
resource_type: Dataset = ...,
237248
asset=None,
238249
):
239-
# we want just the tileset.json as location of the asset
240-
# asset.location = [path for path in asset.location if path.endswith(".json")]
241-
# asset.save()
242250
exec_obj = orchestrator.get_execution_object(execution_id)
243251

244252
resource = super().create_geonode_resource(layer_name, alternate, execution_id, ResourceBase, asset)
245-
asset = self.create_asset_and_link(resource, files=exec_obj.input_params["files"], action=exec_obj.action)
253+
asset = self.create_asset_and_link(
254+
resource,
255+
files=exec_obj.input_params["files"],
256+
action=exec_obj.action,
257+
asset_type="3dtiles",
258+
extension="3dtiles",
259+
)
246260

247261
if isinstance(asset, LocalAsset):
248262
# fixing-up bbox for the 3dtile object

0 commit comments

Comments
 (0)