2023-11-19 12:13:39 +05:30
|
|
|
from enum import Enum
|
|
|
|
|
2024-01-03 17:07:11 +05:30
|
|
|
from sqlmodel import Field, Relationship
|
2023-11-19 12:13:39 +05:30
|
|
|
|
2023-12-25 15:50:45 +05:30
|
|
|
from gisaf.models.models_base import Model
|
2024-01-05 01:50:32 +05:30
|
|
|
from gisaf.models.metadata import gisaf_survey
|
2023-11-19 12:13:39 +05:30
|
|
|
|
|
|
|
|
2024-01-03 17:07:11 +05:30
|
|
|
class Accuracy(Model, table=True):
|
2024-01-05 01:50:32 +05:30
|
|
|
__table_args__ = gisaf_survey.table_args
|
2023-11-19 12:13:39 +05:30
|
|
|
|
|
|
|
class Admin:
|
|
|
|
menu = 'Other'
|
|
|
|
flask_admin_model_view = 'MyModelViewWithPrimaryKey'
|
|
|
|
|
2023-12-25 15:50:45 +05:30
|
|
|
id: int | None = Field(default=None, primary_key=True)
|
2023-11-19 12:13:39 +05:30
|
|
|
name: str
|
|
|
|
accuracy: float
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return f'{self.name} {self.accuracy}'
|
|
|
|
|
|
|
|
def __repr__(self):
|
|
|
|
return f'<models.Accuracy {self.name}>'
|
|
|
|
|
|
|
|
|
2024-01-03 17:07:11 +05:30
|
|
|
class Surveyor(Model, table=True):
|
2024-01-05 01:50:32 +05:30
|
|
|
__table_args__ = gisaf_survey.table_args
|
2023-11-19 12:13:39 +05:30
|
|
|
|
|
|
|
class Admin:
|
|
|
|
menu = 'Other'
|
|
|
|
flask_admin_model_view = 'MyModelViewWithPrimaryKey'
|
|
|
|
|
2023-12-25 15:50:45 +05:30
|
|
|
id: int | None = Field(default=None, primary_key=True)
|
2023-11-19 12:13:39 +05:30
|
|
|
name: str
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return self.name
|
|
|
|
|
|
|
|
def __repr__(self):
|
|
|
|
return f'<models.Surveyor {self.name}>'
|
|
|
|
|
|
|
|
|
2024-01-03 17:07:11 +05:30
|
|
|
class Equipment(Model, table=True):
|
2024-01-05 01:50:32 +05:30
|
|
|
__table_args__ = gisaf_survey.table_args
|
2023-11-19 12:13:39 +05:30
|
|
|
|
|
|
|
class Admin:
|
|
|
|
menu = 'Other'
|
|
|
|
flask_admin_model_view = 'MyModelViewWithPrimaryKey'
|
|
|
|
|
2023-12-25 15:50:45 +05:30
|
|
|
id: int | None = Field(default=None, primary_key=True)
|
2023-11-19 12:13:39 +05:30
|
|
|
name: str
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return self.name
|
|
|
|
|
|
|
|
def __repr__(self):
|
|
|
|
return f'<models.Equipment {self.name}>'
|
|
|
|
|
|
|
|
class GeometryType(str, Enum):
|
|
|
|
point = 'Point'
|
|
|
|
line_work = 'Line_work'
|
|
|
|
|
2024-01-03 17:07:11 +05:30
|
|
|
class AccuracyEquimentSurveyorMapping(Model, table=True):
|
2024-01-05 01:50:32 +05:30
|
|
|
__table_args__ = gisaf_survey.table_args
|
2023-11-19 12:13:39 +05:30
|
|
|
__tablename__ = 'accuracy_equiment_surveyor_mapping'
|
|
|
|
|
|
|
|
class Admin:
|
|
|
|
menu = 'Other'
|
|
|
|
|
2023-12-25 15:50:45 +05:30
|
|
|
id: int | None= Field(default=None, primary_key=True)
|
2024-01-05 01:50:32 +05:30
|
|
|
surveyor_id: int = Field(foreign_key=gisaf_survey.table('surveyor.id'), index=True)
|
|
|
|
equipment_id: int = Field(foreign_key=gisaf_survey.table('equipment.id'), index=True)
|
2023-11-19 12:13:39 +05:30
|
|
|
geometry_type: GeometryType = Field(default='Point', index=True)
|
2024-01-05 01:50:32 +05:30
|
|
|
accuracy_id: int = Field(foreign_key=gisaf_survey.table('accuracy.id'))
|
2024-01-03 17:07:11 +05:30
|
|
|
surveyor: Surveyor = Relationship()
|
|
|
|
accuracy: Accuracy = Relationship()
|
|
|
|
equipment: Equipment = Relationship()
|
2023-11-19 12:13:39 +05:30
|
|
|
|
|
|
|
@classmethod
|
2024-01-03 17:07:11 +05:30
|
|
|
def selectinload(cls):
|
|
|
|
return [
|
|
|
|
cls.surveyor,
|
|
|
|
cls.equipment,
|
|
|
|
cls.accuracy,
|
|
|
|
]
|
|
|
|
|
|
|
|
# @classmethod
|
|
|
|
# def dyn_join_with(cls):
|
|
|
|
# return {
|
|
|
|
# 'surveyor': Surveyor,
|
|
|
|
# 'equipment': Equipment,
|
|
|
|
# 'accuracy': Accuracy,
|
|
|
|
# }
|