auto: 2026-09-01 16:56 (ESD_LAPTOP)
This commit is contained in:
@@ -389,3 +389,61 @@ async def save_surface_analysis_to_db(
|
||||
statistics=None,
|
||||
)
|
||||
return surface_model_ids
|
||||
|
||||
|
||||
async def save_sheet_surface_models(
|
||||
connection: aiomysql.Connection, project_id: UUID, models: list[dict[str, Any]]
|
||||
) -> list[int]:
|
||||
"""관리자가 요청해 새로 만든 도엽 서피스 모델을 등록한다 (2026-09-01).
|
||||
|
||||
전체 재분석(`save_surface_analysis_to_db`)과 달리 **기존 행을 지우지 않는다** —
|
||||
방식 하나만 덧붙이는 요청이라 이미 있는 모델을 날리면 안 된다. 같은 파일을 가리키는
|
||||
옛 행만 걷어 낸다. 입력 파일·구조화 클라우드·좌표계는 같은 프로젝트의 기존 모델에서
|
||||
물려받는다(도엽 서피스는 LAS가 아니라 등고선에서 나오지만 같은 사업지다).
|
||||
|
||||
이 함수는 트랜잭션을 시작하거나 끝내지 않는다 — 호출자가 한 번만 한다.
|
||||
"""
|
||||
async with connection.cursor() as cursor:
|
||||
await cursor.execute(
|
||||
"""
|
||||
SELECT source_file_id, processed_cloud_id, crs_epsg
|
||||
FROM surface_models WHERE project_id = %s ORDER BY id LIMIT 1
|
||||
""",
|
||||
(str(project_id),),
|
||||
)
|
||||
row = await cursor.fetchone()
|
||||
source_file_id, processed_cloud_id, crs_epsg = row if row else (None, None, None)
|
||||
|
||||
model_ids: list[int] = []
|
||||
for model in models:
|
||||
model_path = model.get("model_file_path")
|
||||
if model_path:
|
||||
async with connection.cursor() as cursor:
|
||||
await cursor.execute(
|
||||
"DELETE FROM surface_models WHERE project_id = %s AND model_file_path = %s",
|
||||
(str(project_id), model_path),
|
||||
)
|
||||
model_id = await create_surface_model(
|
||||
connection,
|
||||
project_id=project_id,
|
||||
model_type=model["model_type"],
|
||||
source_file_id=source_file_id,
|
||||
processed_cloud_id=processed_cloud_id,
|
||||
crs_epsg=crs_epsg,
|
||||
resolution_m=model["resolution_m"],
|
||||
model_file_path=model_path,
|
||||
generation_params=model["generation_params"],
|
||||
)
|
||||
model_ids.append(model_id)
|
||||
for layer in model.get("layers", []):
|
||||
await create_terrain_layer(
|
||||
connection,
|
||||
surface_model_id=model_id,
|
||||
layer_name=layer["layer_name"],
|
||||
geometry_type=layer["geometry_type"],
|
||||
layer_file_path=layer["file_path"],
|
||||
file_format=layer["file_format"],
|
||||
file_size_mb=None,
|
||||
statistics=None,
|
||||
)
|
||||
return model_ids
|
||||
|
||||
Reference in New Issue
Block a user