Fix feature info

This commit is contained in:
phil 2024-03-08 12:04:20 +05:30
parent 360a7a70f3
commit 69924709d2
3 changed files with 20 additions and 12 deletions

View file

@ -120,7 +120,9 @@ class BaseSurveyModel(BaseModel):
info.append(InfoItem(key='ISO layer name', info.append(InfoItem(key='ISO layer name',
value=self.iso_layer_name)) value=self.iso_layer_name))
info.append(InfoItem(key='survey category', info.append(InfoItem(key='survey category',
value=f'{self.category.description} ({self.category.name})')) value=self.category.name))
info.append(InfoItem(key='survey category description',
value=self.category.description))
if self.project_id: if self.project_id:
info.append(InfoItem(key='project', info.append(InfoItem(key='project',
value=self.project.name)) value=self.project.name))
@ -190,18 +192,18 @@ class SurveyModel(BaseSurveyModel):
def __tablename__(cls) -> str: def __tablename__(cls) -> str:
return cls.__name__ # type: ignore return cls.__name__ # type: ignore
async def get_survey_info(self): async def get_survey_info(self) -> list[InfoItem]:
info = await super(SurveyModel, self).get_survey_info() info = await super(SurveyModel, self).get_survey_info()
if self.srvyr_id: if self.srvyr_id:
info['surveyor'] = self.surveyor.name info.append(InfoItem(key='surveyor', value=self.surveyor.name))
if self.equip_id: if self.equip_id:
info['survey equipment'] = self.equipment.name info.append(InfoItem(key='survey equipment', value=self.equipment.name))
if self.accur_id: if self.accur_id:
info['survey accuracy'] = self.accuracy.name info.append(InfoItem(key='survey accuracy', value=self.accuracy.name))
if self.date: if self.date:
info['survey date'] = self.date.strftime(LOCALE_DATE_FORMAT) info.append(InfoItem(key='survey date', value=self.date.strftime(LOCALE_DATE_FORMAT)))
info['status'] = self.status info.append(InfoItem(key='status', value=self.status))
info['original id'] = self.orig_id info.append(InfoItem(key='original id', value=self.orig_id))
return info return info
async def get_feature_properties(self): async def get_feature_properties(self):
@ -847,9 +849,10 @@ class GeoPointModelNoStatus(GeoModelNoStatus):
return writer return writer
async def get_geo_info(self) -> list[InfoItem]: async def get_geo_info(self) -> list[InfoItem]:
g = shapely.from_wkb(self.geom.data) # type: ignore
return [ return [
InfoItem(key='longitude', value='{:.6f}.format(self.geom.x)'), InfoItem(key='longitude', value=g.x), # type: ignore
InfoItem(key='latitude', value='{:.6f}.format(self.geom.y)'), InfoItem(key='latitude', value=g.y), # type: ignore
] ]
class GeoPointModel(GeoPointModelNoStatus, GeoModel): class GeoPointModel(GeoPointModelNoStatus, GeoModel):

View file

@ -3,6 +3,7 @@ from typing import Any
from pydantic import BaseModel from pydantic import BaseModel
from gisaf.models.info_item import InfoItem from gisaf.models.info_item import InfoItem
from gisaf.models.tags import Tag
class ActionResult(BaseModel): class ActionResult(BaseModel):
message: str message: str
@ -54,8 +55,8 @@ class FeatureInfo(BaseModel):
geoInfoItems: list[InfoItem] = [] geoInfoItems: list[InfoItem] = []
surveyInfoItems: list[InfoItem] = [] surveyInfoItems: list[InfoItem] = []
infoItems: list[InfoItem] = [] infoItems: list[InfoItem] = []
categorizedInfoItems: list[InfoCategory] = [] categorizedInfoItems: list[InfoCategory] | None = None
tags: list[InfoItem] = [] tags: list[Tag] = []
graph: str | None = None graph: str | None = None
plotParams: PlotParams | None = None plotParams: PlotParams | None = None
files: list[Attachment] = [] files: list[Attachment] = []

View file

@ -44,3 +44,7 @@ class TagKey(SQLModel, table=True):
def __repr__(self): def __repr__(self):
return '<models.TagKey {self.key}>'.format(self=self) return '<models.TagKey {self.key}>'.format(self=self)
class Tag(BaseModel):
key: str
value: str