Skip to content

Commit 5919746

Browse files
wip cells atributes
1 parent 496f7ff commit 5919746

File tree

10 files changed

+79
-0
lines changed

10 files changed

+79
-0
lines changed

opengeodeweb_back_schemas.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,24 @@
406406
],
407407
"additionalProperties": false
408408
},
409+
"cell_attribute_names": {
410+
"$id": "opengeodeweb_back/cell_attribute_names",
411+
"route": "/cell_attribute_names",
412+
"methods": [
413+
"POST"
414+
],
415+
"type": "object",
416+
"properties": {
417+
"id": {
418+
"type": "string",
419+
"minLength": 1
420+
}
421+
},
422+
"required": [
423+
"id"
424+
],
425+
"additionalProperties": false
426+
},
409427
"allowed_objects": {
410428
"$id": "opengeodeweb_back/allowed_objects",
411429
"route": "/allowed_objects",

src/opengeodeweb_back/geode_objects/geode_grid2d.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Standard library imports
22
from __future__ import annotations
3+
from abc import abstractmethod
34

45
# Third party imports
56
import opengeode as og
@@ -24,3 +25,7 @@ def builder(self) -> None:
2425

2526
def inspect(self) -> None:
2627
return None
28+
29+
@abstractmethod
30+
def cell_attribute_manager(self) -> og.AttributeManager: ...
31+

src/opengeodeweb_back/geode_objects/geode_grid3d.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Standard library imports
22
from __future__ import annotations
3+
from abc import abstractmethod
34

45
# Third party imports
56
import opengeode as og
@@ -24,3 +25,6 @@ def builder(self) -> None:
2425

2526
def inspect(self) -> None:
2627
return None
28+
29+
@abstractmethod
30+
def cell_attribute_manager(self) -> og.AttributeManager: ...

src/opengeodeweb_back/geode_objects/geode_light_regular_grid2d.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,6 @@ def save_light_viewable(self, filename_without_extension: str) -> str:
6767

6868
def vertex_attribute_manager(self) -> og.AttributeManager:
6969
return self.light_regular_grid.grid_vertex_attribute_manager()
70+
71+
def cell_attribute_manager(self) -> og.AttributeManager:
72+
return self.light_regular_grid.cell_attribute_manager()

src/opengeodeweb_back/geode_objects/geode_light_regular_grid3d.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,6 @@ def save_light_viewable(self, filename_without_extension: str) -> str:
6767

6868
def vertex_attribute_manager(self) -> og.AttributeManager:
6969
return self.light_regular_grid.grid_vertex_attribute_manager()
70+
71+
def cell_attribute_manager(self) -> og.AttributeManager:
72+
return self.light_regular_grid.cell_attribute_manager()

src/opengeodeweb_back/geode_objects/geode_regulard_grid2d.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
# Local application imports
1010
from .types import GeodeMeshType
1111
from .geode_surface_mesh2d import GeodeSurfaceMesh2D
12+
from .geode_grid2d import GeodeGrid2D
1213

1314

1415
class GeodeRegularGrid2D(GeodeSurfaceMesh2D):

src/opengeodeweb_back/routes/blueprint_routes.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
from opengeodeweb_back.geode_objects import geode_objects
2222
from opengeodeweb_back.geode_objects.types import geode_object_type
2323
from opengeodeweb_back.geode_objects.geode_mesh import GeodeMesh
24+
from opengeodeweb_back.geode_objects.geode_grid2d import GeodeGrid2D
25+
from opengeodeweb_back.geode_objects.geode_grid3d import GeodeGrid3D
2426
from opengeodeweb_back.geode_objects.geode_surface_mesh2d import GeodeSurfaceMesh2D
2527
from opengeodeweb_back.geode_objects.geode_surface_mesh3d import GeodeSurfaceMesh3D
2628
from opengeodeweb_back.geode_objects.geode_solid_mesh3d import GeodeSolidMesh3D
@@ -267,6 +269,25 @@ def vertex_attribute_names() -> flask.Response:
267269
200,
268270
)
269271

272+
@routes.route(
273+
schemas_dict["cell_attribute_names"]["route"],
274+
methods=schemas_dict["cell_attribute_names"]["methods"],
275+
)
276+
def cell_attribute_names() -> flask.Response:
277+
json_data = utils_functions.validate_request(
278+
flask.request, schemas_dict["cell_attribute_names"]
279+
)
280+
params = schemas.PolygonAttributeNames.from_dict(json_data)
281+
geode_object = geode_functions.load_geode_object(params.id)
282+
if not isinstance(geode_object, GeodeGrid2D | GeodeGrid3D):
283+
flask.abort(500, f"{params.id} is not a GeodeGrid")
284+
cell_attribute_names = geode_object.cell_attribute_manager().attribute_names()
285+
return flask.make_response(
286+
{
287+
"cell_attribute_names": cell_attribute_names,
288+
},
289+
200,
290+
)
270291

271292
@routes.route(
272293
schemas_dict["polygon_attribute_names"]["route"],

src/opengeodeweb_back/routes/schemas/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@
1212
from .geographic_coordinate_systems import *
1313
from .geode_objects_and_output_extensions import *
1414
from .export_project import *
15+
from .cell_attribute_names import *
1516
from .allowed_objects import *
1617
from .allowed_files import *
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"route": "/cell_attribute_names",
3+
"methods": ["POST"],
4+
"type": "object",
5+
"properties": {
6+
"id": {
7+
"type": "string",
8+
"minLength": 1
9+
}
10+
},
11+
"required": ["id"],
12+
"additionalProperties": false
13+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from dataclasses_json import DataClassJsonMixin
2+
from dataclasses import dataclass
3+
4+
5+
@dataclass
6+
class CellAttributeNames(DataClassJsonMixin):
7+
def __post_init__(self) -> None:
8+
print(self, flush=True)
9+
10+
id: str

0 commit comments

Comments
 (0)