Rename in category table: model_type to geom_type

This commit is contained in:
phil 2023-12-26 18:42:40 +05:30
parent b772e1bd80
commit c0c308a657
5 changed files with 16 additions and 15 deletions

View file

@ -205,7 +205,7 @@ class RawSurveyImporter(Importer):
gdf['geom'] = gdf.to_crs(conf.srid).geometry.apply(lambda g: dumps_wkb(g, srid=conf.srid, hex=True))
for category_name, category_gdf in gdf.groupby('category'):
category = registry.categories.loc[category_name]
if category.auto_import and category.model_type == 'Point':
if category.auto_import and category.geom_type == 'Point':
if not dry_run:
await upsert_df(category_gdf, category.model)

View file

@ -60,7 +60,7 @@ class CategoryBase(BaseModel):
status: str = Field(min_length=1, max_length=1)
custom: bool | None
auto_import: bool = True
model_type: str = Field(max_length=50,
geom_type: str = Field(max_length=50,
foreign_key='category_model_type.name',
default='Point')
long_name: str | None = Field(max_length=50)
@ -108,7 +108,7 @@ class CategoryBase(BaseModel):
@computed_field
@property
def mapbox_type(self) -> str:
return self.mapbox_type_custom or mapbox_type_mapping[self.model_type]
return self.mapbox_type_custom or mapbox_type_mapping[self.geom_type]
class Category(CategoryBase, table=True):

View file

@ -140,7 +140,7 @@ class SurveyModel(BaseSurveyModel):
Base mixin class for defining final (reprojected) survey data, with a status
"""
metadata: ClassVar[MetaData] = survey
status: str = Field(sa_type=String(1))
status: ClassVar[str] = Field(sa_type=String(1))
get_gdf_with_related: ClassVar[bool] = False
@ -334,10 +334,10 @@ class GeoModel(Model):
Style for the model, used in the map, etc
"""
status: ClassVar[str] = 'E'
"""
Status (ISO layers definition) of the layer. E -> Existing.
"""
# status: ClassVar[str] = 'E'
# """
# Status (ISO layers definition) of the layer. E -> Existing.
# """
_join_with: ClassVar[dict[str, Any]] = {
}
@ -751,6 +751,7 @@ class GeoModel(Model):
return Path(conf.attachments['base_dir'])/cls.get_attachment_dir()
class LiveGeoModel(GeoModel):
status: ClassVar[str] = 'E'
store: ClassVar[str]
group: ClassVar[str] ='Live'
custom: ClassVar[bool] = True

View file

@ -28,7 +28,7 @@ class Store(BaseModel):
minor_group_1: str
minor_group_2: str
#model: GeoModel
model_type: str
geom_type: str
name: str
#name_letter: str
#name_number: int

View file

@ -166,7 +166,7 @@ class ModelRegistry:
else:
logger.debug('Discovered {:s}'.format(category.raw_survey_table_name))
model_class = category_model_mapper.get(category.model_type)
model_class = category_model_mapper.get(category.geom_type)
## Final geometries
try:
if model_class:
@ -213,13 +213,13 @@ class ModelRegistry:
obj = getattr(module, name)
if hasattr(obj, '__module__') and obj.__module__.startswith(module.__name__)\
and hasattr(obj, '__tablename__') and hasattr(obj, 'get_store_name'):
model_type = self.add_model(obj)
logger.debug(f'Model {obj.get_store_name()} added in the registry from gisaf source tree as {model_type}')
geom_type = self.add_model(obj)
logger.debug(f'Model {obj.get_store_name()} added in the registry from gisaf source tree as {geom_type}')
## Scan the models defined in plugins (setuptools' entry points)
for module_name, model in self.scan_entry_points(name='gisaf_extras.models').items():
model_type = self.add_model(model)
logger.debug(f'Model {model.get_store_name()} added in the registry from {module_name} entry point as {model_type}')
geom_type = self.add_model(model)
logger.debug(f'Model {model.get_store_name()} added in the registry from {module_name} entry point as {geom_type}')
for module_name, store in self.scan_entry_points(name='gisaf_extras.stores').items():
self.add_store(store)
@ -621,7 +621,7 @@ class ModelRegistry:
columns={
'live': 'is_live',
'zIndex': 'z_index',
'gisType': 'model_type',
'gisType': 'geom_type',
# 'type': 'mapbox_type',
'viewableRole': 'viewable_role',
}, inplace=True