Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
801 changes: 719 additions & 82 deletions opengeodeweb_back_schemas.json

Large diffs are not rendered by default.

527 changes: 135 additions & 392 deletions opengeodeweb_back_typed_schemas.d.ts

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
"files": [
"opengeodeweb_back_schemas.json",
"opengeodeweb_back_typed_schemas.js",
"opengeodeweb_back_typed_schemas.d.ts"
"opengeodeweb_back_typed_schemas.d.ts",
"src/opengeodeweb_back/schema_types.json",
"src/opengeodeweb_back/schema_types.d.ts",
"src/opengeodeweb_back/schema_types.py"
],
"exports": {
"./opengeodeweb_back_schemas.json": {
Expand All @@ -29,6 +32,9 @@
"./opengeodeweb_back_typed_schemas.js": {
"types": "./opengeodeweb_back_typed_schemas.d.ts",
"default": "./opengeodeweb_back_typed_schemas.js"
},
"./schema_types": {
"types": "./src/opengeodeweb_back/schema_types.d.ts"
}
},
"publishConfig": {
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ where = ["src"]
"opengeodeweb_back.routes.create.schemas" = ["*.json"]
"opengeodeweb_back.routes.crs.schemas" = ["*.json"]
"opengeodeweb_back.routes.basemap.schemas" = ["*.json"]
"opengeodeweb_back" = ["py.typed"]
"opengeodeweb_back" = ["py.typed", "schema_definitions.json"]
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,3 @@ werkzeug==3.1.8
# flask
# flask-cors

opengeodeweb-microservice==1.*,>=1.3.3
6 changes: 3 additions & 3 deletions src/opengeodeweb_back/geode_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def geode_object_output_extensions(
return results


def objects_to_load(allowed: dict[str, AllowedObject]) -> list[str]:
def objects_to_load(allowed: dict[str, AllowedObject]) -> list[GeodeObjectType]:
"""Pick the one type to load per content family so the whole file is loaded.

Per family: keep loadable candidates, then highest is_loadable, then highest
Expand All @@ -100,13 +100,13 @@ def objects_to_load(allowed: dict[str, AllowedObject]) -> list[str]:
families.setdefault(allowed_object.loadable_family, []).append(
(object_type, allowed_object)
)
winners: list[str] = []
winners: list[GeodeObjectType] = []
for candidates in families.values():
best_loadable = max(candidate.is_loadable for _, candidate in candidates)
best = [c for c in candidates if c[1].is_loadable == best_loadable]
best_priority = max(candidate.object_priority for _, candidate in best)
best = [c for c in best if c[1].object_priority == best_priority]
if len(best) != 1:
return []
winners.append(best[0][0])
winners.append(geode_object_type(best[0][0]))
return winners
3 changes: 2 additions & 1 deletion src/opengeodeweb_back/routes/basemap/blueprint_basemap.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from opengeodeweb_back.geode_objects.geode_triangulated_surface3d import (
GeodeTriangulatedSurface3D,
)
from opengeodeweb_back.schema_types import CRS

routes = flask.Blueprint("basemap", __name__, url_prefix="/basemap")
logger = logging.getLogger(__name__)
Expand All @@ -48,7 +49,7 @@ def padded(bounds: tuple[float, float, float, float]) -> tuple[float, float, flo
)


def _crs(params: schemas.CRSParams) -> og_geosciences.GeographicCoordinateSystemInfo:
def _crs(params: CRS) -> og_geosciences.GeographicCoordinateSystemInfo:
key = f"{params.authority}:{params.code}"
# The basemap is a 3D mesh: only list the CRS a 3D object accepts
crs = geographic_coordinate_systems(True).get(key) # noqa: FBT003
Expand Down
94 changes: 38 additions & 56 deletions src/opengeodeweb_back/routes/basemap/schemas/build.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,34 +43,21 @@
"additionalProperties": false
},
"crs": {
"title": "CRSParams",
"type": "object",
"properties": {
"authority": {
"type": "string",
"minLength": 1
},
"code": {
"type": "string",
"minLength": 1
},
"name": {
"type": "string",
"minLength": 1
}
},
"required": [
"authority",
"code",
"name"
],
"additionalProperties": false
"title": "CRS"
},
"z": {
"type": "number"
},
"margin": { "type": "boolean", "default": true },
"max_pixels": { "type": "integer", "minimum": 256, "maximum": 4096, "default": 2048 }
"margin": {
"type": "boolean",
"default": true
},
"max_pixels": {
"type": "integer",
"minimum": 256,
"maximum": 4096,
"default": 2048
}
},
"required": [
"maps",
Expand All @@ -86,21 +73,19 @@
"type": "string"
},
"id": {
"type": "string",
"minLength": 32,
"maxLength": 32
"title": "DataId"
},
"name": {
"type": "string"
},
"viewer_object_type": {
"type": "string"
"title": "ViewerObjectType"
},
"is_viewable": {
"type": "boolean"
},
"geode_object_type": {
"type": "string"
"title": "GeodeObjectType"
},
"viewable_file": {
"type": "string"
Expand All @@ -112,29 +97,10 @@
"type": "integer"
},
"geode_id": {
"type": "string",
"minLength": 36,
"maxLength": 36
"title": "GeodeId"
},
"crs": {
"type": "object",
"properties": {
"authority": {
"type": "string"
},
"code": {
"type": "string"
},
"name": {
"type": "string"
}
},
"required": [
"authority",
"code",
"name"
],
"additionalProperties": false
"title": "CRS"
},
"columns": {
"type": "integer",
Expand All @@ -147,17 +113,33 @@
"attribution": {
"type": "string"
},
"zoom": { "type": "integer", "minimum": 0 },
"zoom": {
"type": "integer",
"minimum": 0
},
"bounds": {
"title": "MeshBounds",
"type": "object",
"properties": {
"x_min": { "type": "number" },
"y_min": { "type": "number" },
"x_max": { "type": "number" },
"y_max": { "type": "number" }
"x_min": {
"type": "number"
},
"y_min": {
"type": "number"
},
"x_max": {
"type": "number"
},
"y_max": {
"type": "number"
}
},
"required": ["x_min", "y_min", "x_max", "y_max"],
"required": [
"x_min",
"y_min",
"x_max",
"y_max"
],
"additionalProperties": false
},
"maps": {
Expand Down
35 changes: 9 additions & 26 deletions src/opengeodeweb_back/routes/basemap/schemas/build.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from opengeodeweb_microservice.schema_types import DataId, GeodeId
from opengeodeweb_microservice.database.data_types import GeodeObjectType, ViewerObjectType
from opengeodeweb_back.schema_types import CRS
from pathlib import Path
from opengeodeweb_microservice.schemas import Route, load_schema
from dataclasses_json import DataClassJsonMixin
Expand All @@ -18,16 +21,6 @@ def __post_init__(self) -> None:
y_min: float


@dataclass
class CRSParams(DataClassJsonMixin):
def __post_init__(self) -> None:
print_dataclass(self)

authority: str
code: str
name: str


class Map(Enum):
PLAN = "plan"
ROUTES = "routes"
Expand All @@ -40,7 +33,7 @@ def __post_init__(self) -> None:
print_dataclass(self)

bounds: Bounds
crs: CRSParams
crs: CRS
maps: List[Map]
z: float
margin: Optional[bool] = None
Expand All @@ -58,16 +51,6 @@ def __post_init__(self) -> None:
y_min: float


@dataclass
class CRS(DataClassJsonMixin):
def __post_init__(self) -> None:
print_dataclass(self)

authority: str
code: str
name: str


@dataclass
class MapElement(DataClassJsonMixin):
def __post_init__(self) -> None:
Expand All @@ -85,15 +68,15 @@ def __post_init__(self) -> None:
attribution: str
bounds: MeshBounds
columns: int
geode_id: str
geode_object_type: str
id: str
geode_id: GeodeId
geode_object_type: GeodeObjectType
id: DataId
is_viewable: bool
maps: List[MapElement]
name: str
native_file: str
rows: int
viewer_object_type: str
viewer_object_type: ViewerObjectType
zoom: int
binary_light_viewable: Optional[str] = None
crs: Optional[CRS] = None
Expand All @@ -107,4 +90,4 @@ def __post_init__(self) -> None:
response=BuildResponse,
)

__all__ = ["Bounds", "CRSParams", "Build", "BuildResponse", "build_route"]
__all__ = ["Bounds", "CRS", "Build", "BuildResponse", "build_route"]
6 changes: 2 additions & 4 deletions src/opengeodeweb_back/routes/basemap/schemas/delete.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
"type": "object",
"properties": {
"id": {
"type": "string",
"minLength": 32,
"maxLength": 32
"title": "DataId"
}
},
"required": [
Expand All @@ -19,7 +17,7 @@
"type": "object",
"properties": {
"id": {
"type": "string"
"title": "DataId"
}
},
"required": [
Expand Down
5 changes: 3 additions & 2 deletions src/opengeodeweb_back/routes/basemap/schemas/delete.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from opengeodeweb_microservice.schema_types import DataId
from pathlib import Path
from opengeodeweb_microservice.schemas import Route, load_schema
from dataclasses_json import DataClassJsonMixin
Expand All @@ -10,15 +11,15 @@ class Delete(DataClassJsonMixin):
def __post_init__(self) -> None:
print_dataclass(self)

id: str
id: DataId


@dataclass
class DeleteResponse(DataClassJsonMixin):
def __post_init__(self) -> None:
print_dataclass(self)

id: str
id: DataId


delete_route = Route(
Expand Down
5 changes: 3 additions & 2 deletions src/opengeodeweb_back/routes/blueprint_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
from opengeodeweb_back.typed_route import parse_params, raw_route, typed_route

if TYPE_CHECKING:
from opengeodeweb_microservice.database.data_types import GeodeObjectType
from werkzeug.datastructures import FileStorage


Expand Down Expand Up @@ -1001,8 +1002,8 @@ def get_all_subclasses(geode_class: type) -> set[type]:
subclass_classes = get_all_subclasses(target_class)

# Filter GeodeObjectType to only include registered related objects, excluding target
parents: list[str] = []
children: list[str] = []
parents: list[GeodeObjectType] = []
children: list[GeodeObjectType] = []
for geode_object_type_str, geode_class in geode_objects.items():
if geode_class == target_class:
continue
Expand Down
Loading
Loading