Skip to content
Merged
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
.pytest_cache
/data
/build
*.egg-info
dist
venv
output
Expand Down
14 changes: 11 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# CHANGELOG


## v5.5.0-rc.1 (2025-02-13)


## v5.4.3 (2025-01-26)


Expand All @@ -11,6 +14,11 @@
- **deps**: Trigger semantic
([`ac4ddd7`](https://github.com/Geode-solutions/OpenGeodeWeb-Back/commit/ac4ddd70936ec159945b4b6864d97c664ce8b1b7))

### Features

- **polyhedron attributes**: New route and tests
([`fb433b8`](https://github.com/Geode-solutions/OpenGeodeWeb-Back/commit/fb433b8f6f804f0022f13c9e720733d4daca4722))


## v5.4.2 (2025-01-22)

Expand Down Expand Up @@ -159,7 +167,7 @@

BREAKING CHANGE: functions moved to utils_functions.py

### BREAKING CHANGES
### Breaking Changes

- **ping route**: Functions moved to utils_functions.py

Expand Down Expand Up @@ -675,7 +683,7 @@ BREAKING CHANGE: geode_objects_output_extensions returns a dict

BREAKING CHANGE: geode_objects_output_extensions takes data as input

### BREAKING CHANGES
### Breaking Changes

- **dependencies**: Geode_objects_output_extensions takes data as input

Expand Down Expand Up @@ -718,7 +726,7 @@ BREAMING CHANGE: geode_objects_output_extensions needs data input

BREAKING CHANGE: Arguments changement(array to json schema)

### BREAKING CHANGES
### Breaking Changes

- **validate_request**: Arguments changement(array to json schema)

Expand Down
2 changes: 1 addition & 1 deletion app.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
""" Packages """
"""Packages"""

import os

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "OpenGeodeWeb-Back"
version = "5.4.3"
version = "5.5.0-rc.1"
dynamic = ["dependencies"]
authors = [
{ name="Geode-solutions", email="[email protected]" },
Expand Down
43 changes: 36 additions & 7 deletions src/opengeodeweb_back/routes/blueprint_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ def save_viewable_file():
DATA_FOLDER_PATH,
generated_id + "." + native_extension,
)
os.remove(os.path.join(UPLOAD_FOLDER, secure_filename))
object_type = geode_functions.get_object_type(
flask.request.json["input_geode_object"]
)
Expand Down Expand Up @@ -316,11 +317,10 @@ def create_point():
methods=vertex_attribute_names_json["methods"],
)
def vertex_attribute_names():

UPLOAD_FOLDER = flask.current_app.config["UPLOAD_FOLDER"]
DATA_FOLDER_PATH = flask.current_app.config["DATA_FOLDER_PATH"]
utils_functions.validate_request(flask.request, vertex_attribute_names_json)
file_absolute_path = os.path.join(
UPLOAD_FOLDER, werkzeug.utils.secure_filename(flask.request.json["filename"])
DATA_FOLDER_PATH, werkzeug.utils.secure_filename(flask.request.json["filename"])
)
data = geode_functions.load(
flask.request.json["input_geode_object"], file_absolute_path
Expand All @@ -347,11 +347,10 @@ def vertex_attribute_names():
methods=polygon_attribute_names_json["methods"],
)
def polygon_attribute_names():

UPLOAD_FOLDER = flask.current_app.config["UPLOAD_FOLDER"]
utils_functions.validate_request(flask.request, vertex_attribute_names_json)
DATA_FOLDER_PATH = flask.current_app.config["DATA_FOLDER_PATH"]
utils_functions.validate_request(flask.request, polygon_attribute_names_json)
file_absolute_path = os.path.join(
UPLOAD_FOLDER, werkzeug.utils.secure_filename(flask.request.json["filename"])
DATA_FOLDER_PATH, werkzeug.utils.secure_filename(flask.request.json["filename"])
)
data = geode_functions.load(
flask.request.json["input_geode_object"], file_absolute_path
Expand All @@ -366,6 +365,36 @@ def polygon_attribute_names():
)


with open(
os.path.join(schemas, "polyhedron_attribute_names.json"),
"r",
) as file:
polyhedron_attribute_names_json = json.load(file)


@routes.route(
polyhedron_attribute_names_json["route"],
methods=polyhedron_attribute_names_json["methods"],
)
def polyhedron_attribute_names():
DATA_FOLDER_PATH = flask.current_app.config["DATA_FOLDER_PATH"]
utils_functions.validate_request(flask.request, vertex_attribute_names_json)
file_absolute_path = os.path.join(
DATA_FOLDER_PATH, werkzeug.utils.secure_filename(flask.request.json["filename"])
)
data = geode_functions.load(
flask.request.json["input_geode_object"], file_absolute_path
)
polyhedron_attribute_names = data.polyhedron_attribute_manager().attribute_names()

return flask.make_response(
{
"polyhedron_attribute_names": polyhedron_attribute_names,
},
200,
)


with open(
os.path.join(schemas, "ping.json"),
"r",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"route": "/polyhedron_attribute_names",
"methods": ["POST"],
"type": "object",
"properties": {
"input_geode_object": {
"type": "string"
},
"filename": {
"type": "string"
}
},
"required": ["input_geode_object", "filename"],
"additionalProperties": false
}
22 changes: 22 additions & 0 deletions tests/polyhedron_attribute.vtu
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0"?>
<VTKFile type="UnstructuredGrid" version="1.0" byte_order="LittleEndian" header_type="UInt32" compressor="vtkZLibDataCompressor">
<UnstructuredGrid>
<Piece NumberOfPoints="11" NumberOfCells="4">
<PointData>
<DataArray type="Float64" Name="toto_on_vertices" format="ascii" NumberOfComponents="1" RangeMin="1" RangeMax="11">1 2 3 4 5 6 7 8 9 10 11 </DataArray>
<DataArray type="Float64" Name="points" format="ascii" NumberOfComponents="3" RangeMin="0" RangeMax="2">0 0 0 1 0 0 2 1 0 1 2 0 0 2 0 0 0 1 1 0 1 2 1 1 1 2 1 0 2 1 1 1 2 </DataArray>
</PointData>
<Points>
<DataArray type="Float64" Name="Points" format="ascii" NumberOfComponents="3" RangeMin="0" RangeMax="2">0 0 0 1 0 0 2 1 0 1 2 0 0 2 0 0 0 1 1 0 1 2 1 1 1 2 1 0 2 1 1 1 2 </DataArray>
</Points>
<CellData>
<DataArray type="Float64" Name="toto_on_polyhedra" format="ascii" NumberOfComponents="1" RangeMin="3" RangeMax="6">3 4 5 6 </DataArray>
</CellData>
<Cells>
<DataArray type="Int64" Name="connectivity" format="ascii" RangeMin="0" RangeMax="10">0 1 3 4 5 6 8 9 1 2 3 6 7 8 5 6 8 9 10 6 7 8 10 </DataArray>
<DataArray type="Int64" Name="offsets" format="ascii" RangeMin="0" RangeMax="11">8 14 19 23 </DataArray>
<DataArray type="UInt8" Name="types" format="ascii" RangeMin="1" RangeMax="42">12 13 14 10 </DataArray>
</Cells>
</Piece>
</UnstructuredGrid>
</VTKFile>
62 changes: 60 additions & 2 deletions tests/test_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

# Third party imports
from werkzeug.datastructures import FileStorage
from flask import app

# Local application imports
from src.opengeodeweb_back import test_utils
Expand Down Expand Up @@ -174,12 +175,22 @@ def test_vertex_attribute_names(client):
)
assert response.status_code == 201

response = client.post(
"/save_viewable_file",
json={
"input_geode_object": "PolygonalSurface3D",
"filename": "vertex_attribute.vtp",
},
)
assert response.status_code == 200
native_file_name = response.json["native_file_name"]

route = f"/vertex_attribute_names"

def get_full_data():
return {
"input_geode_object": "PolygonalSurface3D",
"filename": "vertex_attribute.vtp",
"filename": native_file_name,
}

# Normal test with filename 'vertex_attribute.vtp'
Expand All @@ -200,12 +211,22 @@ def test_polygon_attribute_names(client):
)
assert response.status_code == 201

response = client.post(
"/save_viewable_file",
json={
"input_geode_object": "PolygonalSurface3D",
"filename": "polygon_attribute.vtp",
},
)
assert response.status_code == 200
native_file_name = response.json["native_file_name"]

route = f"/polygon_attribute_names"

def get_full_data():
return {
"input_geode_object": "PolygonalSurface3D",
"filename": "polygon_attribute.vtp",
"filename": native_file_name,
}

# Normal test with filename 'vertex_attribute.vtp'
Expand All @@ -220,6 +241,43 @@ def get_full_data():
test_utils.test_route_wrong_params(client, route, get_full_data)


def test_polyhedron_attribute_names(client):
response = client.put(
f"/upload_file",
data={"file": FileStorage(open("./tests/polyhedron_attribute.vtu", "rb"))},
)
assert response.status_code == 201

response = client.post(
"/save_viewable_file",
json={
"input_geode_object": "HybridSolid3D",
"filename": "polyhedron_attribute.vtu",
},
)
assert response.status_code == 200
native_file_name = response.json["native_file_name"]

route = f"/polyhedron_attribute_names"

def get_full_data():
return {
"input_geode_object": "HybridSolid3D",
"filename": native_file_name,
}

# Normal test with filename 'vertex_attribute.vtp'
response = client.post(route, json=get_full_data())
assert response.status_code == 200
polygon_attribute_names = response.json["polyhedron_attribute_names"]
assert type(polygon_attribute_names) is list
for polygon_attribute_name in polygon_attribute_names:
assert type(polygon_attribute_name) is str

# Test all params
test_utils.test_route_wrong_params(client, route, get_full_data)


def test_create_point(client):
route = f"/create_point"
get_full_data = lambda: {"x": 1, "y": 2, "z": 3}
Expand Down