From f1a5f440cdeb592dfc9ce6b29dd57c9930cd40ac Mon Sep 17 00:00:00 2001 From: MaxNumerique Date: Mon, 23 Nov 2026 10:15:07 +0100 Subject: [PATCH 1/4] fix(crs): assign a CRS to models whose blocks have no mesh coordinates_implausible called bounding_box() on every CRS mesh, and an empty SolidMesh throws. Models built from surfaces often keep their blocks without mesh, so any assign failed on them. Skip empty meshes. Refs Geode-solutions/Vease#873 Co-Authored-By: Claude Opus 5.5 --- src/opengeodeweb_back/crs/crs_functions.py | 3 ++- tests/test_crs_routes.py | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/opengeodeweb_back/crs/crs_functions.py b/src/opengeodeweb_back/crs/crs_functions.py index be0350aa..32c7a4fc 100644 --- a/src/opengeodeweb_back/crs/crs_functions.py +++ b/src/opengeodeweb_back/crs/crs_functions.py @@ -206,7 +206,8 @@ def coordinates_implausible( geode_object: CrsGeodeObject, info: og_geosciences.GeographicCoordinateSystemInfo ) -> bool: """Whether the data XY extent, read in info, misses the area where info is used.""" - boxes = [mesh.bounding_box() for mesh in geode_object.crs_meshes()] + # Empty meshes, like blocks of a model built from surfaces, have no bounding box + boxes = [mesh.bounding_box() for mesh in geode_object.crs_meshes() if mesh.nb_vertices() > 0] # Without mesh, the infinite bounds below mark the data as implausible bounds = ( min((box.min().value(0) for box in boxes), default=math.inf), diff --git a/tests/test_crs_routes.py b/tests/test_crs_routes.py index 6687438c..a534581b 100644 --- a/tests/test_crs_routes.py +++ b/tests/test_crs_routes.py @@ -635,6 +635,16 @@ def test_assign_only_plausible(client: FlaskClient) -> None: assert _active_crs(client, plausible_id) == LAMBERT +def test_assign_geographic_model_without_block_meshes(client: FlaskClient) -> None: + route = "/opengeodeweb_back/crs/assign_geographic" + # Models built from surfaces often keep their blocks without mesh + [brep] = test_utils.check_save_viewable_file(client, "BRep", "corbi.og_brep") + response = client.post(route, json={"id": brep["id"], **LAMBERT}) + assert response.status_code == 200 + assert response.get_json()["crs"] == LAMBERT + assert _active_crs(client, brep["id"]) == LAMBERT + + def test_assign_linked(client: FlaskClient) -> None: route = "/opengeodeweb_back/crs/assign_geographic" point_set_id = _create_point_set(client) From 99b0eb860e62217d6fd2b1e5c171db14df36677d Mon Sep 17 00:00:00 2001 From: MaxNumerique Date: Mon, 23 Nov 2026 10:16:01 +0100 Subject: [PATCH 2/4] fix(crs): stop offering vertical CRSs for X and Y The CRS list offered the 497 height-only CRSs PROJ knows, like EPSG:7839 NZVD2016 height. Assigned to data, they label X and Y with a height axis: the plausibility check cannot convert them, and every later conversion fails. With older Geosciences, the null transformation even crashed the back-end. Leave the CRSs of the vertical_crs table of proj.db out of the list. known_info reads the same list, so assigning one is now refused too. Refs Geode-solutions/Vease#873 Co-Authored-By: Claude Opus 5.5 --- src/opengeodeweb_back/crs/crs_functions.py | 11 ++++++++++- tests/test_crs_routes.py | 16 ++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/opengeodeweb_back/crs/crs_functions.py b/src/opengeodeweb_back/crs/crs_functions.py index 32c7a4fc..e27cdcaf 100644 --- a/src/opengeodeweb_back/crs/crs_functions.py +++ b/src/opengeodeweb_back/crs/crs_functions.py @@ -94,7 +94,9 @@ def geographic_coordinate_systems( if is_3d else og_geosciences.GeographicCoordinateSystem2D.geographic_coordinate_systems() ) - return {info.authority_code(): info for info in infos} + # A height-only CRS cannot place X and Y: converting them fails afterwards + vertical = vertical_coordinate_systems() + return {info.authority_code(): info for info in infos if info.authority_code() not in vertical} def known_geographic_info( @@ -188,6 +190,13 @@ def area_of_use(authority: str, code: str) -> list[tuple[float, float, float, fl return [(float(s), float(n), float(w), float(e)) for s, n, w, e in rows] +@functools.cache +def vertical_coordinate_systems() -> frozenset[str]: + """Height or depth only CRS PROJ knows, as "AUTHORITY:CODE".""" + rows = _query_proj_database("SELECT auth_name, code FROM vertical_crs", ()) or [] + return frozenset(f"{authority}:{code}" for authority, code in rows) + + def _overlaps( latitudes: tuple[float, float], longitudes: tuple[float, float], diff --git a/tests/test_crs_routes.py b/tests/test_crs_routes.py index a534581b..a330712d 100644 --- a/tests/test_crs_routes.py +++ b/tests/test_crs_routes.py @@ -558,6 +558,22 @@ def test_unknown_crs(client: FlaskClient) -> None: assert response.status_code == 400 +def test_vertical_crs_not_offered(client: FlaskClient) -> None: + # A height-only CRS cannot place X and Y + vertical = {"authority": "EPSG", "code": "7839", "name": "NZVD2016 height"} + response = client.post( + "/opengeodeweb_back/crs/geographic_list", json={"geode_object_type": "PointSet3D"} + ) + codes = {(crs["authority"], crs["code"]) for crs in response.get_json()["crs_list"]} + assert ("EPSG", "7839") not in codes + assert ("EPSG", "2193") in codes + [point_set] = test_utils.check_save_viewable_file(client, "PointSet3D", "test.og_pts3d") + response = client.post( + "/opengeodeweb_back/crs/assign_geographic", json={"id": point_set["id"], **vertical} + ) + assert response.status_code == 400 + + def test_assign_only_rewrites_the_native_file(client: FlaskClient) -> None: [point_set] = test_utils.check_save_viewable_file(client, "PointSet3D", "test.og_pts3d") point_set_id = point_set["id"] From 367355f0aff1f7ad95153bc718d9522fd62078f1 Mon Sep 17 00:00:00 2001 From: MaxNumerique <144453705+MaxNumerique@users.noreply.github.com> Date: Mon, 23 Nov 2026 09:40:56 +0000 Subject: [PATCH 3/4] Apply prepare changes --- requirements.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 5c24d6ce..597e5178 100644 --- a/requirements.txt +++ b/requirements.txt @@ -84,4 +84,3 @@ werkzeug==3.1.8 # flask # flask-cors -opengeodeweb-microservice==1.*,>=1.4.0 From 15807bd8cf0718921106c8c2f79b519e51729fc5 Mon Sep 17 00:00:00 2001 From: MaxNumerique <144453705+MaxNumerique@users.noreply.github.com> Date: Mon, 23 Nov 2026 14:01:58 +0000 Subject: [PATCH 4/4] Apply prepare changes --- requirements.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 5c24d6ce..597e5178 100644 --- a/requirements.txt +++ b/requirements.txt @@ -84,4 +84,3 @@ werkzeug==3.1.8 # flask # flask-cors -opengeodeweb-microservice==1.*,>=1.4.0