Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions opengeodeweb_back_schemas.json
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,24 @@
],
"additionalProperties": false
},
"edge_attribute_names": {
"$id": "opengeodeweb_back/edge_attribute_names",
"route": "/edge_attribute_names",
"methods": [
"POST"
],
"type": "object",
"properties": {
"id": {
"type": "string",
"minLength": 1
}
},
"required": [
"id"
],
"additionalProperties": false
},
"cell_attribute_names": {
"$id": "opengeodeweb_back/cell_attribute_names",
"route": "/cell_attribute_names",
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.2
# flask
# flask-cors

opengeodeweb-microservice==1.*,>=1.0.12
3 changes: 3 additions & 0 deletions src/opengeodeweb_back/geode_objects/geode_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,6 @@ def save_light_viewable(self, filename_without_extension: str) -> str:

def inspect(self) -> object:
return None

def edge_attribute_manager(self) -> og.AttributeManager:
return self.graph.edge_attribute_manager()
24 changes: 23 additions & 1 deletion src/opengeodeweb_back/routes/blueprint_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from opengeodeweb_back.geode_objects import geode_objects
from opengeodeweb_back.geode_objects.types import geode_object_type
from opengeodeweb_back.geode_objects.geode_mesh import GeodeMesh
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
Expand Down Expand Up @@ -292,7 +293,7 @@ def cell_attribute_names() -> flask.Response:
json_data = utils_functions.validate_request(
flask.request, schemas_dict["cell_attribute_names"]
)
params = schemas.PolygonAttributeNames.from_dict(json_data)
params = schemas.CellAttributeNames.from_dict(json_data)
geode_object = geode_functions.load_geode_object(params.id)
if not isinstance(geode_object, GeodeGrid2D | GeodeGrid3D):
flask.abort(400, f"{params.id} is not a GeodeGrid")
Expand Down Expand Up @@ -349,6 +350,27 @@ def polyhedron_attribute_names() -> flask.Response:
)


@routes.route(
schemas_dict["edge_attribute_names"]["route"],
methods=schemas_dict["edge_attribute_names"]["methods"],
)
def edge_attribute_names() -> flask.Response:
json_data = utils_functions.validate_request(
flask.request, schemas_dict["edge_attribute_names"]
)
params = schemas.EdgeAttributeNames.from_dict(json_data)
geode_object = geode_functions.load_geode_object(params.id)
if not isinstance(geode_object, GeodeGraph):
flask.abort(400, f"{params.id} does not have edges")
edge_attribute_names = geode_object.edge_attribute_manager().attribute_names()
return flask.make_response(
{
"edge_attribute_names": edge_attribute_names,
},
200,
)


@routes.route(
schemas_dict["ping"]["route"],
methods=schemas_dict["ping"]["methods"],
Expand Down
1 change: 1 addition & 0 deletions src/opengeodeweb_back/routes/schemas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from .geographic_coordinate_systems import *
from .geode_objects_and_output_extensions import *
from .export_project import *
from .edge_attribute_names import *
from .cell_attribute_names import *
from .allowed_objects import *
from .allowed_files import *
17 changes: 17 additions & 0 deletions src/opengeodeweb_back/routes/schemas/edge_attribute_names.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"route": "/edge_attribute_names",
"methods": [
"POST"
],
"type": "object",
"properties": {
"id": {
"type": "string",
"minLength": 1
}
},
"required": [
"id"
],
"additionalProperties": false
}
10 changes: 10 additions & 0 deletions src/opengeodeweb_back/routes/schemas/edge_attribute_names.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from dataclasses_json import DataClassJsonMixin
from dataclasses import dataclass


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

id: str
30 changes: 30 additions & 0 deletions tests/test_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
from opengeodeweb_back.geode_objects.geode_regular_grid2d import (
GeodeRegularGrid2D,
)
from opengeodeweb_back.geode_objects.geode_edged_curve3d import (
GeodeEdgedCurve3D,
)

base_dir = os.path.abspath(os.path.dirname(__file__))
data_dir = os.path.join(base_dir, "data")
Expand Down Expand Up @@ -326,6 +329,33 @@ def test_polyhedron_attribute_names(client: FlaskClient, test_id: str) -> None:
assert type(polyhedron_attribute_name) is str


def test_edge_attribute_names(client: FlaskClient, test_id: str) -> None:
route = f"/opengeodeweb_back/edge_attribute_names"

with client.application.app_context():
file = os.path.join(data_dir, "test.og_edc3d")
data = Data.create(
geode_object=GeodeEdgedCurve3D.geode_object_type(),
viewer_object=GeodeEdgedCurve3D.viewer_type(),
input_file=file,
)
data.native_file = file
session = get_session()
if session:
session.commit()

data_path = geode_functions.data_file_path(data.id, data.native_file)
os.makedirs(os.path.dirname(data_path), exist_ok=True)
assert os.path.exists(data_path), f"File not found at {data_path}"
response = client.post(route, json={"id": data.id})
print(response.get_json())
assert response.status_code == 200
edge_attribute_names = response.get_json()["edge_attribute_names"]
assert type(edge_attribute_names) is list
for edge_attribute_name in edge_attribute_names:
assert type(edge_attribute_name) is str


def test_database_uri_path(client: FlaskClient) -> None:
app = client.application
with app.app_context():
Expand Down