88
99# Local application imports
1010from opengeodeweb_back import geode_functions , utils_functions
11- from . import schemas
11+ from opengeodeweb_back . routes . create . schemas import schemas
1212from opengeodeweb_back .geode_objects .geode_point_set3d import GeodePointSet3D
1313from opengeodeweb_back .geode_objects .geode_edged_curve3d import GeodeEdgedCurve3D
1414
1717
1818
1919@routes .route (
20- schemas_dict ["create_point " ]["route" ],
21- methods = schemas_dict ["create_point " ]["methods" ],
20+ schemas_dict ["point " ]["route" ],
21+ methods = schemas_dict ["point " ]["methods" ],
2222)
23- def create_point () -> flask .Response :
23+ def point () -> flask .Response :
2424 """Endpoint to create a single point in 3D space."""
2525 json_data = utils_functions .validate_request (
2626 flask .request , schemas_dict ["create_point" ]
2727 )
28- params = schemas .CreatePoint .from_dict (json_data )
28+ params = schemas .Point .from_dict (json_data )
2929
3030 # Create the point
3131 pointset = GeodePointSet3D ()
@@ -38,84 +38,3 @@ def create_point() -> flask.Response:
3838 pointset
3939 )
4040 return flask .make_response (result , 200 )
41-
42-
43- @routes .route (
44- schemas_dict ["create_aoi" ]["route" ], methods = schemas_dict ["create_aoi" ]["methods" ]
45- )
46- def create_aoi () -> flask .Response :
47- """Endpoint to create an Area of Interest (AOI) as an EdgedCurve3D."""
48- json_data = utils_functions .validate_request (
49- flask .request , schemas_dict ["create_aoi" ]
50- )
51- params = schemas .CreateAoi .from_dict (json_data )
52-
53- # Create the edged curve
54- edged_curve = GeodeEdgedCurve3D ()
55- builder = edged_curve .builder ()
56- builder .set_name (params .name )
57-
58- # Create vertices first
59- for point in params .points :
60- builder .create_point (opengeode .Point3D ([point .x , point .y , params .z ]))
61-
62- # Create edges between consecutive vertices and close the loop
63- num_vertices = len (params .points )
64- for i in range (num_vertices ):
65- next_i = (i + 1 ) % num_vertices
66- builder .create_edge_with_vertices (i , next_i )
67-
68- # Save and get info
69- result = utils_functions .generate_native_viewable_and_light_viewable_from_object (
70- edged_curve
71- )
72- return flask .make_response (result , 200 )
73-
74-
75- @routes .route (
76- schemas_dict ["create_voi" ]["route" ], methods = schemas_dict ["create_voi" ]["methods" ]
77- )
78- def create_voi () -> flask .Response :
79- """Endpoint to create a Volume of Interest (VOI) as an EdgedCurve3D (a bounding box/prism)."""
80- json_data = utils_functions .validate_request (
81- flask .request , schemas_dict ["create_voi" ]
82- )
83- params = schemas .CreateVoi .from_dict (json_data )
84-
85- aoi_data = geode_functions .get_data_info (params .aoi_id )
86- if not aoi_data :
87- flask .abort (404 , f"AOI with id { params .aoi_id } not found" )
88-
89- aoi_object = geode_functions .load_geode_object (params .aoi_id )
90- if not isinstance (aoi_object , GeodeEdgedCurve3D ):
91- flask .abort (400 , f"AOI with id { params .aoi_id } is not a GeodeEdgedCurve3D" )
92-
93- aoi_curve = aoi_object .edged_curve
94- nb_points = aoi_curve .nb_vertices ()
95-
96- edged_curve = GeodeEdgedCurve3D ()
97- builder = edged_curve .builder ()
98- builder .set_name (params .name )
99-
100- for point_id in range (nb_points ):
101- aoi_point = aoi_curve .point (point_id )
102- builder .create_point (
103- opengeode .Point3D ([aoi_point .value (0 ), aoi_point .value (1 ), params .z_min ])
104- )
105-
106- for point_id in range (nb_points ):
107- aoi_point = aoi_curve .point (point_id )
108- builder .create_point (
109- opengeode .Point3D ([aoi_point .value (0 ), aoi_point .value (1 ), params .z_max ])
110- )
111-
112- for point_id in range (nb_points ):
113- next_point = (point_id + 1 ) % nb_points
114- builder .create_edge_with_vertices (point_id , next_point )
115- builder .create_edge_with_vertices (point_id + nb_points , next_point + nb_points )
116- builder .create_edge_with_vertices (point_id , point_id + nb_points )
117-
118- result = utils_functions .generate_native_viewable_and_light_viewable_from_object (
119- edged_curve
120- )
121- return flask .make_response (result , 200 )
0 commit comments