Skip to content
92 changes: 92 additions & 0 deletions opengeodeweb_back_schemas.json
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,98 @@
"required": [],
"additionalProperties": false
},
"model_component_vertex_attribute_names": {
"$id": "opengeodeweb_back/model_component_vertex_attribute_names",
"route": "/model_component_vertex_attribute_names",
"methods": [
"POST"
],
"type": "object",
"properties": {
"id": {
"type": "string",
"minLength": 1
},
"component_id": {
"type": "string",
"minLength": 1
}
},
"required": [
"id",
"component_id"
],
"additionalProperties": false
},
"model_component_polyhedron_attribute_names": {
"$id": "opengeodeweb_back/model_component_polyhedron_attribute_names",
"route": "/model_component_polyhedron_attribute_names",
"methods": [
"POST"
],
"type": "object",
"properties": {
"id": {
"type": "string",
"minLength": 1
},
"component_id": {
"type": "string",
"minLength": 1
}
},
"required": [
"id",
"component_id"
],
"additionalProperties": false
},
"model_component_polygon_attribute_names": {
"$id": "opengeodeweb_back/model_component_polygon_attribute_names",
"route": "/model_component_polygon_attribute_names",
"methods": [
"POST"
],
"type": "object",
"properties": {
"id": {
"type": "string",
"minLength": 1
},
"component_id": {
"type": "string",
"minLength": 1
}
},
"required": [
"id",
"component_id"
],
"additionalProperties": false
},
"model_component_edge_attribute_names": {
"$id": "opengeodeweb_back/model_component_edge_attribute_names",
"route": "/model_component_edge_attribute_names",
"methods": [
"POST"
],
"type": "object",
"properties": {
"id": {
"type": "string",
"minLength": 1
},
"component_id": {
"type": "string",
"minLength": 1
}
},
"required": [
"id",
"component_id"
],
"additionalProperties": false
},
"missing_files": {
"$id": "opengeodeweb_back/missing_files",
"route": "/missing_files",
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,3 @@ werkzeug==3.1.8
# flask
# flask-cors

opengeodeweb-microservice==1.*,>=1.1.3
111 changes: 110 additions & 1 deletion src/opengeodeweb_back/routes/blueprint_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import time
import shutil
import math
from typing import Any
from typing import Any, Union, get_args

# Third party imports
import flask
Expand All @@ -24,13 +24,24 @@
from opengeodeweb_back.routes import schemas
from opengeodeweb_back.geode_objects import geode_objects
from opengeodeweb_back.geode_objects.geode_mesh import GeodeMesh
from opengeodeweb_back.geode_objects.geode_model import GeodeModel
from opengeodeweb_back.geode_objects.geode_graph import GeodeGraph
from opengeodeweb_back.geode_objects.geode_grid2d import GeodeGrid2D
from opengeodeweb_back.geode_objects.geode_grid3d import GeodeGrid3D
from opengeodeweb_back.geode_objects.geode_surface_mesh2d import GeodeSurfaceMesh2D
from opengeodeweb_back.geode_objects.geode_surface_mesh3d import GeodeSurfaceMesh3D
from opengeodeweb_back.geode_objects.geode_solid_mesh3d import GeodeSolidMesh3D

ComponentMesh = Union[
og.Corner2D,
og.Corner3D,
og.Line2D,
og.Line3D,
og.Surface2D,
og.Surface3D,
og.Block3D,
]

routes = flask.Blueprint("routes", __name__, url_prefix="/opengeodeweb_back")

schemas_dict = get_schemas_dict(os.path.join(os.path.dirname(__file__), "schemas"))
Expand Down Expand Up @@ -387,6 +398,104 @@ def edge_attribute_names() -> flask.Response:
)


@routes.route(
schemas_dict["model_component_vertex_attribute_names"]["route"],
methods=schemas_dict["model_component_vertex_attribute_names"]["methods"],
)
def model_component_vertex_attribute_names() -> flask.Response:
json_data = utils_functions.validate_request(
flask.request, schemas_dict["model_component_vertex_attribute_names"]
)
params = schemas.ModelComponentVertexAttributeNames.from_dict(json_data)
geode_object = geode_functions.load_geode_object(params.id)
if not isinstance(geode_object, GeodeModel):
flask.abort(400, f"{params.id} is not a GeodeModel")
component = geode_object.component(og.uuid(params.component_id))
if not isinstance(component, get_args(ComponentMesh)):
flask.abort(400, f"{params.component_id} is not a valid ComponentMesh")
mesh = component.mesh()
attribute_manager = mesh.vertex_attribute_manager()
return flask.make_response(
{"attributes": attributes_metadata(attribute_manager)},
200,
)


@routes.route(
schemas_dict["model_component_edge_attribute_names"]["route"],
methods=schemas_dict["model_component_edge_attribute_names"]["methods"],
)
def model_component_edge_attribute_names() -> flask.Response:
json_data = utils_functions.validate_request(
flask.request, schemas_dict["model_component_edge_attribute_names"]
)
params = schemas.ModelComponentEdgeAttributeNames.from_dict(json_data)
geode_object = geode_functions.load_geode_object(params.id)
if not isinstance(geode_object, GeodeModel):
flask.abort(400, f"{params.id} is not a GeodeModel")
component = geode_object.component(og.uuid(params.component_id))
if not isinstance(component, get_args(ComponentMesh)):
flask.abort(400, f"{params.component_id} is not a valid ComponentMesh")
mesh = component.mesh()
if not hasattr(mesh, "edge_attribute_manager"):
flask.abort(400, "Component does not have edges")
attribute_manager = mesh.edge_attribute_manager()
return flask.make_response(
{"attributes": attributes_metadata(attribute_manager)},
200,
)


@routes.route(
schemas_dict["model_component_polygon_attribute_names"]["route"],
methods=schemas_dict["model_component_polygon_attribute_names"]["methods"],
)
def model_component_polygon_attribute_names() -> flask.Response:
json_data = utils_functions.validate_request(
flask.request, schemas_dict["model_component_polygon_attribute_names"]
)
params = schemas.ModelComponentPolygonAttributeNames.from_dict(json_data)
geode_object = geode_functions.load_geode_object(params.id)
if not isinstance(geode_object, GeodeModel):
flask.abort(400, f"{params.id} is not a GeodeModel")
component = geode_object.component(og.uuid(params.component_id))
if not isinstance(component, get_args(ComponentMesh)):
flask.abort(400, f"{params.component_id} is not a valid ComponentMesh")
mesh = component.mesh()
if not hasattr(mesh, "polygon_attribute_manager"):
flask.abort(400, "Component does not have polygons")
attribute_manager = mesh.polygon_attribute_manager()
return flask.make_response(
{"attributes": attributes_metadata(attribute_manager)},
200,
)


@routes.route(
schemas_dict["model_component_polyhedron_attribute_names"]["route"],
methods=schemas_dict["model_component_polyhedron_attribute_names"]["methods"],
)
def model_component_polyhedron_attribute_names() -> flask.Response:
json_data = utils_functions.validate_request(
flask.request, schemas_dict["model_component_polyhedron_attribute_names"]
)
params = schemas.ModelComponentPolyhedronAttributeNames.from_dict(json_data)
geode_object = geode_functions.load_geode_object(params.id)
if not isinstance(geode_object, GeodeModel):
flask.abort(400, f"{params.id} is not a GeodeModel")
component = geode_object.component(og.uuid(params.component_id))
if not isinstance(component, get_args(ComponentMesh)):
flask.abort(400, f"{params.component_id} is not a valid ComponentMesh")
mesh = component.mesh()
if not hasattr(mesh, "polyhedron_attribute_manager"):
flask.abort(400, "Component does not have polyhedra")
attribute_manager = mesh.polyhedron_attribute_manager()
return flask.make_response(
{"attributes": attributes_metadata(attribute_manager)},
200,
)


@routes.route(
schemas_dict["ping"]["route"],
methods=schemas_dict["ping"]["methods"],
Expand Down
4 changes: 4 additions & 0 deletions src/opengeodeweb_back/routes/schemas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
from .polyhedron_attribute_names import *
from .polygon_attribute_names import *
from .ping import *
from .model_component_vertex_attribute_names import *
from .model_component_polyhedron_attribute_names import *
from .model_component_polygon_attribute_names import *
from .model_component_edge_attribute_names import *
from .missing_files import *
from .kill import *
from .inspect_file import *
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"route": "/model_component_edge_attribute_names",
"methods": ["POST"],
"type": "object",
"properties": {
"id": {
"type": "string",
"minLength": 1
},
"component_id": {
"type": "string",
"minLength": 1
}
},
"required": ["id", "component_id"],
"additionalProperties": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from dataclasses_json import DataClassJsonMixin
from dataclasses import dataclass


@dataclass
class ModelComponentEdgeAttributeNames(DataClassJsonMixin):
def __post_init__(self) -> None:
print(self, flush=True)

component_id: str
id: str
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"route": "/model_component_polygon_attribute_names",
"methods": ["POST"],
"type": "object",
"properties": {
"id": {
"type": "string",
"minLength": 1
},
"component_id": {
"type": "string",
"minLength": 1
}
},
"required": ["id", "component_id"],
"additionalProperties": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from dataclasses_json import DataClassJsonMixin
from dataclasses import dataclass


@dataclass
class ModelComponentPolygonAttributeNames(DataClassJsonMixin):
def __post_init__(self) -> None:
print(self, flush=True)

component_id: str
id: str
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"route": "/model_component_polyhedron_attribute_names",
"methods": ["POST"],
"type": "object",
"properties": {
"id": {
"type": "string",
"minLength": 1
},
"component_id": {
"type": "string",
"minLength": 1
}
},
"required": ["id", "component_id"],
"additionalProperties": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from dataclasses_json import DataClassJsonMixin
from dataclasses import dataclass


@dataclass
class ModelComponentPolyhedronAttributeNames(DataClassJsonMixin):
def __post_init__(self) -> None:
print(self, flush=True)

component_id: str
id: str
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"route": "/model_component_vertex_attribute_names",
"methods": ["POST"],
"type": "object",
"properties": {
"id": {
"type": "string",
"minLength": 1
},
"component_id": {
"type": "string",
"minLength": 1
}
},
"required": ["id", "component_id"],
"additionalProperties": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from dataclasses_json import DataClassJsonMixin
from dataclasses import dataclass


@dataclass
class ModelComponentVertexAttributeNames(DataClassJsonMixin):
def __post_init__(self) -> None:
print(self, flush=True)

component_id: str
id: str
Loading
Loading