Skip to content

Commit 2c7cc45

Browse files
build: update geoengine-openapi-client dependency to 0.0.33 (#259)
* build: update geoengine-openapi-client dependency to 0.0.33 * fix: correct workflow parameter in add_layer_to_collection function * fix: update geoengine-openapi-client URL to use HTTPS * fix: update workflow handling in Layer class and add SpatialResolutionDict type * refactor: VectorExpression to support output_column as a dictionary - Updated the to_dict method to handle output_column as a dictionary in addition to GeoVectorDataType. - Changed the operator type check in from_operator_dict method to "VectorExpression" for consistency. - Modified the output_measurement assignment to use geoengine_openapi_client.Measurement.from_dict for better integration. * change geoengine-openapi-client dependency to version 0.0.33
1 parent a3df64b commit 2c7cc45

File tree

5 files changed

+47
-26
lines changed

5 files changed

+47
-26
lines changed

examples/expression.ipynb

Lines changed: 16 additions & 12 deletions
Large diffs are not rendered by default.

geoengine/layers.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -603,12 +603,14 @@ def from_response(cls, response: geoengine_openapi_client.Layer) -> Layer:
603603
if response.symbology is not None:
604604
symbology = Symbology.from_response(response.symbology)
605605

606+
workflow_dict = cast(dict[str, Any], response.workflow.to_dict()) # silence mypy here
607+
606608
return Layer(
607609
name=response.name,
608610
description=response.description,
609611
layer_id=LayerId(response.id.layer_id),
610612
provider_id=LayerProviderId(response.id.provider_id),
611-
workflow=response.workflow.to_dict(),
613+
workflow=workflow_dict,
612614
symbology=symbology,
613615
properties=cast(list[Any], response.properties),
614616
metadata=cast(dict[Any, Any], response.metadata),
@@ -852,7 +854,10 @@ def _add_layer_to_collection(
852854
response = layers_api.add_layer(
853855
collection_id,
854856
geoengine_openapi_client.AddLayer(
855-
name=name, description=description, workflow=workflow, symbology=symbology_dict
857+
name=name,
858+
description=description,
859+
workflow=geoengine_openapi_client.Workflow.from_dict(workflow),
860+
symbology=symbology_dict,
856861
),
857862
_request_timeout=timeout,
858863
)

geoengine/types.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from abc import abstractmethod
1010
from datetime import datetime, timezone
1111
from enum import Enum
12-
from typing import Any, Literal, cast
12+
from typing import Any, Literal, TypedDict, cast
1313
from uuid import UUID
1414

1515
import geoengine_openapi_client
@@ -248,6 +248,13 @@ def __eq__(self, other: Any) -> bool:
248248
return self.start == other.start and self.end == other.end
249249

250250

251+
class SpatialResolutionDict(TypedDict):
252+
"""A spatial resolution as a dictionary"""
253+
254+
x: float
255+
y: float
256+
257+
251258
class SpatialResolution:
252259
"""'A spatial resolution."""
253260

@@ -262,16 +269,16 @@ def __init__(self, x_resolution: float, y_resolution: float) -> None:
262269
self.x_resolution = x_resolution
263270
self.y_resolution = y_resolution
264271

265-
def to_api_dict(self) -> geoengine_openapi_client.SpatialResolution:
266-
return geoengine_openapi_client.SpatialResolution(
267-
x=self.x_resolution,
268-
y=self.y_resolution,
269-
)
272+
def to_api_dict(self) -> SpatialResolutionDict:
273+
return {
274+
"x": self.x_resolution,
275+
"y": self.y_resolution,
276+
}
270277

271278
@staticmethod
272-
def from_response(response: geoengine_openapi_client.SpatialResolution) -> SpatialResolution:
279+
def from_response(response: SpatialResolutionDict) -> SpatialResolution:
273280
"""create a `SpatialResolution` from an API response"""
274-
return SpatialResolution(x_resolution=response.x, y_resolution=response.y)
281+
return SpatialResolution(x_resolution=response["x"], y_resolution=response["y"])
275282

276283
def as_tuple(self) -> tuple[float, float]:
277284
return (self.x_resolution, self.y_resolution)

geoengine/workflow_builder/operators.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -851,7 +851,10 @@ def name(self) -> str:
851851

852852
def to_dict(self) -> dict[str, Any]:
853853
output_column_dict = None
854-
if isinstance(self.output_column, GeoVectorDataType):
854+
855+
if isinstance(self.output_column, dict):
856+
output_column_dict = self.output_column
857+
elif isinstance(self.output_column, GeoVectorDataType):
855858
output_column_dict = {
856859
"type": "geometry",
857860
"value": self.output_column.value,
@@ -880,7 +883,7 @@ def to_dict(self) -> dict[str, Any]:
880883

881884
@classmethod
882885
def from_operator_dict(cls, operator_dict: dict[str, Any]) -> VectorExpression:
883-
if operator_dict["type"] != "Expression":
886+
if operator_dict["type"] != "VectorExpression":
884887
raise ValueError("Invalid operator type")
885888

886889
geometry_column_name = None
@@ -889,7 +892,9 @@ def from_operator_dict(cls, operator_dict: dict[str, Any]) -> VectorExpression:
889892

890893
output_measurement = None
891894
if "outputMeasurement" in operator_dict["params"]:
892-
output_measurement = Measurement.from_response(operator_dict["params"]["outputMeasurement"])
895+
output_measurement = Measurement.from_response(
896+
geoengine_openapi_client.Measurement.from_dict(operator_dict["params"]["outputMeasurement"])
897+
)
893898

894899
return VectorExpression(
895900
source=VectorOperator.from_operator_dict(operator_dict["sources"]["vector"]),

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ readme = { file = "README.md", content-type = "text/markdown" }
1616
license-files = ["LICENSE"]
1717
requires-python = ">=3.10"
1818
dependencies = [
19-
"geoengine-openapi-client == 0.0.31",
19+
"geoengine-openapi-client == 0.0.33",
2020
"geopandas >=1.0,<2.0",
2121
"matplotlib >=3.6,<3.11",
2222
"numpy >=1.23,<2.5",

0 commit comments

Comments
 (0)