Skip to content

Commit f6b3ddd

Browse files
Merge branch 'next' into feat/get_vertex_attributes
2 parents 51d4427 + 67ac0a2 commit f6b3ddd

File tree

6 files changed

+112
-3
lines changed

6 files changed

+112
-3
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# CHANGELOG
22

33

4+
## v5.4.0-rc.2 (2024-11-28)
5+
6+
47
## v5.4.0-rc.1 (2024-11-27)
58

69
### Features
@@ -11,6 +14,15 @@
1114
- **routes**: Create point3D route
1215
([`88867c6`](https://github.com/Geode-solutions/OpenGeodeWeb-Back/commit/88867c629b8fbf2648faaf328f5adb3452b727c2))
1316

17+
- **polygon attribute**: New route/schemas/test/data
18+
([`e50f3ff`](https://github.com/Geode-solutions/OpenGeodeWeb-Back/commit/e50f3ffeb7706e7b3a8fea49c303cd91b6cc1bce))
19+
20+
- **vertex attribute**: New route/schemas/test/data
21+
([`11865dd`](https://github.com/Geode-solutions/OpenGeodeWeb-Back/commit/11865dd747b8e5501f17dbf5b70ad8052cbdef05))
22+
23+
- **test_utils**: Automatic schema validation
24+
([`7dbb3fc`](https://github.com/Geode-solutions/OpenGeodeWeb-Back/commit/7dbb3fc4d1901d4d050249203d3bd84bc2d6b5c1))
25+
1426

1527
## v5.3.2 (2024-11-08)
1628

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
55

66
[project]
77
name = "OpenGeodeWeb-Back"
8-
version = "5.4.0-rc.1"
8+
version = "5.4.0-rc.2"
99
dynamic = ["dependencies"]
1010
authors = [
1111
{ name="Geode-solutions", email="[email protected]" },

src/opengeodeweb_back/routes/blueprint_routes.py

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ def vertex_attribute_names():
326326
flask.request.json["input_geode_object"], file_absolute_path
327327
)
328328
vertex_attribute_names = data.vertex_attribute_manager().attribute_names()
329-
print(f"vertex_attribute_names: {vertex_attribute_names}", flush=True)
329+
330330
return flask.make_response(
331331
{
332332
"vertex_attribute_names": vertex_attribute_names,
@@ -335,6 +335,37 @@ def vertex_attribute_names():
335335
)
336336

337337

338+
with open(
339+
os.path.join(schemas, "polygon_attribute_names.json"),
340+
"r",
341+
) as file:
342+
polygon_attribute_names_json = json.load(file)
343+
344+
345+
@routes.route(
346+
polygon_attribute_names_json["route"],
347+
methods=polygon_attribute_names_json["methods"],
348+
)
349+
def polygon_attribute_names():
350+
351+
UPLOAD_FOLDER = flask.current_app.config["UPLOAD_FOLDER"]
352+
utils_functions.validate_request(flask.request, vertex_attribute_names_json)
353+
file_absolute_path = os.path.join(
354+
UPLOAD_FOLDER, werkzeug.utils.secure_filename(flask.request.json["filename"])
355+
)
356+
data = geode_functions.load(
357+
flask.request.json["input_geode_object"], file_absolute_path
358+
)
359+
polygon_attribute_names = data.polygon_attribute_manager().attribute_names()
360+
361+
return flask.make_response(
362+
{
363+
"polygon_attribute_names": polygon_attribute_names,
364+
},
365+
200,
366+
)
367+
368+
338369
with open(
339370
os.path.join(schemas, "ping.json"),
340371
"r",
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"route": "/polygon_attribute_names",
3+
"methods": ["POST"],
4+
"type": "object",
5+
"properties": {
6+
"input_geode_object": {
7+
"type": "string"
8+
},
9+
"filename": {
10+
"type": "string"
11+
}
12+
},
13+
"required": ["input_geode_object", "filename"],
14+
"additionalProperties": false
15+
}

tests/polygon_attribute.vtp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0"?>
2+
<VTKFile type="PolyData" version="1.0" byte_order="LittleEndian" header_type="UInt32" compressor="vtkZLibDataCompressor">
3+
<PolyData>
4+
<Piece NumberOfPoints="14" NumberOfPolys="14">
5+
<PointData>
6+
<DataArray type="Float64" Name="geode_implicit_attribute" format="ascii" NumberOfComponents="1" RangeMin="-5.03872538" RangeMax="2.56229305">-5.03873 -3.56819 -3.29213 -0.379219 0.386424 -1.97966 -0.310684 1.50807 1.80048 2.25409 2.56229 0.235826 -0.162775 -1.4339 </DataArray>
7+
<DataArray type="Float64" Name="points" format="ascii" NumberOfComponents="2" RangeMin="1.10000002" RangeMax="10">1.1 4.5 3 5 1.2 6 3 8 5 8.2 5 5.5 1.1 8.3 2 10 4 10 6 10 7 10 5.9 7.7 6.1 7 5.8 5.8 </DataArray>
8+
<DataArray type="Float64" Name="unique vertices" format="ascii" NumberOfComponents="1" RangeMin="32" RangeMax="45">32 33 36 37 42 34 38 39 40 41 43 44 45 35 </DataArray>
9+
<DataArray type="Float64" Name="gradient_3d_attribute" format="ascii" NumberOfComponents="3" RangeMin="0" RangeMax="1.2239517">0.441452 1.06497 0 0.509268 1.09401 0 0.451134 1.22395 0 0.244789 1.03019 0 0.306431 0.898241 0 0.520398 0.854144 0 0.0558145 0.936744 0 0.17577 1.03026 0 0.179188 0.94981 0 0.242737 0.863881 0 0.312089 0.886676 0 0.328556 0.855054 0 nan nan nan 0.353402 0.897993 0 </DataArray>
10+
</PointData>
11+
<Points>
12+
<DataArray type="Float64" Name="Points" format="ascii" NumberOfComponents="3" RangeMin="1.1000000000000001" RangeMax="10">1.1 4.5 0 3 5 0 1.2 6 0 3 8 0 5 8.2 0 5 5.5 0 1.1 8.3 0 2 10 0 4 10 0 6 10 0 7 10 0 5.9 7.7 0 6.1 7 0 5.8 5.8 0 </DataArray>
13+
</Points>
14+
<CellData>
15+
<DataArray type="Float64" Name="triangle_vertices" format="ascii" NumberOfComponents="3" RangeMin="0" RangeMax="13">0 1 2 1 3 2 1 4 3 1 5 4 2 3 6 3 7 6 3 8 7 3 4 8 4 9 8 4 10 9 4 11 10 4 12 11 5 12 4 5 13 12 </DataArray>
16+
<DataArray type="Float64" Name="triangle_adjacents" format="ascii" NumberOfComponents="3" RangeMin="0" RangeMax="4.2949673e+09">4.29497e+09 1 4.29497e+09 2 4 0 3 7 1 4.29497e+09 12 2 1 5 4.29497e+09 6 4.29497e+09 4 7 4.29497e+09 5 2 8 6 9 4.29497e+09 7 10 4.29497e+09 8 11 4.29497e+09 9 12 4.29497e+09 10 13 11 3 4.29497e+09 4.29497e+09 12 </DataArray>
17+
<DataArray type="Float64" Name="implicit_on_polygons" format="ascii" NumberOfComponents="1" RangeMin="-3.96634865" RangeMax="1.73426831">-3.96635 -2.41318 -1.18699 -1.72048 -1.32735 0.272721 0.976443 0.602562 1.48033 1.73427 1.06151 0.153159 -0.585337 -1.19211 </DataArray>
18+
</CellData>
19+
<Polys>
20+
<DataArray type="Int64" Name="connectivity" format="ascii" RangeMin="0" RangeMax="13">0 1 2 1 3 2 1 4 3 1 5 4 2 3 6 3 7 6 3 8 7 3 4 8 4 9 8 4 10 9 4 11 10 4 12 11 5 12 4 5 13 12 </DataArray>
21+
<DataArray type="Int64" Name="offsets" format="ascii" RangeMin="0" RangeMax="14">3 6 9 12 15 18 21 24 27 30 33 36 39 42 </DataArray>
22+
</Polys>
23+
</Piece>
24+
</PolyData>
25+
</VTKFile>

tests/test_routes.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@ def test_vertex_attribute_names(client):
172172
assert response.status_code == 201
173173

174174
route = f"/vertex_attribute_names"
175-
176175
def get_full_data():
177176
return {
178177
"input_geode_object": "PolygonalSurface3D",
@@ -190,6 +189,33 @@ def get_full_data():
190189
test_utils.test_route_wrong_params(client, route, get_full_data)
191190

192191

192+
def test_polygon_attribute_names(client):
193+
response = client.put(
194+
f"/upload_file",
195+
data={"file": FileStorage(open("./tests/polygon_attribute.vtp", "rb"))},
196+
)
197+
assert response.status_code == 201
198+
199+
route = f"/polygon_attribute_names"
200+
201+
def get_full_data():
202+
return {
203+
"input_geode_object": "PolygonalSurface3D",
204+
"filename": "polygon_attribute.vtp",
205+
}
206+
207+
# Normal test with filename 'vertex_attribute.vtp'
208+
response = client.post(route, json=get_full_data())
209+
assert response.status_code == 200
210+
polygon_attribute_names = response.json["polygon_attribute_names"]
211+
assert type(polygon_attribute_names) is list
212+
for polygon_attribute_name in polygon_attribute_names:
213+
assert type(polygon_attribute_name) is str
214+
215+
# Test all params
216+
test_utils.test_route_wrong_params(client, route, get_full_data)
217+
218+
193219
def test_create_point(client):
194220
route = f"/create_point"
195221
get_full_data = lambda: {"x": 1, "y": 2, "z": 3}

0 commit comments

Comments
 (0)