Skip to content

Commit 36bd6c3

Browse files
committed
feat(curve): blueprint for curve creation
1 parent 024840c commit 36bd6c3

5 files changed

Lines changed: 137 additions & 0 deletions

File tree

opengeodeweb_back_schemas.json

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,62 @@
4343
"points"
4444
],
4545
"additionalProperties": false
46+
},
47+
"edged_curve": {
48+
"$id": "opengeodeweb_back/create/edged_curve",
49+
"route": "/edged_curve",
50+
"methods": [
51+
"POST"
52+
],
53+
"type": "object",
54+
"properties": {
55+
"name": {
56+
"type": "string",
57+
"minLength": 1
58+
},
59+
"points": {
60+
"type": "array",
61+
"items": {
62+
"type": "object",
63+
"properties": {
64+
"x": {
65+
"type": "number"
66+
},
67+
"y": {
68+
"type": "number"
69+
},
70+
"z": {
71+
"type": "number"
72+
}
73+
},
74+
"required": [
75+
"x",
76+
"y",
77+
"z"
78+
],
79+
"additionalProperties": false
80+
},
81+
"minItems": 2
82+
},
83+
"edges": {
84+
"type": "array",
85+
"items": {
86+
"type": "array",
87+
"items": {
88+
"type": "integer"
89+
},
90+
"minItems": 2,
91+
"maxItems": 2
92+
},
93+
"minItems": 1
94+
}
95+
},
96+
"required": [
97+
"name",
98+
"points",
99+
"edges"
100+
],
101+
"additionalProperties": false
46102
}
47103
},
48104
"vertex_attribute_names": {

src/opengeodeweb_back/routes/create/blueprint_create.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,29 @@ def point_set() -> flask.Response:
3737
pointset
3838
)
3939
return flask.make_response(result, 200)
40+
41+
42+
@routes.route(
43+
schemas_dict["edged_curve"]["route"],
44+
methods=schemas_dict["edged_curve"]["methods"],
45+
)
46+
def edged_curve() -> flask.Response:
47+
"""Endpoint to create an edged curve in 3D space."""
48+
json_data = utils_functions.validate_request(
49+
flask.request, schemas_dict["edged_curve"]
50+
)
51+
params = schemas.EdgedCurve.from_dict(json_data)
52+
53+
edged_curve_obj = GeodeEdgedCurve3D()
54+
builder = edged_curve_obj.builder()
55+
builder.set_name(params.name)
56+
for point in params.points:
57+
builder.create_point(opengeode.Point3D([point.x, point.y, point.z]))
58+
59+
for edge in params.edges:
60+
builder.create_edge_with_vertices(edge[0], edge[1])
61+
62+
result = utils_functions.generate_native_viewable_and_light_viewable_from_object(
63+
edged_curve_obj
64+
)
65+
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_set import *
2+
from .edged_curve import *
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"route": "/edged_curve",
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+
"additionalProperties": false
21+
},
22+
"minItems": 2
23+
},
24+
"edges": {
25+
"type": "array",
26+
"items": {
27+
"type": "array",
28+
"items": { "type": "integer" },
29+
"minItems": 2,
30+
"maxItems": 2
31+
},
32+
"minItems": 1
33+
}
34+
},
35+
"required": ["name", "points", "edges"],
36+
"additionalProperties": false
37+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from dataclasses_json import DataClassJsonMixin
2+
from dataclasses import dataclass
3+
from typing import List
4+
5+
6+
@dataclass
7+
class Point(DataClassJsonMixin):
8+
x: float
9+
y: float
10+
z: float
11+
12+
13+
@dataclass
14+
class EdgedCurve(DataClassJsonMixin):
15+
name: str
16+
points: List[Point]
17+
edges: List[List[int]]

0 commit comments

Comments
 (0)