Skip to content

Commit e77805a

Browse files
committed
changes
1 parent ad9c5f0 commit e77805a

File tree

5 files changed

+26
-58
lines changed

5 files changed

+26
-58
lines changed

opengeodeweb_back_schemas.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@
6161
],
6262
"additionalProperties": false
6363
},
64-
"minItems": 4,
65-
"maxItems": 4
64+
"minItems": 3
6665
},
6766
"z": {
6867
"type": "number"
@@ -92,18 +91,19 @@
9291
},
9392
"aoi_id": {
9493
"type": "string",
95-
"description": "ID of the corresponding AOI from which to take X and Y coordinates"
94+
"description": "ID of the corresponding AOI"
9695
},
9796
"z_min": {
9897
"type": "number",
99-
"description": "Minimum Z coordinate for the VOI"
98+
"description": "Minimum Z coordinate"
10099
},
101100
"z_max": {
102101
"type": "number",
103-
"description": "Maximum Z coordinate for the VOI"
102+
"description": "Maximum Z coordinate"
104103
},
105104
"id": {
106-
"type": "string"
105+
"type": "string",
106+
"description": "Optional ID for updating existing VOI"
107107
}
108108
},
109109
"required": [

src/opengeodeweb_back/routes/create/blueprint_create.py

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -80,55 +80,56 @@ def create_voi() -> flask.Response:
8080
utils_functions.validate_request(flask.request, schemas_dict["create_voi"])
8181
params = schemas.CreateVoi.from_dict(flask.request.get_json())
8282

83-
# Define the 4 vertices of the AOI (bottom face in the XY plane)
83+
aoi_data = geode_functions.get_data_info(params.aoi_id)
84+
if not aoi_data:
85+
flask.abort(404, f"AOI with id {params.aoi_id} not found")
86+
87+
edged_curve_aoi = geode_functions.load_data(params.aoi_id)
88+
if not isinstance(edged_curve_aoi, opengeode.EdgedCurve3D):
89+
flask.abort(400, "Referenced object is not an EdgedCurve3D (AOI)")
90+
91+
bbox_aoi = edged_curve_aoi.bounding_box()
92+
min_x = bbox_aoi.min().value(0)
93+
min_y = bbox_aoi.min().value(1)
94+
max_x = bbox_aoi.max().value(0)
95+
max_y = bbox_aoi.max().value(1)
96+
8497
aoi_vertices = [
85-
(params.min_x, params.min_y),
86-
(params.max_x, params.min_y),
87-
(params.max_x, params.max_y),
88-
(params.min_x, params.max_y),
98+
(min_x, min_y),
99+
(max_x, min_y),
100+
(max_x, max_y),
101+
(min_x, max_y),
89102
]
90103

91-
# Create the EdgedCurve object and its builder
92104
edged_curve = geode_functions.geode_object_class("EdgedCurve3D").create()
93105
builder = geode_functions.create_builder("EdgedCurve3D", edged_curve)
94106
builder.set_name(params.name)
95107

96-
# Extract Z bounds
97108
z_min = params.z_min
98109
z_max = params.z_max
99110

100-
# --- 1. Create the 8 vertices of the bounding box ---
101111

102-
# Create the 4 bottom vertices (indices 0 to 3)
103112
for x, y in aoi_vertices:
104113
builder.create_point(opengeode.Point3D([x, y, z_min]))
105114

106-
# Create the 4 top vertices (indices 4 to 7)
107115
for x, y in aoi_vertices:
108116
builder.create_point(opengeode.Point3D([x, y, z_max]))
109117

110-
# --- 2. Define and create the 12 edges of the bounding box ---
111118

112-
# Edges of the bottom face (connecting vertices 0-1, 1-2, 2-3, 3-0)
113119
bottom_edges = [(i, (i + 1) % 4) for i in range(4)]
114120

115-
# Edges of the top face (connecting vertices 4-5, 5-6, 6-7, 7-4)
116-
# The (i + 4) and ((i + 1) % 4 + 4) ensure we use indices 4, 5, 6, 7
117121
top_edges = [(i + 4, (i + 1) % 4 + 4) for i in range(4)]
118122

119-
# Vertical edges (connecting bottom (0-3) to top (4-7) vertices: 0-4, 1-5, 2-6, 3-7)
120123
vertical_edges = [(i, i + 4) for i in range(4)]
121124

122-
# Combine all edges
123125
all_edges = bottom_edges + top_edges + vertical_edges
124126

125-
# Create the edges in the EdgedCurve
126127
for v1, v2 in all_edges:
127128
builder.create_edge_with_vertices(v1, v2)
128129

129-
# Save and get info
130130
result = utils_functions.generate_native_viewable_and_light_viewable_from_object(
131131
geode_object="EdgedCurve3D",
132132
data=edged_curve,
133133
)
134+
result["aoi_id"] = params.aoi_id
134135
return flask.make_response(result, 200)

src/opengeodeweb_back/routes/create/schemas/create_aoi.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@
2727
],
2828
"additionalProperties": false
2929
},
30-
"minItems": 4,
31-
"maxItems": 4
30+
"minItems": 3
3231
},
3332
"z": {
3433
"type": "number"

src/opengeodeweb_back/routes/create/schemas/create_voi.json

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,6 @@
1313
"type": "string",
1414
"description": "ID of the corresponding AOI"
1515
},
16-
"min_x": {
17-
"type": "number",
18-
"description": "Minimum X coordinate from AOI"
19-
},
20-
"min_y": {
21-
"type": "number",
22-
"description": "Minimum Y coordinate from AOI"
23-
},
24-
"max_x": {
25-
"type": "number",
26-
"description": "Maximum X coordinate from AOI"
27-
},
28-
"max_y": {
29-
"type": "number",
30-
"description": "Maximum Y coordinate from AOI"
31-
},
3216
"z_min": {
3317
"type": "number",
3418
"description": "Minimum Z coordinate"
@@ -45,10 +29,6 @@
4529
"required": [
4630
"name",
4731
"aoi_id",
48-
"min_x",
49-
"min_y",
50-
"max_x",
51-
"max_y",
5232
"z_min",
5333
"z_max"
5434
],

src/opengeodeweb_back/routes/create/schemas/create_voi.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,6 @@ class CreateVoi(DataClassJsonMixin):
1010
aoi_id: str
1111
"""ID of the corresponding AOI"""
1212

13-
min_x: float
14-
"""Minimum X coordinate from AOI"""
15-
16-
min_y: float
17-
"""Minimum Y coordinate from AOI"""
18-
19-
max_x: float
20-
"""Maximum X coordinate from AOI"""
21-
22-
max_y: float
23-
"""Maximum Y coordinate from AOI"""
24-
2513
z_min: float
2614
"""Minimum Z coordinate for the VOI"""
2715

0 commit comments

Comments
 (0)