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: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.pytest_cache
./data
/data
dist
venv
output
Expand Down
2 changes: 2 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[pytest]
addopts = --ignore=src/opengeodeweb_back/
32 changes: 16 additions & 16 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@ attrs==24.2.0
# via
# jsonschema
# referencing
blinker==1.8.2
blinker==1.9.0
# via flask
click==8.1.7
# via flask
flask[async]==3.0.3
flask[async]==3.1.0
# via
# -r requirements.in
# flask-cors
flask-cors==5.0.0
# via -r requirements.in
geode-background==8.7.0
geode-background==8.7.5
# via
# geode-explicit
# geode-implicit
# geode-simplex
geode-common==33.0.9
geode-common==33.1.3
# via
# -r requirements.in
# geode-background
Expand All @@ -35,26 +35,26 @@ geode-common==33.0.9
# geode-numerics
# geode-simplex
# geode-viewables
geode-conversion==6.0.14
geode-conversion==6.0.18
# via
# geode-explicit
# geode-implicit
geode-explicit==6.1.14
geode-explicit==6.1.17
# via
# -r requirements.in
# geode-implicit
geode-implicit==3.3.2
geode-implicit==3.3.5
# via -r requirements.in
geode-numerics==5.1.8
geode-numerics==5.2.0
# via
# -r requirements.in
# geode-implicit
# geode-simplex
geode-simplex==8.2.15
geode-simplex==8.2.18
# via
# -r requirements.in
# geode-implicit
geode-viewables==3.0.6
geode-viewables==3.0.8
# via -r requirements.in
itsdangerous==2.2.0
# via flask
Expand All @@ -68,7 +68,7 @@ markupsafe==3.0.2
# via
# jinja2
# werkzeug
opengeode-core==15.6.3
opengeode-core==15.6.7
# via
# -r requirements.in
# geode-background
Expand All @@ -83,23 +83,23 @@ opengeode-core==15.6.3
# opengeode-geosciencesio
# opengeode-inspector
# opengeode-io
opengeode-geosciences==8.1.1
opengeode-geosciences==8.2.0
# via
# -r requirements.in
# geode-implicit
# geode-viewables
# opengeode-geosciencesio
opengeode-geosciencesio==5.2.3
opengeode-geosciencesio==5.3.2
# via
# -r requirements.in
# geode-implicit
opengeode-inspector==6.1.12
opengeode-inspector==6.1.15
# via
# -r requirements.in
# geode-explicit
# geode-implicit
# geode-simplex
opengeode-io==7.0.5
opengeode-io==7.0.7
# via
# -r requirements.in
# geode-implicit
Expand All @@ -115,7 +115,7 @@ rpds-py==0.21.0
# referencing
typing-extensions==4.12.2
# via asgiref
werkzeug==3.1.2
werkzeug==3.1.3
# via
# -r requirements.in
# flask
5 changes: 5 additions & 0 deletions src/opengeodeweb_back/geode_objects.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
# Standard library imports

# Third party imports
import opengeode as og
import opengeode_io as og_io
import opengeode_inspector as og_inspector
import opengeode_geosciences as og_gs
import opengeode_geosciencesio as og_gs_io
import geode_viewables as g_v

# Local application imports


def geode_objects_dict():
return {
Expand Down
62 changes: 62 additions & 0 deletions src/opengeodeweb_back/routes/blueprint_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,68 @@ def create_point():
)


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


@routes.route(
vertex_attribute_names_json["route"],
methods=vertex_attribute_names_json["methods"],
)
def vertex_attribute_names():

UPLOAD_FOLDER = flask.current_app.config["UPLOAD_FOLDER"]
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 = geode_functions.load(
flask.request.json["input_geode_object"], file_absolute_path
)
vertex_attribute_names = data.vertex_attribute_manager().attribute_names()

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


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


@routes.route(
polygon_attribute_names_json["route"],
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)
file_absolute_path = os.path.join(
UPLOAD_FOLDER, werkzeug.utils.secure_filename(flask.request.json["filename"])
)
data = geode_functions.load(
flask.request.json["input_geode_object"], file_absolute_path
)
polygon_attribute_names = data.polygon_attribute_manager().attribute_names()

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


with open(
os.path.join(schemas, "ping.json"),
"r",
Expand Down
15 changes: 15 additions & 0 deletions src/opengeodeweb_back/routes/schemas/polygon_attribute_names.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"route": "/polygon_attribute_names",
"methods": ["POST"],
"type": "object",
"properties": {
"input_geode_object": {
"type": "string"
},
"filename": {
"type": "string"
}
},
"required": ["input_geode_object", "filename"],
"additionalProperties": false
}
15 changes: 15 additions & 0 deletions src/opengeodeweb_back/routes/schemas/vertex_attribute_names.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"route": "/vertex_attribute_names",
"methods": ["POST"],
"type": "object",
"properties": {
"input_geode_object": {
"type": "string"
},
"filename": {
"type": "string"
}
},
"required": ["input_geode_object", "filename"],
"additionalProperties": false
}
25 changes: 25 additions & 0 deletions src/opengeodeweb_back/test_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Standard library imports

# Third party imports

# Local application imports


def test_route_wrong_params(client, route, get_full_data):
for key, value in get_full_data().items():
json = get_full_data()
json.pop(key)
response = client.post(route, json=json)
assert response.status_code == 400
error_description = response.json["description"]
assert error_description == f"Validation error: '{key}' is a required property"

json = get_full_data()
json["dumb_key"] = "dumb_value"
response = client.post(route, json=json)
assert response.status_code == 400
error_description = response.json["description"]
assert (
error_description
== "Validation error: Additional properties are not allowed ('dumb_key' was unexpected)"
)
7 changes: 6 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Standard library imports
import time

# Third party imports
import pytest

# Local application imports
from app import app
import time


@pytest.fixture
Expand Down
25 changes: 25 additions & 0 deletions tests/polygon_attribute.vtp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0"?>
<VTKFile type="PolyData" version="1.0" byte_order="LittleEndian" header_type="UInt32" compressor="vtkZLibDataCompressor">
<PolyData>
<Piece NumberOfPoints="14" NumberOfPolys="14">
<PointData>
<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>
<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>
<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>
<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>
</PointData>
<Points>
<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>
</Points>
<CellData>
<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>
<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>
<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>
</CellData>
<Polys>
<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>
<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>
</Polys>
</Piece>
</PolyData>
</VTKFile>
5 changes: 5 additions & 0 deletions tests/test_geode_functions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Standard library imports
import os
import uuid

# Third party imports

# Local application imports
from src.opengeodeweb_back import geode_functions, geode_objects


Expand Down
Loading