OpenGeodeWeb-Back 5.10.0rc22__py3-none-any.whl → 5.14.1__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.
- opengeodeweb_back/app.py +173 -0
- opengeodeweb_back/app_config.py +1 -10
- opengeodeweb_back/geode_functions.py +44 -283
- opengeodeweb_back/geode_objects/__init__.py +61 -0
- opengeodeweb_back/geode_objects/geode_brep.py +102 -0
- opengeodeweb_back/geode_objects/geode_cross_section.py +75 -0
- opengeodeweb_back/geode_objects/geode_edged_curve2d.py +107 -0
- opengeodeweb_back/geode_objects/geode_edged_curve3d.py +107 -0
- opengeodeweb_back/geode_objects/geode_graph.py +76 -0
- opengeodeweb_back/geode_objects/geode_grid2d.py +30 -0
- opengeodeweb_back/geode_objects/geode_grid3d.py +30 -0
- opengeodeweb_back/geode_objects/geode_hybrid_solid3d.py +71 -0
- opengeodeweb_back/geode_objects/geode_implicit_cross_section.py +81 -0
- opengeodeweb_back/geode_objects/geode_implicit_structural_model.py +85 -0
- opengeodeweb_back/geode_objects/geode_light_regular_grid2d.py +72 -0
- opengeodeweb_back/geode_objects/geode_light_regular_grid3d.py +72 -0
- opengeodeweb_back/geode_objects/geode_mesh.py +19 -0
- opengeodeweb_back/geode_objects/geode_model.py +22 -0
- opengeodeweb_back/geode_objects/geode_object.py +78 -0
- opengeodeweb_back/geode_objects/geode_point_set2d.py +105 -0
- opengeodeweb_back/geode_objects/geode_point_set3d.py +105 -0
- opengeodeweb_back/geode_objects/geode_polygonal_surface2d.py +73 -0
- opengeodeweb_back/geode_objects/geode_polygonal_surface3d.py +73 -0
- opengeodeweb_back/geode_objects/geode_polyhedral_solid3d.py +73 -0
- opengeodeweb_back/geode_objects/geode_raster_image2d.py +83 -0
- opengeodeweb_back/geode_objects/geode_raster_image3d.py +83 -0
- opengeodeweb_back/geode_objects/geode_regular_grid2d.py +78 -0
- opengeodeweb_back/geode_objects/geode_regular_grid3d.py +78 -0
- opengeodeweb_back/geode_objects/geode_section.py +106 -0
- opengeodeweb_back/geode_objects/geode_solid_mesh3d.py +61 -0
- opengeodeweb_back/geode_objects/geode_structural_model.py +78 -0
- opengeodeweb_back/geode_objects/geode_surface_mesh2d.py +66 -0
- opengeodeweb_back/geode_objects/geode_surface_mesh3d.py +66 -0
- opengeodeweb_back/geode_objects/geode_tetrahedral_solid3d.py +73 -0
- opengeodeweb_back/geode_objects/geode_triangulated_surface2d.py +77 -0
- opengeodeweb_back/geode_objects/geode_triangulated_surface3d.py +77 -0
- opengeodeweb_back/geode_objects/geode_vertex_set.py +81 -0
- opengeodeweb_back/geode_objects/types.py +75 -0
- opengeodeweb_back/routes/blueprint_routes.py +352 -231
- opengeodeweb_back/routes/create/blueprint_create.py +121 -0
- opengeodeweb_back/routes/create/schemas/__init__.py +3 -0
- opengeodeweb_back/routes/create/schemas/create_aoi.json +45 -0
- opengeodeweb_back/routes/create/schemas/create_aoi.py +25 -0
- opengeodeweb_back/routes/create/schemas/create_point.json +29 -0
- opengeodeweb_back/routes/create/schemas/create_point.py +13 -0
- opengeodeweb_back/routes/create/schemas/create_voi.json +36 -0
- opengeodeweb_back/routes/create/schemas/create_voi.py +24 -0
- opengeodeweb_back/routes/models/blueprint_models.py +27 -27
- opengeodeweb_back/routes/models/schemas/__init__.py +2 -0
- opengeodeweb_back/routes/models/schemas/mesh_components.py +10 -0
- opengeodeweb_back/routes/models/schemas/vtm_component_indices.py +10 -0
- opengeodeweb_back/routes/schemas/__init__.py +17 -0
- opengeodeweb_back/routes/schemas/allowed_files.json +6 -8
- opengeodeweb_back/routes/schemas/allowed_files.py +10 -0
- opengeodeweb_back/routes/schemas/allowed_objects.json +1 -8
- opengeodeweb_back/routes/schemas/allowed_objects.py +10 -0
- opengeodeweb_back/routes/schemas/cell_attribute_names.json +13 -0
- opengeodeweb_back/routes/schemas/cell_attribute_names.py +10 -0
- opengeodeweb_back/routes/schemas/export_project.json +21 -0
- opengeodeweb_back/routes/schemas/export_project.py +12 -0
- opengeodeweb_back/routes/schemas/geode_objects_and_output_extensions.json +2 -2
- opengeodeweb_back/routes/schemas/geode_objects_and_output_extensions.py +11 -0
- opengeodeweb_back/routes/schemas/geographic_coordinate_systems.json +2 -2
- opengeodeweb_back/routes/schemas/geographic_coordinate_systems.py +10 -0
- opengeodeweb_back/routes/schemas/import_project.json +10 -0
- opengeodeweb_back/routes/schemas/import_project.py +10 -0
- opengeodeweb_back/routes/schemas/inspect_file.json +2 -2
- opengeodeweb_back/routes/schemas/inspect_file.py +11 -0
- opengeodeweb_back/routes/schemas/kill.json +10 -0
- opengeodeweb_back/routes/schemas/kill.py +10 -0
- opengeodeweb_back/routes/schemas/missing_files.json +2 -2
- opengeodeweb_back/routes/schemas/missing_files.py +11 -0
- opengeodeweb_back/routes/schemas/ping.py +10 -0
- opengeodeweb_back/routes/schemas/polygon_attribute_names.py +10 -0
- opengeodeweb_back/routes/schemas/polyhedron_attribute_names.py +10 -0
- opengeodeweb_back/routes/schemas/save_viewable_file.json +2 -2
- opengeodeweb_back/routes/schemas/save_viewable_file.py +11 -0
- opengeodeweb_back/routes/schemas/texture_coordinates.py +10 -0
- opengeodeweb_back/routes/schemas/upload_file.py +11 -0
- opengeodeweb_back/routes/schemas/vertex_attribute_names.py +10 -0
- opengeodeweb_back/test_utils.py +9 -3
- opengeodeweb_back/utils_functions.py +93 -88
- {opengeodeweb_back-5.10.0rc22.dist-info → opengeodeweb_back-5.14.1.dist-info}/METADATA +17 -22
- opengeodeweb_back-5.14.1.dist-info/RECORD +98 -0
- opengeodeweb_back-5.14.1.dist-info/entry_points.txt +2 -0
- opengeodeweb_back/geode_objects.py +0 -570
- opengeodeweb_back/routes/schemas/create_point.json +0 -29
- opengeodeweb_back-5.10.0rc22.dist-info/RECORD +0 -30
- {opengeodeweb_back-5.10.0rc22.dist-info → opengeodeweb_back-5.14.1.dist-info}/WHEEL +0 -0
- {opengeodeweb_back-5.10.0rc22.dist-info → opengeodeweb_back-5.14.1.dist-info}/licenses/LICENSE +0 -0
- {opengeodeweb_back-5.10.0rc22.dist-info → opengeodeweb_back-5.14.1.dist-info}/top_level.txt +0 -0
opengeodeweb_back/app.py
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"""Packages"""
|
|
2
|
+
|
|
3
|
+
import argparse
|
|
4
|
+
import os
|
|
5
|
+
from typing import Any
|
|
6
|
+
import flask
|
|
7
|
+
import flask_cors # type: ignore
|
|
8
|
+
from flask import Flask, Response
|
|
9
|
+
from flask_cors import cross_origin
|
|
10
|
+
from werkzeug.exceptions import HTTPException
|
|
11
|
+
from opengeodeweb_back import utils_functions, app_config
|
|
12
|
+
from opengeodeweb_back.routes import blueprint_routes
|
|
13
|
+
from opengeodeweb_back.routes.models import blueprint_models
|
|
14
|
+
from opengeodeweb_back.routes.create import blueprint_create
|
|
15
|
+
from opengeodeweb_microservice.database import connection
|
|
16
|
+
|
|
17
|
+
""" Global config """
|
|
18
|
+
app: Flask = flask.Flask(__name__)
|
|
19
|
+
|
|
20
|
+
""" Config variables """
|
|
21
|
+
FLASK_DEBUG = True if os.environ.get("FLASK_DEBUG", default=None) == "True" else False
|
|
22
|
+
if FLASK_DEBUG == False:
|
|
23
|
+
app.config.from_object(app_config.ProdConfig)
|
|
24
|
+
else:
|
|
25
|
+
app.config.from_object(app_config.DevConfig)
|
|
26
|
+
DEFAULT_HOST: str = app.config.get("DEFAULT_HOST") or "localhost"
|
|
27
|
+
DEFAULT_PORT: int = int(app.config.get("DEFAULT_PORT") or 5000)
|
|
28
|
+
DEFAULT_DATA_FOLDER_PATH: str = app.config.get("DEFAULT_DATA_FOLDER_PATH") or "./data"
|
|
29
|
+
ORIGINS: Any = app.config.get("ORIGINS")
|
|
30
|
+
TIMEOUT: int = int(app.config.get("MINUTES_BEFORE_TIMEOUT") or 30)
|
|
31
|
+
SSL: Any = app.config.get("SSL")
|
|
32
|
+
SECONDS_BETWEEN_SHUTDOWNS: float = float(
|
|
33
|
+
app.config.get("SECONDS_BETWEEN_SHUTDOWNS") or 60.0
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
@app.before_request
|
|
38
|
+
def before_request() -> flask.Response | None:
|
|
39
|
+
if flask.request.method == "OPTIONS":
|
|
40
|
+
response = flask.make_response()
|
|
41
|
+
response.headers["Access-Control-Allow-Methods"] = "GET,POST,PUT,DELETE,OPTIONS"
|
|
42
|
+
return response
|
|
43
|
+
utils_functions.before_request(flask.current_app)
|
|
44
|
+
return None
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
@app.teardown_request
|
|
48
|
+
def teardown_request(exception: BaseException | None) -> None:
|
|
49
|
+
utils_functions.teardown_request(flask.current_app, exception)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
app.register_blueprint(
|
|
53
|
+
blueprint_routes.routes,
|
|
54
|
+
url_prefix="/opengeodeweb_back",
|
|
55
|
+
name="opengeodeweb_back",
|
|
56
|
+
)
|
|
57
|
+
app.register_blueprint(
|
|
58
|
+
blueprint_models.routes,
|
|
59
|
+
url_prefix="/opengeodeweb_back/models",
|
|
60
|
+
name="opengeodeweb_models",
|
|
61
|
+
)
|
|
62
|
+
app.register_blueprint(
|
|
63
|
+
blueprint_create.routes,
|
|
64
|
+
url_prefix="/opengeodeweb_back/create",
|
|
65
|
+
name="opengeodeweb_create",
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
if FLASK_DEBUG == False:
|
|
69
|
+
utils_functions.set_interval(
|
|
70
|
+
utils_functions.kill_task, SECONDS_BETWEEN_SHUTDOWNS, app
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
@app.errorhandler(HTTPException)
|
|
75
|
+
def errorhandler(exception: HTTPException) -> tuple[dict[str, Any], int] | Response:
|
|
76
|
+
return utils_functions.handle_exception(exception)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
@app.errorhandler(Exception)
|
|
80
|
+
def handle_generic_exception(exception: Exception) -> Response:
|
|
81
|
+
print("\033[91mError:\033[0m \033[91m" + str(exception) + "\033[0m", flush=True)
|
|
82
|
+
return flask.make_response({"description": str(exception)}, 500)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
@app.route(
|
|
86
|
+
"/error",
|
|
87
|
+
methods=["POST"],
|
|
88
|
+
)
|
|
89
|
+
def return_error() -> Response:
|
|
90
|
+
flask.abort(500, f"Test")
|
|
91
|
+
return flask.make_response({}, 500)
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
@app.route("/", methods=["POST"])
|
|
95
|
+
@cross_origin()
|
|
96
|
+
def root() -> Response:
|
|
97
|
+
return flask.make_response({}, 200)
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
@app.route("/kill", methods=["POST"])
|
|
101
|
+
@cross_origin()
|
|
102
|
+
def kill() -> None:
|
|
103
|
+
print("Manual server kill, shutting down...", flush=True)
|
|
104
|
+
os._exit(0)
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def run_server() -> None:
|
|
108
|
+
parser = argparse.ArgumentParser(
|
|
109
|
+
prog="OpenGeodeWeb-Back", description="Backend server for OpenGeodeWeb"
|
|
110
|
+
)
|
|
111
|
+
parser.add_argument("--host", type=str, default=DEFAULT_HOST, help="Host to run on")
|
|
112
|
+
parser.add_argument(
|
|
113
|
+
"-p", "--port", type=int, default=DEFAULT_PORT, help="Port to listen on"
|
|
114
|
+
)
|
|
115
|
+
parser.add_argument(
|
|
116
|
+
"-d",
|
|
117
|
+
"--debug",
|
|
118
|
+
default=FLASK_DEBUG,
|
|
119
|
+
help="Whether to run in debug mode",
|
|
120
|
+
action="store_true",
|
|
121
|
+
)
|
|
122
|
+
parser.add_argument(
|
|
123
|
+
"-dfp",
|
|
124
|
+
"--data_folder_path",
|
|
125
|
+
type=str,
|
|
126
|
+
default=DEFAULT_DATA_FOLDER_PATH,
|
|
127
|
+
help="Path to the folder where data is stored",
|
|
128
|
+
)
|
|
129
|
+
parser.add_argument(
|
|
130
|
+
"-ufp",
|
|
131
|
+
"--upload_folder_path",
|
|
132
|
+
type=str,
|
|
133
|
+
default=DEFAULT_DATA_FOLDER_PATH,
|
|
134
|
+
help="Path to the folder where uploads are stored",
|
|
135
|
+
)
|
|
136
|
+
parser.add_argument(
|
|
137
|
+
"-origins",
|
|
138
|
+
"--allowed_origins",
|
|
139
|
+
default=ORIGINS,
|
|
140
|
+
help="Origins that are allowed to connect to the server",
|
|
141
|
+
)
|
|
142
|
+
parser.add_argument(
|
|
143
|
+
"-t",
|
|
144
|
+
"--timeout",
|
|
145
|
+
default=TIMEOUT,
|
|
146
|
+
help="Number of minutes before the server times out",
|
|
147
|
+
)
|
|
148
|
+
args = parser.parse_args()
|
|
149
|
+
app.config.update(DATA_FOLDER_PATH=args.data_folder_path)
|
|
150
|
+
app.config.update(UPLOAD_FOLDER=args.upload_folder_path)
|
|
151
|
+
app.config.update(MINUTES_BEFORE_TIMEOUT=args.timeout)
|
|
152
|
+
flask_cors.CORS(app, origins=args.allowed_origins)
|
|
153
|
+
print(
|
|
154
|
+
f"Host: {args.host}, Port: {args.port}, Debug: {args.debug}, "
|
|
155
|
+
f"Data folder path: {args.data_folder_path}, Timeout: {args.timeout}, "
|
|
156
|
+
f"Origins: {args.allowed_origins}",
|
|
157
|
+
flush=True,
|
|
158
|
+
)
|
|
159
|
+
|
|
160
|
+
db_filename: str = app.config.get("DATABASE_FILENAME") or "project.db"
|
|
161
|
+
db_path = os.path.join(args.data_folder_path, db_filename)
|
|
162
|
+
os.makedirs(os.path.dirname(db_path), exist_ok=True)
|
|
163
|
+
app.config["SQLALCHEMY_DATABASE_URI"] = f"sqlite:///{db_path}"
|
|
164
|
+
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
|
|
165
|
+
|
|
166
|
+
connection.init_database(db_path)
|
|
167
|
+
print(f"Database initialized at: {db_path}", flush=True)
|
|
168
|
+
app.run(debug=args.debug, host=args.host, port=args.port, ssl_context=SSL)
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
# ''' Main '''
|
|
172
|
+
if __name__ == "__main__":
|
|
173
|
+
run_server()
|
opengeodeweb_back/app_config.py
CHANGED
|
@@ -4,9 +4,6 @@ import time
|
|
|
4
4
|
|
|
5
5
|
# Third party imports
|
|
6
6
|
# Local application imports
|
|
7
|
-
from opengeodeweb_microservice.database.connection import get_database
|
|
8
|
-
|
|
9
|
-
DATABASE_FILENAME = "project.db"
|
|
10
7
|
|
|
11
8
|
|
|
12
9
|
class Config(object):
|
|
@@ -18,7 +15,7 @@ class Config(object):
|
|
|
18
15
|
REQUEST_COUNTER = 0
|
|
19
16
|
LAST_REQUEST_TIME = time.time()
|
|
20
17
|
LAST_PING_TIME = time.time()
|
|
21
|
-
|
|
18
|
+
DATABASE_FILENAME = "project.db"
|
|
22
19
|
|
|
23
20
|
|
|
24
21
|
class ProdConfig(Config):
|
|
@@ -27,9 +24,6 @@ class ProdConfig(Config):
|
|
|
27
24
|
MINUTES_BEFORE_TIMEOUT = "1"
|
|
28
25
|
SECONDS_BETWEEN_SHUTDOWNS = "10"
|
|
29
26
|
DATA_FOLDER_PATH = "/data"
|
|
30
|
-
SQLALCHEMY_DATABASE_URI = f"sqlite:///{os.path.abspath(
|
|
31
|
-
os.path.join(DATA_FOLDER_PATH, DATABASE_FILENAME)
|
|
32
|
-
)}"
|
|
33
27
|
|
|
34
28
|
|
|
35
29
|
class DevConfig(Config):
|
|
@@ -39,6 +33,3 @@ class DevConfig(Config):
|
|
|
39
33
|
SECONDS_BETWEEN_SHUTDOWNS = "10"
|
|
40
34
|
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
41
35
|
DATA_FOLDER_PATH = os.path.join(BASE_DIR, "data")
|
|
42
|
-
SQLALCHEMY_DATABASE_URI = f"sqlite:///{os.path.join(
|
|
43
|
-
BASE_DIR, DATA_FOLDER_PATH, DATABASE_FILENAME
|
|
44
|
-
)}"
|
|
@@ -2,75 +2,47 @@
|
|
|
2
2
|
import os
|
|
3
3
|
|
|
4
4
|
# Third party imports
|
|
5
|
-
import opengeode_geosciences as og_gs # type: ignore
|
|
6
|
-
import opengeode as og # type: ignore
|
|
7
5
|
import werkzeug
|
|
8
6
|
import flask
|
|
9
|
-
from typing import Any
|
|
10
7
|
|
|
11
8
|
# Local application imports
|
|
12
|
-
from .geode_objects import
|
|
13
|
-
from . import
|
|
9
|
+
from .geode_objects import geode_objects
|
|
10
|
+
from .geode_objects.types import (
|
|
11
|
+
GeodeObjectType,
|
|
12
|
+
geode_object_type,
|
|
13
|
+
)
|
|
14
|
+
from .geode_objects.geode_object import GeodeObject
|
|
14
15
|
from opengeodeweb_microservice.database.data import Data
|
|
15
|
-
from opengeodeweb_microservice.database.connection import get_session
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
def
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
def input_factory(geode_object: str):
|
|
27
|
-
return geode_object_value(geode_object)["input_factory"]
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
def output_factory(geode_object: str):
|
|
31
|
-
return geode_object_value(geode_object)["output_factory"]
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
def additional_files(geode_object: str, file_absolute_path: str):
|
|
35
|
-
return geode_object_value(geode_object)["additional_files"](file_absolute_path)
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
def is_loadable(geode_object: str, file_absolute_path: str) -> float:
|
|
39
|
-
percentage = geode_object_value(geode_object)["is_loadable"](file_absolute_path)
|
|
40
|
-
return percentage.value()
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
def object_priority(geode_object: str, file_absolute_path: str) -> int:
|
|
44
|
-
return geode_object_value(geode_object)["object_priority"](file_absolute_path)
|
|
45
|
-
|
|
18
|
+
def data_file_path(data_id: str, filename: str | None = None) -> str:
|
|
19
|
+
data_folder_path = flask.current_app.config["DATA_FOLDER_PATH"]
|
|
20
|
+
data_path = os.path.join(data_folder_path, data_id)
|
|
21
|
+
if filename is not None:
|
|
22
|
+
return os.path.join(data_path, filename)
|
|
23
|
+
return data_path
|
|
46
24
|
|
|
47
|
-
def load(geode_object: str, file_absolute_path: str):
|
|
48
|
-
return geode_object_value(geode_object)["load"](file_absolute_path)
|
|
49
25
|
|
|
26
|
+
def geode_object_from_string(value: str) -> type[GeodeObject]:
|
|
27
|
+
return geode_objects[geode_object_type(value)]
|
|
50
28
|
|
|
51
|
-
def data_file_path(data_id: str, filename: str = "") -> str:
|
|
52
|
-
data_folder_path = flask.current_app.config["DATA_FOLDER_PATH"]
|
|
53
|
-
if filename:
|
|
54
|
-
return os.path.join(data_folder_path, data_id, filename)
|
|
55
|
-
return os.path.join(data_folder_path, data_id)
|
|
56
29
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
if not data_entry:
|
|
30
|
+
def load_geode_object(data_id: str) -> GeodeObject:
|
|
31
|
+
data = Data.get(data_id)
|
|
32
|
+
if not data:
|
|
61
33
|
flask.abort(404, f"Data with id {data_id} not found")
|
|
62
34
|
|
|
63
|
-
file_absolute_path = data_file_path(data_id,
|
|
35
|
+
file_absolute_path = data_file_path(data_id, data.native_file)
|
|
64
36
|
print("Loading file: ", file_absolute_path)
|
|
65
37
|
print("File exists: ", os.path.exists(file_absolute_path))
|
|
66
|
-
return
|
|
38
|
+
return geode_object_from_string(data.geode_object).load(file_absolute_path)
|
|
67
39
|
|
|
68
40
|
|
|
69
41
|
def get_data_info(data_id: str) -> Data:
|
|
70
|
-
|
|
71
|
-
if not
|
|
42
|
+
data = Data.get(data_id)
|
|
43
|
+
if not data:
|
|
72
44
|
flask.abort(404, f"Data with id {data_id} not found")
|
|
73
|
-
return
|
|
45
|
+
return data
|
|
74
46
|
|
|
75
47
|
|
|
76
48
|
def upload_file_path(filename: str) -> str:
|
|
@@ -79,237 +51,26 @@ def upload_file_path(filename: str) -> str:
|
|
|
79
51
|
return os.path.abspath(os.path.join(upload_folder, secure_filename))
|
|
80
52
|
|
|
81
53
|
|
|
82
|
-
def
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
)
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
def create_builder(geode_object: str, data):
|
|
93
|
-
return geode_object_value(geode_object)["builder"](data)
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
def assign_crs(geode_object: str, data, crs_name: str, info):
|
|
97
|
-
builder = create_builder(geode_object, data)
|
|
98
|
-
geode_object_value(geode_object)["crs"]["assign"](data, builder, crs_name, info)
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
def convert_crs(geode_object: str, data, crs_name: str, info):
|
|
102
|
-
builder = create_builder(geode_object, data)
|
|
103
|
-
geode_object_value(geode_object)["crs"]["convert"](data, builder, crs_name, info)
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
def create_crs(
|
|
107
|
-
geode_object: str,
|
|
108
|
-
data,
|
|
109
|
-
name: str,
|
|
110
|
-
input_coordiante_system,
|
|
111
|
-
output_coordiante_system,
|
|
112
|
-
):
|
|
113
|
-
builder = create_builder(geode_object, data)
|
|
114
|
-
geode_object_value(geode_object)["crs"]["create"](
|
|
115
|
-
data, builder, name, input_coordiante_system, output_coordiante_system
|
|
116
|
-
)
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
def get_object_type(geode_object: str):
|
|
120
|
-
return geode_object_value(geode_object)["object_type"]
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
def get_elements(geode_object: str):
|
|
124
|
-
return geode_object_value(geode_object)["elements"]
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
def is_3D(geode_object: str):
|
|
128
|
-
return geode_object_value(geode_object)["is_3D"]
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
def is_viewable(geode_object: str):
|
|
132
|
-
return geode_object_value(geode_object)["is_viewable"]
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
def inspect(geode_object: str, data):
|
|
136
|
-
return geode_object_value(geode_object)["inspector"](data)
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
def save_viewable(geode_object: str, data, folder_absolute_path: str, id: str):
|
|
140
|
-
return geode_object_value(geode_object)["save_viewable"](
|
|
141
|
-
data, os.path.join(folder_absolute_path, id)
|
|
142
|
-
)
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
def save_light_viewable(geode_object: str, data, folder_absolute_path: str, id: str):
|
|
146
|
-
return geode_object_value(geode_object)["save_light_viewable"](
|
|
147
|
-
data, os.path.join(folder_absolute_path, id)
|
|
148
|
-
)
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
def geode_object_input_extensions(geode_object: str):
|
|
152
|
-
geode_object_input_list_creators = input_factory(geode_object).list_creators()
|
|
153
|
-
geode_object_input_list_creators.sort()
|
|
154
|
-
return geode_object_input_list_creators
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
def geode_object_output_extensions(geode_object: str):
|
|
158
|
-
geode_object_output_list_creators = output_factory(geode_object).list_creators()
|
|
159
|
-
geode_object_output_list_creators.sort()
|
|
160
|
-
return geode_object_output_list_creators
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
def filter_geode_objects(key: str = None):
|
|
164
|
-
geode_objects_filtered_list = []
|
|
165
|
-
for geode_object, value in geode_objects_dict().items():
|
|
166
|
-
if key != None and key != "":
|
|
167
|
-
if key in value:
|
|
168
|
-
if type(value[key]) == bool:
|
|
169
|
-
geode_objects_filtered_list.append(geode_object)
|
|
170
|
-
else:
|
|
171
|
-
geode_objects_filtered_list.append(geode_object)
|
|
172
|
-
else:
|
|
173
|
-
geode_objects_filtered_list.append(geode_object)
|
|
174
|
-
geode_objects_filtered_list.sort()
|
|
175
|
-
return geode_objects_filtered_list
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
def list_input_extensions(key: str = None):
|
|
179
|
-
extensions_list = []
|
|
180
|
-
geode_objects_filtered_list = filter_geode_objects(key)
|
|
181
|
-
for geode_object in geode_objects_filtered_list:
|
|
182
|
-
extensions_list += geode_object_input_extensions(geode_object)
|
|
183
|
-
|
|
184
|
-
extensions_list = list(set(extensions_list))
|
|
185
|
-
extensions_list.sort()
|
|
186
|
-
return extensions_list
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
def has_creator(geode_object: str, extension: str):
|
|
190
|
-
return input_factory(geode_object).has_creator(extension)
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
def list_geode_objects(
|
|
194
|
-
file_absolute_path: str,
|
|
195
|
-
key: str = None,
|
|
196
|
-
):
|
|
197
|
-
return_dict = {}
|
|
198
|
-
file_extension = utils_functions.extension_from_filename(
|
|
199
|
-
os.path.basename(file_absolute_path)
|
|
200
|
-
)
|
|
201
|
-
geode_objects_filtered_list = filter_geode_objects(key)
|
|
202
|
-
for geode_object in geode_objects_filtered_list:
|
|
203
|
-
if has_creator(geode_object, file_extension):
|
|
204
|
-
loadability_score = is_loadable(geode_object, file_absolute_path)
|
|
205
|
-
priority_score = object_priority(geode_object, file_absolute_path)
|
|
206
|
-
return_dict[geode_object] = {
|
|
207
|
-
"is_loadable": loadability_score,
|
|
208
|
-
"object_priority": priority_score,
|
|
209
|
-
}
|
|
210
|
-
return return_dict
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
def geode_objects_output_extensions(geode_object: str, data):
|
|
214
|
-
geode_objects_output_extensions_dict = {}
|
|
215
|
-
output_extensions = geode_object_output_extensions(geode_object)
|
|
216
|
-
extensions_dict = {}
|
|
217
|
-
for output_extension in output_extensions:
|
|
218
|
-
bool_is_saveable = is_saveable(geode_object, data, f"test.{output_extension}")
|
|
219
|
-
extensions_dict[output_extension] = {"is_saveable": bool_is_saveable}
|
|
220
|
-
geode_objects_output_extensions_dict[geode_object] = extensions_dict
|
|
221
|
-
|
|
222
|
-
if "parent" in geode_object_value(geode_object).keys():
|
|
223
|
-
parent_geode_object = geode_object_value(geode_object)["parent"]
|
|
224
|
-
geode_objects_output_extensions_dict.update(
|
|
225
|
-
geode_objects_output_extensions(parent_geode_object, data)
|
|
226
|
-
)
|
|
227
|
-
return geode_objects_output_extensions_dict
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
def get_inspector_children(obj):
|
|
231
|
-
new_object = {}
|
|
232
|
-
|
|
233
|
-
if "inspection_type" in dir(obj):
|
|
234
|
-
new_object["title"] = obj.inspection_type()
|
|
235
|
-
new_object["nb_issues"] = 0
|
|
236
|
-
new_object["children"] = []
|
|
237
|
-
for child in dir(obj):
|
|
238
|
-
if not child.startswith("__") and not child in [
|
|
239
|
-
"inspection_type",
|
|
240
|
-
"string",
|
|
241
|
-
]:
|
|
242
|
-
child_instance = obj.__getattribute__(child)
|
|
243
|
-
child_object = get_inspector_children(child_instance)
|
|
244
|
-
new_object["children"].append(child_object)
|
|
245
|
-
new_object["nb_issues"] += child_object["nb_issues"]
|
|
246
|
-
else:
|
|
247
|
-
new_object["title"] = obj.description()
|
|
248
|
-
nb_issues = obj.nb_issues()
|
|
249
|
-
new_object["nb_issues"] = nb_issues
|
|
250
|
-
if nb_issues > 0:
|
|
251
|
-
issues = obj.string().split("\n")
|
|
252
|
-
new_object["issues"] = issues
|
|
253
|
-
return new_object
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
def geographic_coordinate_systems(geode_object: str):
|
|
257
|
-
if is_3D(geode_object):
|
|
258
|
-
return og_gs.GeographicCoordinateSystem3D.geographic_coordinate_systems()
|
|
259
|
-
else:
|
|
260
|
-
return og_gs.GeographicCoordinateSystem2D.geographic_coordinate_systems()
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
def geographic_coordinate_systems_info(geode_object: str, crs):
|
|
264
|
-
if is_3D(geode_object):
|
|
265
|
-
return og_gs.GeographicCoordinateSystemInfo3D(
|
|
266
|
-
crs["authority"], crs["code"], crs["name"]
|
|
54
|
+
def geode_object_output_extensions(
|
|
55
|
+
geode_object: GeodeObject,
|
|
56
|
+
) -> dict[GeodeObjectType, dict[str, bool]]:
|
|
57
|
+
results: dict[GeodeObjectType, dict[str, bool]] = {}
|
|
58
|
+
for mixin_geode_object in geode_objects[geode_object.geode_object_type()].__mro__:
|
|
59
|
+
output_extensions_method = getattr(
|
|
60
|
+
mixin_geode_object, "output_extensions", None
|
|
267
61
|
)
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
),
|
|
284
|
-
),
|
|
285
|
-
og.Vector2D(
|
|
286
|
-
og.Point2D(
|
|
287
|
-
[coordinate_system["origin_x"], coordinate_system["origin_y"]]
|
|
288
|
-
),
|
|
289
|
-
og.Point2D(
|
|
290
|
-
[coordinate_system["point_2_x"], coordinate_system["point_2_y"]]
|
|
291
|
-
),
|
|
292
|
-
),
|
|
293
|
-
],
|
|
294
|
-
og.Point2D([coordinate_system["origin_x"], coordinate_system["origin_y"]]),
|
|
295
|
-
)
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
def assign_geographic_coordinate_system_info(geode_object: str, data, input_crs):
|
|
299
|
-
info = geographic_coordinate_systems_info(geode_object, input_crs)
|
|
300
|
-
assign_crs(geode_object, data, input_crs["name"], info)
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
def convert_geographic_coordinate_system_info(geode_object: str, data, output_crs):
|
|
304
|
-
info = geographic_coordinate_systems_info(geode_object, output_crs)
|
|
305
|
-
convert_crs(geode_object, data, output_crs["name"], info)
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
def create_coordinate_system(
|
|
309
|
-
geode_object: str, data, name, input_coordinate_points, output_coordinate_points
|
|
310
|
-
):
|
|
311
|
-
input_coordiante_system = coordinate_system(geode_object, input_coordinate_points)
|
|
312
|
-
output_coordiante_system = coordinate_system(geode_object, output_coordinate_points)
|
|
313
|
-
create_crs(
|
|
314
|
-
geode_object, data, name, input_coordiante_system, output_coordiante_system
|
|
315
|
-
)
|
|
62
|
+
if output_extensions_method is None:
|
|
63
|
+
continue
|
|
64
|
+
output_extensions = output_extensions_method.__func__(mixin_geode_object)
|
|
65
|
+
if output_extensions is None:
|
|
66
|
+
continue
|
|
67
|
+
object_output_extensions: dict[str, bool] = {}
|
|
68
|
+
is_saveable_method = getattr(mixin_geode_object, "is_saveable")
|
|
69
|
+
for output_extension in output_extensions:
|
|
70
|
+
bool_is_saveable = is_saveable_method(
|
|
71
|
+
geode_object, f"test.{output_extension}"
|
|
72
|
+
)
|
|
73
|
+
object_output_extensions[output_extension] = bool_is_saveable
|
|
74
|
+
if hasattr(mixin_geode_object, "geode_object_type"):
|
|
75
|
+
results[mixin_geode_object.geode_object_type()] = object_output_extensions
|
|
76
|
+
return results
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# Standard library imports
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
# Third party imports
|
|
5
|
+
|
|
6
|
+
# Local application imports
|
|
7
|
+
from .types import GeodeObjectType
|
|
8
|
+
from .geode_object import GeodeObject
|
|
9
|
+
from .geode_brep import GeodeBRep
|
|
10
|
+
from .geode_vertex_set import GeodeVertexSet
|
|
11
|
+
from .geode_graph import GeodeGraph
|
|
12
|
+
from .geode_point_set2d import GeodePointSet2D
|
|
13
|
+
from .geode_point_set3d import GeodePointSet3D
|
|
14
|
+
from .geode_edged_curve2d import GeodeEdgedCurve2D
|
|
15
|
+
from .geode_edged_curve3d import GeodeEdgedCurve3D
|
|
16
|
+
from .geode_raster_image2d import GeodeRasterImage2D
|
|
17
|
+
from .geode_raster_image3d import GeodeRasterImage3D
|
|
18
|
+
from .geode_polygonal_surface2d import GeodePolygonalSurface2D
|
|
19
|
+
from .geode_polygonal_surface3d import GeodePolygonalSurface3D
|
|
20
|
+
from .geode_triangulated_surface2d import GeodeTriangulatedSurface2D
|
|
21
|
+
from .geode_triangulated_surface3d import GeodeTriangulatedSurface3D
|
|
22
|
+
from .geode_regular_grid2d import GeodeRegularGrid2D
|
|
23
|
+
from .geode_polyhedral_solid3d import GeodePolyhedralSolid3D
|
|
24
|
+
from .geode_tetrahedral_solid3d import GeodeTetrahedralSolid3D
|
|
25
|
+
from .geode_hybrid_solid3d import GeodeHybridSolid3D
|
|
26
|
+
from .geode_regular_grid3d import GeodeRegularGrid3D
|
|
27
|
+
from .geode_light_regular_grid2d import GeodeLightRegularGrid2D
|
|
28
|
+
from .geode_light_regular_grid3d import GeodeLightRegularGrid3D
|
|
29
|
+
from .geode_section import GeodeSection
|
|
30
|
+
from .geode_structural_model import GeodeStructuralModel
|
|
31
|
+
from .geode_cross_section import GeodeCrossSection
|
|
32
|
+
from .geode_implicit_structural_model import GeodeImplicitStructuralModel
|
|
33
|
+
from .geode_implicit_cross_section import GeodeImplicitCrossSection
|
|
34
|
+
|
|
35
|
+
geode_objects: dict[GeodeObjectType, type[GeodeObject]] = {
|
|
36
|
+
"VertexSet": GeodeVertexSet,
|
|
37
|
+
"Graph": GeodeGraph,
|
|
38
|
+
"PointSet2D": GeodePointSet2D,
|
|
39
|
+
"PointSet3D": GeodePointSet3D,
|
|
40
|
+
"EdgedCurve2D": GeodeEdgedCurve2D,
|
|
41
|
+
"EdgedCurve3D": GeodeEdgedCurve3D,
|
|
42
|
+
"RasterImage2D": GeodeRasterImage2D,
|
|
43
|
+
"RasterImage3D": GeodeRasterImage3D,
|
|
44
|
+
"PolygonalSurface2D": GeodePolygonalSurface2D,
|
|
45
|
+
"PolygonalSurface3D": GeodePolygonalSurface3D,
|
|
46
|
+
"TriangulatedSurface2D": GeodeTriangulatedSurface2D,
|
|
47
|
+
"TriangulatedSurface3D": GeodeTriangulatedSurface3D,
|
|
48
|
+
"RegularGrid2D": GeodeRegularGrid2D,
|
|
49
|
+
"PolyhedralSolid3D": GeodePolyhedralSolid3D,
|
|
50
|
+
"TetrahedralSolid3D": GeodeTetrahedralSolid3D,
|
|
51
|
+
"HybridSolid3D": GeodeHybridSolid3D,
|
|
52
|
+
"RegularGrid3D": GeodeRegularGrid3D,
|
|
53
|
+
"LightRegularGrid2D": GeodeLightRegularGrid2D,
|
|
54
|
+
"LightRegularGrid3D": GeodeLightRegularGrid3D,
|
|
55
|
+
"BRep": GeodeBRep,
|
|
56
|
+
"Section": GeodeSection,
|
|
57
|
+
"StructuralModel": GeodeStructuralModel,
|
|
58
|
+
"CrossSection": GeodeCrossSection,
|
|
59
|
+
"ImplicitStructuralModel": GeodeImplicitStructuralModel,
|
|
60
|
+
"ImplicitCrossSection": GeodeImplicitCrossSection,
|
|
61
|
+
}
|