Skip to content

Commit 6b59701

Browse files
committed
feat(points): modify point's blueprint
1 parent 82a7171 commit 6b59701

5 files changed

Lines changed: 104 additions & 0 deletions

File tree

opengeodeweb_back_schemas.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,48 @@
3030
"z"
3131
],
3232
"additionalProperties": false
33+
},
34+
"point_set": {
35+
"$id": "opengeodeweb_back/create/point_set",
36+
"route": "/point_set",
37+
"methods": [
38+
"POST"
39+
],
40+
"type": "object",
41+
"properties": {
42+
"name": {
43+
"type": "string",
44+
"minLength": 1
45+
},
46+
"points": {
47+
"type": "array",
48+
"items": {
49+
"type": "object",
50+
"properties": {
51+
"x": {
52+
"type": "number"
53+
},
54+
"y": {
55+
"type": "number"
56+
},
57+
"z": {
58+
"type": "number"
59+
}
60+
},
61+
"required": [
62+
"x",
63+
"y",
64+
"z"
65+
]
66+
},
67+
"minItems": 1
68+
}
69+
},
70+
"required": [
71+
"name",
72+
"points"
73+
],
74+
"additionalProperties": false
3375
}
3476
},
3577
"vertex_attribute_names": {

src/opengeodeweb_back/routes/create/blueprint_create.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,24 @@ def point() -> flask.Response:
3636
pointset
3737
)
3838
return flask.make_response(result, 200)
39+
40+
41+
@routes.route(
42+
schemas_dict["point_set"]["route"],
43+
methods=schemas_dict["point_set"]["methods"],
44+
)
45+
def point_set() -> flask.Response:
46+
"""Endpoint to create a point set in 3D space."""
47+
json_data = utils_functions.validate_request(flask.request, schemas_dict["point_set"])
48+
params = schemas.PointSet.from_dict(json_data)
49+
50+
pointset = GeodePointSet3D()
51+
builder = pointset.builder()
52+
builder.set_name(params.name)
53+
for point in params.points:
54+
builder.create_point(opengeode.Point3D([point.x, point.y, point.z]))
55+
56+
result = utils_functions.generate_native_viewable_and_light_viewable_from_object(
57+
pointset
58+
)
59+
return flask.make_response(result, 200)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
from .point import *
2+
from .point_set import *
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"route": "/point_set",
3+
"methods": ["POST"],
4+
"type": "object",
5+
"properties": {
6+
"name": {
7+
"type": "string",
8+
"minLength": 1
9+
},
10+
"points": {
11+
"type": "array",
12+
"items": {
13+
"type": "object",
14+
"properties": {
15+
"x": { "type": "number" },
16+
"y": { "type": "number" },
17+
"z": { "type": "number" }
18+
},
19+
"required": ["x", "y", "z"]
20+
},
21+
"minItems": 1
22+
}
23+
},
24+
"required": ["name", "points"],
25+
"additionalProperties": false
26+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from dataclasses_json import DataClassJsonMixin
2+
from dataclasses import dataclass
3+
from typing import List
4+
5+
@dataclass
6+
class PointXYZ(DataClassJsonMixin):
7+
x: float
8+
y: float
9+
z: float
10+
11+
@dataclass
12+
class PointSet(DataClassJsonMixin):
13+
name: str
14+
points: List[PointXYZ]

0 commit comments

Comments
 (0)