diff --git a/.env_dev b/.env_dev index d37591416fc..2f3879a695d 100644 --- a/.env_dev +++ b/.env_dev @@ -37,9 +37,9 @@ GEODATABASE_URL=postgis://geonode:geonode@localhost:5432/geonode_data GEONODE_DB_CONN_MAX_AGE=0 GEONODE_DB_CONN_TOUT=5 DEFAULT_BACKEND_DATASTORE=datastore -BROKER_URL=amqp://admin:admin@localhost:5672// +BROKER_URL=amqp://guest:guest@localhost:5672// CELERY_BEAT_SCHEDULER=celery.beat:PersistentScheduler -ASYNC_SIGNALS=False +ASYNC_SIGNALS=True SITEURL=http://localhost:8000/ diff --git a/geonode/upload/handlers/tiles3d/handler.py b/geonode/upload/handlers/tiles3d/handler.py index 434b567f018..c80511b38b1 100755 --- a/geonode/upload/handlers/tiles3d/handler.py +++ b/geonode/upload/handlers/tiles3d/handler.py @@ -82,8 +82,7 @@ def can_handle(_data) -> bool: if not base: return False ext = base.split(".")[-1] if isinstance(base, str) else base.name.split(".")[-1] - input_filename = os.path.basename(base if isinstance(base, str) else base.name) - if ext in ["json"] and "tileset.json" in input_filename: + if ext in ["json"] and Tiles3DFileHandler.is_3dtiles_json(base): return True return False @@ -110,16 +109,7 @@ def is_valid(files, user, **kwargs): raise Invalid3DTilesException("Please remove the additional dots in the filename") try: - with open(_file, "r") as _readed_file: - _file = json.loads(_readed_file.read()) - # required key described in the specification of 3dtiles - # https://docs.ogc.org/cs/22-025r4/22-025r4.html#toc92 - is_valid = all(key in _file.keys() for key in ("asset", "geometricError", "root")) - - if not is_valid: - raise Invalid3DTilesException( - "The provided 3DTiles is not valid, some of the mandatory keys are missing. Mandatory keys are: 'asset', 'geometricError', 'root'" - ) + _file = Tiles3DFileHandler.is_3dtiles_json(_file) Tiles3DFileHandler.validate_3dtile_payload(payload=_file) @@ -128,6 +118,21 @@ def is_valid(files, user, **kwargs): return True + @staticmethod + def is_3dtiles_json(_file): + with open(_file, "r") as _readed_file: + _file = json.loads(_readed_file.read()) + # required key described in the specification of 3dtiles + # https://docs.ogc.org/cs/22-025r4/22-025r4.html#toc92 + is_valid = all(key in _file.keys() for key in ("asset", "geometricError", "root")) + + if not is_valid: + raise Invalid3DTilesException( + "The provided 3DTiles is not valid, some of the mandatory keys are missing. Mandatory keys are: 'asset', 'geometricError', 'root'" + ) + + return _file + @staticmethod def validate_3dtile_payload(payload): # if the keys are there, let's check if the mandatory child are there too @@ -216,7 +221,7 @@ def create_geonode_resource( asset=None, ): # we want just the tileset.json as location of the asset - asset.location = [path for path in asset.location if "tileset.json" in path] + asset.location = [path for path in asset.location if path.endswith(".json")] asset.save() resource = super().create_geonode_resource(layer_name, alternate, execution_id, ResourceBase, asset)