Skip to content

Commit

Permalink
Add more layer metadata (#65)
Browse files Browse the repository at this point in the history
* Fix is_raster in common layer

* Add more metadata to input layer
  • Loading branch information
zamuzakki committed Sep 9, 2024
1 parent b312d60 commit eccf6e4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 5 additions & 1 deletion django_project/cplus_api/tasks/sync_default_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,16 @@ def read_metadata(
res_y = abs(transform[4])
crs = dataset.crs
nodata = dataset.nodata
unit = dataset.crs.units_factor[0]
unit = "m" if unit == "metre" else unit

metadata = {
"is_raster": get_layer_type(self.file['Key']) == 0,
"crs": str(crs),
"resolution": [res_x, res_y],
"no_data": nodata
"unit": unit,
"nodata_value": nodata,
"is_geographic": dataset.crs.is_geographic
}
if not self.input_layer.name:
self.input_layer.name = os.path.basename(self.file['Key'])
Expand Down
4 changes: 3 additions & 1 deletion django_project/cplus_api/tests/test_sync_default_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@ def base_run(self):
self.assertTrue(input_layers.exists())
metadata = {
'crs': 'EPSG:32735',
'no_data': -9999.0,
'nodata_value': -9999.0,
'is_raster': True,
'resolution': [19.676449999999022, 19.676448888890445],
'is_geographic': False,
'unit': 'm'
}
self.assertEqual(input_layer.name, 'test_pathway_2.tif')
self.assertEqual(input_layer.description, 'test_pathway_2.tif')
Expand Down

0 comments on commit eccf6e4

Please sign in to comment.