Skip to content

Commit

Permalink
🐛 fix grid table creation and 🎨 remove warning for eo collections
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelrpl committed Oct 28, 2022
1 parent b97814c commit cbca999
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 55 deletions.
2 changes: 1 addition & 1 deletion bdc_catalog/models/grid_ref_sys.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def create_geometry_table(cls, table_name: str, features: Iterable[Feature], sri
**opts
)

inspector = inspect(grid_table)
inspector = inspect(db.engine)
if inspector.has_table(table_name, schema=BDC_CATALOG_SCHEMA):
raise RuntimeError(f'Table {table_name} already exists')

Expand Down
2 changes: 2 additions & 0 deletions bdc_catalog/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ def create_collection(name: str, version: Any, bands: list,
band_obj.mime_type = MimeType.query().filter(MimeType.name == value).first()
elif prop == 'resolution_unit':
band_obj.resolution_unit = ResolutionUnit.query().filter(ResolutionUnit.name == value).first()
elif prop == 'metadata': # Special case to avoid internal SQLAlchemy metadata prop
band_obj.metadata_ = value
else:
setattr(band_obj, prop, value)
db.session.add(band_obj)
Expand Down
159 changes: 105 additions & 54 deletions examples/fixtures/sentinel-2.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,15 @@
"scale": 0.0001,
"data_type": "int16",
"mime_type": "image/jp2",
"resolution_x": 60.0,
"resolution_y": 60.0,
"resolution_unit": "Meter",
"center_wavelength": 0.4427,
"full_width_half_max": 0.021
"metadata": {
"eo": {
"resolution_x": 60.0,
"resolution_y": 60.0,
"center_wavelength": 0.4427,
"full_width_half_max": 0.021
}
},
"resolution_unit": "Meter"
},
{
"name": "B02",
Expand All @@ -38,11 +42,14 @@
"scale": 0.0001,
"data_type": "int16",
"mime_type": "image/jp2",
"resolution_x": 10.0,
"resolution_y": 10.0,
"resolution_unit": "Meter",
"center_wavelength": 0.4924,
"full_width_half_max": 0.066
"metadata": {
"eo": {
"resolution_x": 10.0,
"resolution_y": 10.0,
"center_wavelength": 0.4924,
"full_width_half_max": 0.066
}
}
},
{
"name": "B03",
Expand All @@ -54,11 +61,15 @@
"scale": 0.0001,
"data_type": "int16",
"mime_type": "image/jp2",
"resolution_x": 10.0,
"resolution_y": 10.0,
"resolution_unit": "Meter",
"center_wavelength": 0.5598,
"full_width_half_max": 0.036
"metadata": {
"eo": {
"resolution_x": 10.0,
"resolution_y": 10.0,
"center_wavelength": 0.5598,
"full_width_half_max": 0.036
}
}
},
{
"name": "B04",
Expand All @@ -70,11 +81,15 @@
"scale": 0.0001,
"data_type": "int16",
"mime_type": "image/jp2",
"resolution_x": 10.0,
"resolution_y": 10.0,
"resolution_unit": "Meter",
"center_wavelength": 0.6646,
"full_width_half_max": 0.031
"metadata": {
"eo": {
"resolution_x": 10.0,
"resolution_y": 10.0,
"center_wavelength": 0.6646,
"full_width_half_max": 0.031
}
}
},
{
"name": "B05",
Expand All @@ -86,11 +101,15 @@
"scale": 0.0001,
"data_type": "int16",
"mime_type": "image/jp2",
"resolution_x": 20.0,
"resolution_y": 20.0,
"resolution_unit": "Meter",
"center_wavelength": 0.7041,
"full_width_half_max": 0.015
"metadata": {
"eo": {
"resolution_x": 20.0,
"resolution_y": 20.0,
"center_wavelength": 0.7041,
"full_width_half_max": 0.015
}
}
},
{
"name": "B06",
Expand All @@ -102,11 +121,15 @@
"scale": 0.0001,
"data_type": "int16",
"mime_type": "image/jp2",
"resolution_x": 20.0,
"resolution_y": 20.0,
"resolution_unit": "Meter",
"center_wavelength": 0.7405,
"full_width_half_max": 0.015
"metadata": {
"eo": {
"resolution_x": 20.0,
"resolution_y": 20.0,
"center_wavelength": 0.7405,
"full_width_half_max": 0.015
}
}
},
{
"name": "B07",
Expand All @@ -118,11 +141,15 @@
"scale": 0.0001,
"data_type": "int16",
"mime_type": "image/jp2",
"resolution_x": 20.0,
"resolution_y": 20.0,
"resolution_unit": "Meter",
"center_wavelength": 0.7828,
"full_width_half_max": 0.020
"metadata": {
"eo": {
"resolution_x": 20.0,
"resolution_y": 20.0,
"center_wavelength": 0.7828,
"full_width_half_max": 0.020
}
}
},
{
"name": "B08",
Expand All @@ -134,11 +161,15 @@
"scale": 0.0001,
"data_type": "int16",
"mime_type": "image/jp2",
"resolution_x": 10.0,
"resolution_y": 10.0,
"resolution_unit": "Meter",
"center_wavelength": 0.8328,
"full_width_half_max": 0.106
"metadata": {
"eo": {
"resolution_x": 10.0,
"resolution_y": 10.0,
"center_wavelength": 0.8328,
"full_width_half_max": 0.106
}
}
},
{
"name": "B8A",
Expand All @@ -150,11 +181,15 @@
"scale": 0.0001,
"data_type": "int16",
"mime_type": "image/jp2",
"resolution_x": 20.0,
"resolution_y": 20.0,
"resolution_unit": "Meter",
"center_wavelength": 0.8647,
"full_width_half_max": 0.021
"metadata": {
"eo": {
"resolution_x": 20.0,
"resolution_y": 20.0,
"center_wavelength": 0.8647,
"full_width_half_max": 0.021
}
}
},
{
"name": "B09",
Expand All @@ -166,11 +201,15 @@
"scale": 0.0001,
"data_type": "int16",
"mime_type": "image/jp2",
"resolution_x": 60.0,
"resolution_y": 60.0,
"resolution_unit": "Meter",
"center_wavelength": 0.9451,
"full_width_half_max": 0.020
"metadata": {
"eo": {
"resolution_x": 60.0,
"resolution_y": 60.0,
"center_wavelength": 0.9451,
"full_width_half_max": 0.020
}
}
},
{
"name": "B10",
Expand All @@ -182,11 +221,15 @@
"scale": 0.0001,
"data_type": "int16",
"mime_type": "image/jp2",
"resolution_x": 60.0,
"resolution_y": 60.0,
"resolution_unit": "Meter",
"center_wavelength": 0.3735,
"full_width_half_max": 0.031
"metadata": {
"eo": {
"resolution_x": 60.0,
"resolution_y": 60.0,
"center_wavelength": 0.3735,
"full_width_half_max": 0.031
}
}
},
{
"name": "B11",
Expand All @@ -198,11 +241,15 @@
"scale": 0.0001,
"data_type": "int16",
"mime_type": "image/jp2",
"resolution_x": 20.0,
"resolution_y": 20.0,
"resolution_unit": "Meter",
"center_wavelength": 1.6137,
"full_width_half_max": 0.091
"metadata": {
"eo": {
"resolution_x": 20.0,
"resolution_y": 20.0,
"center_wavelength": 1.6137,
"full_width_half_max": 0.091
}
}
},
{
"name": "B12",
Expand All @@ -214,11 +261,15 @@
"scale": 0.0001,
"data_type": "int16",
"mime_type": "image/jp2",
"resolution_x": 20.0,
"resolution_y": 20.0,
"resolution_unit": "Meter",
"center_wavelength": 2.2024,
"full_width_half_max": 0.175
"metadata": {
"eo": {
"resolution_x": 20.0,
"resolution_y": 20.0,
"center_wavelength": 2.2024,
"full_width_half_max": 0.175
}
}
}
],
"items": [
Expand Down

0 comments on commit cbca999

Please sign in to comment.