From e377c014a7f8eac984d66c600d957c6e6cc9781d Mon Sep 17 00:00:00 2001 From: phil Date: Thu, 14 Mar 2024 17:02:04 +0530 Subject: [PATCH] Update/fix plot params --- src/gisaf/api/main.py | 17 ++++++++++++++++- src/gisaf/models/info.py | 6 +++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/gisaf/api/main.py b/src/gisaf/api/main.py index 3e42922..bbd6ee8 100644 --- a/src/gisaf/api/main.py +++ b/src/gisaf/api/main.py @@ -16,7 +16,9 @@ from gisaf.models.authentication import ( ) from gisaf.models.category import Category, CategoryRead from gisaf.models.geo_models_base import GeoModel, PlottableModel -from gisaf.models.info import LegendItem, ModelAction, ModelInfo, DataProvider, ModelValue, TagActions +from gisaf.models.info import (LegendItem, ModelAction, ModelInfo, + DataProvider, ModelValue, PlotParams, + TagActions) from gisaf.models.measures import MeasuresItem from gisaf.models.survey import Equipment, SurveyMeta, Surveyor from gisaf.config import Survey, conf @@ -355,6 +357,19 @@ async def get_model_info( model_info['downloaders'] = plugin_manager.downloaders_stores[store] return ModelInfo(**model_info) +@api.get("/plot-params/{store}") +async def get_plot_params( + store: str, id: str, value: str + ) -> PlotParams: + model = registry.geom.get(store) + ## Get additional plot params + if hasattr(model, 'get_plot_params'): + plot_params: PlotParams = await model.get_plot_params(id, value) + return plot_params + else: + raise HTTPException(status_code=status.HTTP_204_NO_CONTENT) + + # @api.get("/user-role") # async def get_user_role_relation( # *, db_session: AsyncSession = Depends(get_db_session) diff --git a/src/gisaf/models/info.py b/src/gisaf/models/info.py index 05e8e37..5a2bae4 100644 --- a/src/gisaf/models/info.py +++ b/src/gisaf/models/info.py @@ -39,9 +39,9 @@ class PlotBaseLine(BaseModel): class PlotParams(BaseModel): - baseLines: list[PlotBaseLine] - bgShape: list[PlotBgShape] - barBase: float + baseLines: list[PlotBaseLine] = [] + bgShapes: list[PlotBgShape] = [] + barBase: float | None = None class Attachment(BaseModel):