Skip to content

Commit

Permalink
Merge pull request #80 from pblottiere/raster_layer_metadata_type
Browse files Browse the repository at this point in the history
Add data type and band counts metadata for raster layers
  • Loading branch information
pblottiere authored Sep 23, 2024
2 parents 1460ffe + 640af05 commit bcfa520
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
18 changes: 18 additions & 0 deletions docs/src/sandbox/raster/layers.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,26 @@ true
### List layers and get metadata

```` shell
# list layers
$ curl "http://localhost:5000/api/projects/my_project/layers?schema=my_schema"
["polygons","dem"]

# get metadata
$ curl "http://localhost:5000/api/projects/my_project/layers/dem?schema=my_schema"
{
"bands": 1,
"bbox": "18.6662979442000001 45.77670143760000343, 18.70359794419999844 45.81170143760000002",
"crs": "EPSG:4326",
"current_style": "default",
"data_type": "float32",
"name": "dem",
"source": "/dem.tif",
"styles": [
"default"
],
"type": "raster",
"valid": true
}
````


Expand Down
7 changes: 7 additions & 0 deletions qsa-api/qsa_api/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,9 @@ def layer(self, name: str) -> dict:

if layer.type() == Qgis.LayerType.Vector:
infos["geometry"] = QgsWkbTypes.displayString(layer.wkbType())
elif layer.type() == Qgis.LayerType.Raster:
infos["bands"] = layer.bandCount()
infos["data_type"] = layer.dataProvider().dataType(1).name.lower()

infos["source"] = layer.source()
infos["crs"] = layer.crs().authid()
Expand Down Expand Up @@ -320,6 +323,10 @@ def exists(self) -> bool:
)
projects = storage.listProjects(uri)

# necessary step if the project has been created without QSA
if self.name in projects:
self._qgis_projects_dir().mkdir(parents=True, exist_ok=True)

return self.name in projects and self._qgis_projects_dir().exists()

def create(self, author: str) -> (bool, str):
Expand Down

0 comments on commit bcfa520

Please sign in to comment.