OpenGeodeWeb-Back 5.10.5rc1__py3-none-any.whl → 5.11.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of OpenGeodeWeb-Back might be problematic. Click here for more details.

opengeodeweb_back/app.py CHANGED
@@ -4,30 +4,26 @@ import argparse
4
4
  import os
5
5
  import time
6
6
  from typing import Any
7
-
8
7
  import flask
9
8
  import flask_cors # type: ignore
10
9
  from flask import Flask, Response
11
10
  from flask_cors import cross_origin
12
11
  from werkzeug.exceptions import HTTPException
13
-
14
12
  from opengeodeweb_back import utils_functions, app_config
15
13
  from opengeodeweb_back.routes import blueprint_routes
16
14
  from opengeodeweb_back.routes.models import blueprint_models
15
+ from opengeodeweb_back.routes.create import blueprint_create
17
16
  from opengeodeweb_microservice.database import connection
18
17
 
19
-
20
18
  """ Global config """
21
19
  app: Flask = flask.Flask(__name__)
22
20
 
23
21
  """ Config variables """
24
22
  FLASK_DEBUG = True if os.environ.get("FLASK_DEBUG", default=None) == "True" else False
25
-
26
23
  if FLASK_DEBUG == False:
27
24
  app.config.from_object(app_config.ProdConfig)
28
25
  else:
29
26
  app.config.from_object(app_config.DevConfig)
30
-
31
27
  DEFAULT_HOST: str = app.config.get("DEFAULT_HOST") or "localhost"
32
28
  DEFAULT_PORT: int = int(app.config.get("DEFAULT_PORT") or 5000)
33
29
  DEFAULT_DATA_FOLDER_PATH: str = app.config.get("DEFAULT_DATA_FOLDER_PATH") or "./data"
@@ -54,12 +50,16 @@ app.register_blueprint(
54
50
  url_prefix="/opengeodeweb_back",
55
51
  name="opengeodeweb_back",
56
52
  )
57
-
58
53
  app.register_blueprint(
59
54
  blueprint_models.routes,
60
55
  url_prefix="/opengeodeweb_back/models",
61
56
  name="opengeodeweb_models",
62
57
  )
58
+ app.register_blueprint(
59
+ blueprint_create.routes,
60
+ url_prefix="/opengeodeweb_back/create",
61
+ name="opengeodeweb_create",
62
+ )
63
63
 
64
64
  if FLASK_DEBUG == False:
65
65
  utils_functions.set_interval(
@@ -72,6 +72,11 @@ def errorhandler(e: HTTPException) -> tuple[dict[str, Any], int] | Response:
72
72
  return utils_functions.handle_exception(e)
73
73
 
74
74
 
75
+ @app.errorhandler(Exception)
76
+ def handle_generic_exception(e: Exception) -> Response:
77
+ return flask.make_response({"error": str(e)}, 500)
78
+
79
+
75
80
  @app.route(
76
81
  "/error",
77
82
  methods=["POST"],
@@ -136,13 +141,10 @@ def run_server() -> None:
136
141
  help="Number of minutes before the server times out",
137
142
  )
138
143
  args = parser.parse_args()
139
-
140
144
  app.config.update(DATA_FOLDER_PATH=args.data_folder_path)
141
145
  app.config.update(UPLOAD_FOLDER=args.upload_folder_path)
142
146
  app.config.update(MINUTES_BEFORE_TIMEOUT=args.timeout)
143
-
144
147
  flask_cors.CORS(app, origins=args.allowed_origins)
145
-
146
148
  print(
147
149
  f"Host: {args.host}, Port: {args.port}, Debug: {args.debug}, "
148
150
  f"Data folder path: {args.data_folder_path}, Timeout: {args.timeout}, "
@@ -158,7 +160,6 @@ def run_server() -> None:
158
160
 
159
161
  connection.init_database(db_path)
160
162
  print(f"Database initialized at: {db_path}", flush=True)
161
-
162
163
  app.run(debug=args.debug, host=args.host, port=args.port, ssl_context=SSL)
163
164
 
164
165
 
@@ -10,7 +10,8 @@ import werkzeug
10
10
 
11
11
  # Local application imports
12
12
  from .. import geode_functions, utils_functions
13
-
13
+ from opengeodeweb_microservice.database.data import Data
14
+ from opengeodeweb_microservice.database.connection import get_session
14
15
  from .models import blueprint_models
15
16
 
16
17
  routes = flask.Blueprint("routes", __name__, url_prefix="/opengeodeweb_back")
@@ -22,7 +23,6 @@ routes.register_blueprint(
22
23
  name=blueprint_models.routes.name,
23
24
  )
24
25
 
25
-
26
26
  schemas = os.path.join(os.path.dirname(__file__), "schemas")
27
27
 
28
28
  with open(
@@ -244,30 +244,6 @@ def save_viewable_file():
244
244
  )
245
245
 
246
246
 
247
- with open(os.path.join(schemas, "create_point.json"), "r") as file:
248
- create_point_json = json.load(file)
249
-
250
-
251
- @routes.route(create_point_json["route"], methods=create_point_json["methods"])
252
- def create_point():
253
- utils_functions.validate_request(flask.request, create_point_json)
254
- title = flask.request.get_json()["title"]
255
- x = flask.request.get_json()["x"]
256
- y = flask.request.get_json()["y"]
257
- z = flask.request.get_json()["z"]
258
- class_ = geode_functions.geode_object_class("PointSet3D")
259
- PointSet3D = class_.create()
260
- builder = geode_functions.create_builder("PointSet3D", PointSet3D)
261
- builder.create_point(opengeode.Point3D([x, y, z]))
262
- builder.set_name(title)
263
- return flask.make_response(
264
- utils_functions.generate_native_viewable_and_light_viewable_from_object(
265
- "PointSet3D", PointSet3D
266
- ),
267
- 200,
268
- )
269
-
270
-
271
247
  with open(os.path.join(schemas, "texture_coordinates.json"), "r") as file:
272
248
  texture_coordinates_json = json.load(file)
273
249
 
@@ -0,0 +1,117 @@
1
+ # Standard library imports
2
+ import json
3
+ import os
4
+ from typing import Any, TypedDict
5
+
6
+ # Third party imports
7
+ import flask
8
+ import opengeode
9
+
10
+ # Local application imports
11
+ from opengeodeweb_back import geode_functions, utils_functions
12
+
13
+ routes = flask.Blueprint("create", __name__, url_prefix="/create")
14
+ schemas = os.path.join(os.path.dirname(__file__), "schemas")
15
+
16
+ # --- Type definitions ---
17
+ type SchemaDict = dict[str, Any]
18
+
19
+
20
+ class PointDict(TypedDict):
21
+ x: float
22
+ y: float
23
+
24
+
25
+ class CreatePointParams(TypedDict):
26
+ name: str
27
+ x: float
28
+ y: float
29
+ z: float
30
+
31
+
32
+ class CreateAOIParams(TypedDict):
33
+ name: str
34
+ points: list[PointDict]
35
+ z: float
36
+
37
+
38
+ # Load schemas
39
+ with open(os.path.join(schemas, "create_point.json"), "r") as file:
40
+ create_point_json: SchemaDict = json.load(file)
41
+
42
+
43
+ @routes.route(create_point_json["route"], methods=create_point_json["methods"])
44
+ def create_point() -> flask.Response:
45
+ """Endpoint to create a single point in 3D space."""
46
+ print(f"create_point : {flask.request=}", flush=True)
47
+ utils_functions.validate_request(flask.request, create_point_json)
48
+
49
+ # Extract and validate data from request
50
+ params: CreatePointParams = flask.request.get_json()
51
+ name = params["name"]
52
+ x = params["x"]
53
+ y = params["y"]
54
+ z = params["z"]
55
+
56
+ # Create the point
57
+ class_ = geode_functions.geode_object_class("PointSet3D")
58
+ pointset = class_.create()
59
+ builder = geode_functions.create_builder("PointSet3D", pointset)
60
+ builder.set_name(name)
61
+ builder.create_point(opengeode.Point3D([x, y, z]))
62
+
63
+ # Save and get info
64
+ result = utils_functions.generate_native_viewable_and_light_viewable_from_object(
65
+ geode_object="PointSet3D",
66
+ data=pointset,
67
+ )
68
+ result["name"] = name
69
+ return flask.make_response(result, 200)
70
+
71
+
72
+ # Load schema for AOI creation
73
+ with open(os.path.join(schemas, "create_aoi.json"), "r") as file:
74
+ create_aoi_json: SchemaDict = json.load(file)
75
+
76
+
77
+ @routes.route(create_aoi_json["route"], methods=create_aoi_json["methods"])
78
+ def create_aoi() -> flask.Response:
79
+ """Endpoint to create an Area of Interest (AOI) as an EdgedCurve3D."""
80
+ print(f"create_aoi : {flask.request=}", flush=True)
81
+ utils_functions.validate_request(flask.request, create_aoi_json)
82
+
83
+ # Extract and validate data from request
84
+ params: CreateAOIParams = flask.request.get_json()
85
+ name = params["name"]
86
+ points = params["points"]
87
+ z = params["z"]
88
+
89
+ # Create the edged curve
90
+ class_ = geode_functions.geode_object_class("EdgedCurve3D")
91
+ edged_curve = class_.create()
92
+ builder = geode_functions.create_builder("EdgedCurve3D", edged_curve)
93
+ builder.set_name(name)
94
+
95
+ # Create vertices first
96
+ vertex_indices: list[int] = []
97
+ for point in points:
98
+ vertex_id = builder.create_point(opengeode.Point3D([point["x"], point["y"], z]))
99
+ vertex_indices.append(vertex_id)
100
+
101
+ # Create edges between consecutive vertices and close the loop
102
+ num_vertices = len(vertex_indices)
103
+ for i in range(num_vertices):
104
+ next_i = (i + 1) % num_vertices
105
+ edge_id = builder.create_edge()
106
+ builder.set_edge_vertex(opengeode.EdgeVertex(edge_id, 0), vertex_indices[i])
107
+ builder.set_edge_vertex(
108
+ opengeode.EdgeVertex(edge_id, 1), vertex_indices[next_i]
109
+ )
110
+
111
+ # Save and get info
112
+ result = utils_functions.generate_native_viewable_and_light_viewable_from_object(
113
+ geode_object="EdgedCurve3D",
114
+ data=edged_curve,
115
+ )
116
+ result["name"] = name
117
+ return flask.make_response(result, 200)
@@ -0,0 +1,46 @@
1
+ {
2
+ "route": "/create_aoi",
3
+ "methods": [
4
+ "POST"
5
+ ],
6
+ "type": "object",
7
+ "properties": {
8
+ "name": {
9
+ "type": "string",
10
+ "description": "Name of the AOI"
11
+ },
12
+ "points": {
13
+ "type": "array",
14
+ "items": {
15
+ "type": "object",
16
+ "properties": {
17
+ "x": {
18
+ "type": "number"
19
+ },
20
+ "y": {
21
+ "type": "number"
22
+ }
23
+ },
24
+ "required": [
25
+ "x",
26
+ "y"
27
+ ],
28
+ "additionalProperties": false
29
+ },
30
+ "minItems": 4,
31
+ "maxItems": 4
32
+ },
33
+ "z": {
34
+ "type": "number"
35
+ },
36
+ "id": {
37
+ "type": "string"
38
+ }
39
+ },
40
+ "required": [
41
+ "name",
42
+ "points",
43
+ "z"
44
+ ],
45
+ "additionalProperties": false
46
+ }
@@ -0,0 +1,29 @@
1
+ {
2
+ "route": "/create_point",
3
+ "methods": [
4
+ "POST"
5
+ ],
6
+ "type": "object",
7
+ "properties": {
8
+ "name": {
9
+ "type": "string",
10
+ "minLength": 1
11
+ },
12
+ "x": {
13
+ "type": "number"
14
+ },
15
+ "y": {
16
+ "type": "number"
17
+ },
18
+ "z": {
19
+ "type": "number"
20
+ }
21
+ },
22
+ "required": [
23
+ "name",
24
+ "x",
25
+ "y",
26
+ "z"
27
+ ],
28
+ "additionalProperties": false
29
+ }
@@ -211,6 +211,7 @@ def save_all_viewables_and_return_info(
211
211
  "native_file_name": data_entry.native_file_name,
212
212
  "viewable_file_name": data_entry.viewable_file_name,
213
213
  "id": data_entry.id,
214
+ "name": data.name(), # type: ignore
214
215
  "object_type": geode_functions.get_object_type(geode_object),
215
216
  "binary_light_viewable": binary_light_viewable.decode("utf-8"),
216
217
  "geode_object": data_entry.geode_object,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: OpenGeodeWeb-Back
3
- Version: 5.10.5rc1
3
+ Version: 5.11.0
4
4
  Summary: OpenGeodeWeb-Back is an open source framework that proposes handy python functions and wrappers for the OpenGeode ecosystem
5
5
  Author-email: Geode-solutions <team-web@geode-solutions.com>
6
6
  Project-URL: Homepage, https://github.com/Geode-solutions/OpenGeodeWeb-Back
@@ -16,18 +16,18 @@ Requires-Dist: blinker>=1
16
16
  Requires-Dist: click>=8
17
17
  Requires-Dist: flask[async]>=3
18
18
  Requires-Dist: flask-cors==6.0.1
19
- Requires-Dist: geode-common==33.11.0
20
- Requires-Dist: geode-viewables==3.3.0
19
+ Requires-Dist: geode-common==33.11.3
20
+ Requires-Dist: geode-viewables==3.3.2
21
21
  Requires-Dist: itsdangerous>=2
22
22
  Requires-Dist: jinja2>=3
23
23
  Requires-Dist: markupsafe>=3
24
- Requires-Dist: opengeode-core==15.27.4
25
- Requires-Dist: opengeode-geosciences==9.4.1
26
- Requires-Dist: opengeode-geosciencesio==5.8.0
27
- Requires-Dist: opengeode-inspector==6.8.1
28
- Requires-Dist: opengeode-io==7.4.0
24
+ Requires-Dist: opengeode-core==15.29.2
25
+ Requires-Dist: opengeode-geosciences==9.5.0
26
+ Requires-Dist: opengeode-geosciencesio==5.8.1
27
+ Requires-Dist: opengeode-inspector==6.8.2
28
+ Requires-Dist: opengeode-io==7.4.2
29
29
  Requires-Dist: werkzeug==3.1.2
30
- Requires-Dist: opengeodeweb-microservice==1.*,>=1.0.5rc1
30
+ Requires-Dist: opengeodeweb-microservice==1.*,>=1.0.5
31
31
  Dynamic: license-file
32
32
 
33
33
  <h1 align="center">OpenGeodeWeb-Back<sup><i>by Geode-solutions</i></sup></h1>
@@ -1,18 +1,20 @@
1
1
  opengeodeweb_back/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- opengeodeweb_back/app.py,sha256=_ws9UCqbR-_Hd4kE-Xh7FaGSulVRd7Au3KbOM3GUQ8I,4766
2
+ opengeodeweb_back/app.py,sha256=SX7csXbWxlfeazrgSYuplJu9Z4LxupCd5T8O6bFN36g,5090
3
3
  opengeodeweb_back/app_config.py,sha256=z-omTiGj3-y0BZ1IchAM6EoTdC7vAX6B4OymEnuM0T4,843
4
4
  opengeodeweb_back/geode_functions.py,sha256=NzELy9s6AETDnm7tyA_uM2N89zrfeLdblRhzYrBONmw,10804
5
5
  opengeodeweb_back/geode_objects.py,sha256=_NclGPa024kCwUHdORkFuXYtiZBmQpgq6sO3LRkBhe8,27776
6
6
  opengeodeweb_back/py.typed,sha256=la67KBlbjXN-_-DfGNcdOcjYumVpKG_Tkw-8n5dnGB4,8
7
7
  opengeodeweb_back/test_utils.py,sha256=18AbRW9-tfKkPcmRGilTTHXI7S3armYyV7Vdy5UvUKM,794
8
- opengeodeweb_back/utils_functions.py,sha256=tHU6VjyW-QwohDihdcoVSiD2TdGLeB0EtBjCorvVb8I,9327
9
- opengeodeweb_back/routes/blueprint_routes.py,sha256=eTEKwKt9qc6cH1MDQ3lwmcnzLLxU_W8cYwu8HcUbXxo,10998
8
+ opengeodeweb_back/utils_functions.py,sha256=gGhNENDyx9ooO1Mb7KWLfgGCJ9F2DZMRpp9EXzEmb9A,9376
9
+ opengeodeweb_back/routes/blueprint_routes.py,sha256=xOcC_Urp8C62zX1XJ4ILQPicObPhoYBI-38ObGYH-UA,10251
10
+ opengeodeweb_back/routes/create/blueprint_create.py,sha256=rHZbpIJ0dhpWCe8agWMFJCg1uSFiTBGjCO9bnktYyUY,3557
11
+ opengeodeweb_back/routes/create/schemas/create_aoi.json,sha256=bFL5ZqhKAKsBmGwIQANzdIp1vGeH5WAHnRpZYsUZ1tQ,999
12
+ opengeodeweb_back/routes/create/schemas/create_point.json,sha256=ddfDzWKj4cMYhF6oJzvRh0bpTiQo1hqLFODK-vJjxHQ,484
10
13
  opengeodeweb_back/routes/models/blueprint_models.py,sha256=Jo9pUDeu1nO3_IbBiuHGk57cc4_fhwxjM0EKNyv1FT0,1874
11
14
  opengeodeweb_back/routes/models/schemas/mesh_components.json,sha256=JmQUvpy7HpGS6FlThZLx1YjHqiInRTqUZ_Ft5MfOzEE,239
12
15
  opengeodeweb_back/routes/models/schemas/vtm_component_indices.json,sha256=0XILVxhAxi0RhQFDZZoUeGcAnBMroWz3kNJS7-6_dKQ,239
13
16
  opengeodeweb_back/routes/schemas/allowed_files.json,sha256=pRsGf39LiJpl3zEGLg4IqvRtm7iUx3Wq4Tb4tSFXGV0,234
14
17
  opengeodeweb_back/routes/schemas/allowed_objects.json,sha256=oy_YYpFzgDICx-keWqNIUpQM3zzB4eE3H6mPNxH9rWc,361
15
- opengeodeweb_back/routes/schemas/create_point.json,sha256=XjmXLMkr4jgWYHUKSwAhsxz1oLDZi8r8J0SY-QuEvks,386
16
18
  opengeodeweb_back/routes/schemas/geode_objects_and_output_extensions.json,sha256=tp83tPQaxTltQrdL8D3TnG8pqY_2fgAaYVeTWPXO0qI,371
17
19
  opengeodeweb_back/routes/schemas/geographic_coordinate_systems.json,sha256=lnPqevRRlUASF4ObmpG8ChH3c2LHNB99Si292S3OsLU,279
18
20
  opengeodeweb_back/routes/schemas/inspect_file.json,sha256=WoFF2hgZCUfqSDFJRq1sLpivjCQ6TCvSHPH8pKFY6KM,348
@@ -25,9 +27,9 @@ opengeodeweb_back/routes/schemas/save_viewable_file.json,sha256=pvvEdaC7bNASPMrl
25
27
  opengeodeweb_back/routes/schemas/texture_coordinates.json,sha256=2uQueIl1jOmxFG_gIi_vJETR4IurrwuSf8GAnzphk9g,237
26
28
  opengeodeweb_back/routes/schemas/upload_file.json,sha256=LJ3U3L5ApKuQDVFIpVT_y2alq4HW_suTvZ3HUucNbhg,219
27
29
  opengeodeweb_back/routes/schemas/vertex_attribute_names.json,sha256=ECIflohiqPZNsflAdkfEzksL4we0JvZhIxUd84Ubctg,240
28
- opengeodeweb_back-5.10.5rc1.dist-info/licenses/LICENSE,sha256=LoTB-aqQvzTGxoTRXNnhNV0LKiqdk2bQv6MB34l8zkI,1079
29
- opengeodeweb_back-5.10.5rc1.dist-info/METADATA,sha256=6LnIyanx13uNBllBS48qFz4J41ZJ7nAOZDnPu9nIyKs,2668
30
- opengeodeweb_back-5.10.5rc1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
31
- opengeodeweb_back-5.10.5rc1.dist-info/entry_points.txt,sha256=3W_t5GFc9ROHSIZ55IGvYU3DLHUFQmYOM4Bm9u3Z0cE,71
32
- opengeodeweb_back-5.10.5rc1.dist-info/top_level.txt,sha256=tN1FZeLIVBrdja2-pbmhg5-tK-JILmmT9OeIBnhlUrQ,18
33
- opengeodeweb_back-5.10.5rc1.dist-info/RECORD,,
30
+ opengeodeweb_back-5.11.0.dist-info/licenses/LICENSE,sha256=LoTB-aqQvzTGxoTRXNnhNV0LKiqdk2bQv6MB34l8zkI,1079
31
+ opengeodeweb_back-5.11.0.dist-info/METADATA,sha256=na4X9UmOyw0MUsZKYjRBtyZCUp5qgtk-lVnedL501R4,2662
32
+ opengeodeweb_back-5.11.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
33
+ opengeodeweb_back-5.11.0.dist-info/entry_points.txt,sha256=3W_t5GFc9ROHSIZ55IGvYU3DLHUFQmYOM4Bm9u3Z0cE,71
34
+ opengeodeweb_back-5.11.0.dist-info/top_level.txt,sha256=tN1FZeLIVBrdja2-pbmhg5-tK-JILmmT9OeIBnhlUrQ,18
35
+ opengeodeweb_back-5.11.0.dist-info/RECORD,,
@@ -1,29 +0,0 @@
1
- {
2
- "route": "/create_point",
3
- "methods": [
4
- "POST"
5
- ],
6
- "type": "object",
7
- "properties": {
8
- "title": {
9
- "type": "string",
10
- "minLength": 1
11
- },
12
- "x": {
13
- "type": "number"
14
- },
15
- "y": {
16
- "type": "number"
17
- },
18
- "z": {
19
- "type": "number"
20
- }
21
- },
22
- "required": [
23
- "title",
24
- "x",
25
- "y",
26
- "z"
27
- ],
28
- "additionalProperties": false
29
- }