feat: 支持编辑 QGIS 工程模板图层

This commit is contained in:
nixevol
2026-10-15 00:39:03 +08:00
parent 81daf9f266
commit 611c500ac4
6 changed files with 702 additions and 4 deletions
+34 -1
View File
@@ -11,7 +11,7 @@ from fastapi import FastAPI, HTTPException, UploadFile
from fastapi.responses import JSONResponse, StreamingResponse
from pydantic import BaseModel
from marketgrid import layer_edit
from marketgrid import layer_edit, project_edit
from toolbox import tasks
from toolbox.tasks import ACTIVE, KINDS, LABELS, ROOT
from toolbox.validation import SOURCES, market_options, validate
@@ -39,6 +39,26 @@ class LayerWrite(BaseModel):
values: dict = {}
class ProjectLayer(BaseModel):
id: str = ""
name: str
checked: bool = False
source: str = ""
url: str = ""
xyz: bool = False
kind: str = ""
zmin: str = ""
zmax: str = ""
referer: str = ""
header: bool = False
encoding: str = ""
class ProjectWrite(BaseModel):
path: str
layers: list[ProjectLayer]
def resolve_path(value):
text = str(value or "").strip().strip('"')
if not text:
@@ -342,6 +362,19 @@ def file_stat(path: str = ""):
return {"path": str(target), "exists": True, "size": target.stat().st_size}
@app.get("/api/project")
def project_document(path: str = ""):
return project_edit.read_project(resolve_path(path))
@app.put("/api/project")
def project_update(body: ProjectWrite):
return project_edit.update_project(
resolve_path(body.path),
[item.model_dump() for item in body.layers],
)
@app.get("/api/layer")
def layer_document(path: str = ""):
return layer_edit.read_layer(resolve_path(path))