Skip to content

Commit ed63dcc

Browse files
authored
Merge pull request #121 from Geode-solutions/fix_createpoint
Fix_createpoint
2 parents c811fc3 + 3ac5bf2 commit ed63dcc

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

src/opengeodeweb_back/routes/blueprint_routes.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,23 +283,37 @@ def save_viewable_file():
283283
def create_point():
284284
utils_functions.validate_request(flask.request, create_point_json)
285285
DATA_FOLDER_PATH = flask.current_app.config["DATA_FOLDER_PATH"]
286+
title = flask.request.json["title"]
286287
x = flask.request.json["x"]
287288
y = flask.request.json["y"]
288289
z = flask.request.json["z"]
289290
class_ = geode_functions.geode_object_class("PointSet3D")
290291
PointSet3D = class_.create()
291292
builder = geode_functions.create_builder("PointSet3D", PointSet3D)
292293
builder.create_point(opengeode.Point3D([x, y, z]))
293-
294+
builder.set_name(title)
295+
name = PointSet3D.name()
294296
generated_id = str(uuid.uuid4()).replace("-", "")
297+
object_type = geode_functions.get_object_type("PointSet3D")
298+
saved_native_file_path = geode_functions.save(
299+
"PointSet3D", PointSet3D, DATA_FOLDER_PATH, generated_id + ".og_pts3d"
300+
)
295301
saved_viewable_file_path = geode_functions.save_viewable(
296302
"PointSet3D", PointSet3D, DATA_FOLDER_PATH, generated_id
297303
)
298304

305+
native_file_name = os.path.basename(saved_native_file_path[0])
306+
viewable_file_name = os.path.basename(saved_viewable_file_path)
307+
299308
return flask.make_response(
300309
{
301310
"viewable_file_name": os.path.basename(saved_viewable_file_path),
302311
"id": generated_id,
312+
"name": name,
313+
"native_file_name": native_file_name,
314+
"viewable_file_name": viewable_file_name,
315+
"object_type": object_type,
316+
"geode_object": "PointSet3D",
303317
},
304318
200,
305319
)

src/opengeodeweb_back/routes/schemas/create_point.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
],
66
"type": "object",
77
"properties": {
8+
"title": {
9+
"type": "string"
10+
},
811
"x": {
912
"type": "number"
1013
},
@@ -16,6 +19,7 @@
1619
}
1720
},
1821
"required": [
22+
"title",
1923
"x",
2024
"y",
2125
"z"

tests/test_routes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ def get_full_data():
294294

295295
def test_create_point(client):
296296
route = f"/create_point"
297-
get_full_data = lambda: {"x": 1, "y": 2, "z": 3}
297+
get_full_data = lambda: {"title": "test_point", "x": 1, "y": 2, "z": 3}
298298

299299
# Normal test with all keys
300300
response = client.post(route, json=get_full_data())

0 commit comments

Comments
 (0)