Fix feature info
This commit is contained in:
parent
360a7a70f3
commit
69924709d2
3 changed files with 20 additions and 12 deletions
|
@ -120,7 +120,9 @@ class BaseSurveyModel(BaseModel):
|
|||
info.append(InfoItem(key='ISO layer name',
|
||||
value=self.iso_layer_name))
|
||||
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:
|
||||
info.append(InfoItem(key='project',
|
||||
value=self.project.name))
|
||||
|
@ -190,18 +192,18 @@ class SurveyModel(BaseSurveyModel):
|
|||
def __tablename__(cls) -> str:
|
||||
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()
|
||||
if self.srvyr_id:
|
||||
info['surveyor'] = self.surveyor.name
|
||||
info.append(InfoItem(key='surveyor', value=self.surveyor.name))
|
||||
if self.equip_id:
|
||||
info['survey equipment'] = self.equipment.name
|
||||
info.append(InfoItem(key='survey equipment', value=self.equipment.name))
|
||||
if self.accur_id:
|
||||
info['survey accuracy'] = self.accuracy.name
|
||||
info.append(InfoItem(key='survey accuracy', value=self.accuracy.name))
|
||||
if self.date:
|
||||
info['survey date'] = self.date.strftime(LOCALE_DATE_FORMAT)
|
||||
info['status'] = self.status
|
||||
info['original id'] = self.orig_id
|
||||
info.append(InfoItem(key='survey date', value=self.date.strftime(LOCALE_DATE_FORMAT)))
|
||||
info.append(InfoItem(key='status', value=self.status))
|
||||
info.append(InfoItem(key='original id', value=self.orig_id))
|
||||
return info
|
||||
|
||||
async def get_feature_properties(self):
|
||||
|
@ -847,9 +849,10 @@ class GeoPointModelNoStatus(GeoModelNoStatus):
|
|||
return writer
|
||||
|
||||
async def get_geo_info(self) -> list[InfoItem]:
|
||||
g = shapely.from_wkb(self.geom.data) # type: ignore
|
||||
return [
|
||||
InfoItem(key='longitude', value='{:.6f}.format(self.geom.x)'),
|
||||
InfoItem(key='latitude', value='{:.6f}.format(self.geom.y)'),
|
||||
InfoItem(key='longitude', value=g.x), # type: ignore
|
||||
InfoItem(key='latitude', value=g.y), # type: ignore
|
||||
]
|
||||
|
||||
class GeoPointModel(GeoPointModelNoStatus, GeoModel):
|
||||
|
|
|
@ -3,6 +3,7 @@ from typing import Any
|
|||
from pydantic import BaseModel
|
||||
|
||||
from gisaf.models.info_item import InfoItem
|
||||
from gisaf.models.tags import Tag
|
||||
|
||||
class ActionResult(BaseModel):
|
||||
message: str
|
||||
|
@ -54,8 +55,8 @@ class FeatureInfo(BaseModel):
|
|||
geoInfoItems: list[InfoItem] = []
|
||||
surveyInfoItems: list[InfoItem] = []
|
||||
infoItems: list[InfoItem] = []
|
||||
categorizedInfoItems: list[InfoCategory] = []
|
||||
tags: list[InfoItem] = []
|
||||
categorizedInfoItems: list[InfoCategory] | None = None
|
||||
tags: list[Tag] = []
|
||||
graph: str | None = None
|
||||
plotParams: PlotParams | None = None
|
||||
files: list[Attachment] = []
|
||||
|
|
|
@ -44,3 +44,7 @@ class TagKey(SQLModel, table=True):
|
|||
def __repr__(self):
|
||||
return '<models.TagKey {self.key}>'.format(self=self)
|
||||
|
||||
|
||||
class Tag(BaseModel):
|
||||
key: str
|
||||
value: str
|
Loading…
Add table
Add a link
Reference in a new issue