feat(지형표본): 346-1 지반고 자릿수 칸 — /route/elevations decimals(기본 3 · 0~6) · 계산 묶음 서버 길은 6자리로 부름(격자 길과 같은 값) · 시험
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Se7ytqbohmBQnfYpwYFnYf
This commit is contained in:
@@ -73,7 +73,7 @@ export function designTerrainGridNow(projectId: string): DesignTerrainGrid | nul
|
||||
/** 한 번에 물을 수 있는 점 수 — 서버 `MAX_POINTS` 와 같은 값. */
|
||||
const ELEVATION_CHUNK = 4000;
|
||||
|
||||
/** 계산 묶음 ground 단계에 넣을 격자 · 서버 길(PLAN 346-1). 서버 길 값은 mm 자리(응답 그대로). */
|
||||
/** 계산 묶음 ground 단계에 넣을 격자 · 서버 길(PLAN 346-1). 서버 길도 소수 6자리 — 격자 길과 같은 값. */
|
||||
export function groundStageDeps(projectId: string): Pick<GroundStageDeps, "grid" | "remote"> {
|
||||
return {
|
||||
grid: () => designTerrainGridNow(projectId),
|
||||
@@ -88,7 +88,7 @@ export function groundStageDeps(projectId: string): Pick<GroundStageDeps, "grid"
|
||||
method: "POST",
|
||||
credentials: "include",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ points: chunk, terrain }),
|
||||
body: JSON.stringify({ points: chunk, terrain, decimals: 6 }),
|
||||
signal,
|
||||
});
|
||||
if (!response.ok) throw new Error(`지반고 요청 실패: HTTP ${response.status}`);
|
||||
|
||||
@@ -62,6 +62,8 @@ class ElevationRequest(BaseModel):
|
||||
|
||||
points: list[tuple[float, float]] = Field(..., min_length=1, max_length=MAX_POINTS)
|
||||
terrain: AnalysisTerrain | None = None
|
||||
#: 표고 자릿수 — 화면 값은 mm(3) · 계산 묶음 서버 길은 6(격자 표본 · 서버 생성과 같은 자리).
|
||||
decimals: int = Field(3, ge=0, le=6)
|
||||
|
||||
|
||||
def _sample(project_root: Path, params: dict, points: list[tuple[float, float]]):
|
||||
@@ -112,7 +114,9 @@ async def read_route_elevations(project_id: UUID, request: ElevationRequest) ->
|
||||
return {
|
||||
"status": "success",
|
||||
"project_id": str(project_id),
|
||||
"z": [None if not ok else round(float(value), 3) for value, ok in zip(z, valid)],
|
||||
"z": [
|
||||
None if not ok else round(float(value), request.decimals) for value, ok in zip(z, valid)
|
||||
],
|
||||
"valid": [bool(ok) for ok in valid],
|
||||
}
|
||||
|
||||
|
||||
@@ -114,3 +114,30 @@ def test_받을_자리_서명은_manifest_구성과_평활(tmp_path):
|
||||
)
|
||||
assert terrain_router._design_grid({**PARAMS, "method": "tin"}, models, confirmed) is None
|
||||
assert terrain_router._design_grid(PARAMS, models, None) is None
|
||||
|
||||
|
||||
def test_지반고_자릿수_기본_3_묶음은_6(tmp_path, monkeypatch):
|
||||
root = tmp_path
|
||||
models = root / "B04_PreProcess" / "models"
|
||||
models.mkdir(parents=True)
|
||||
x = np.arange(0.0, 11.0)
|
||||
np.savez(
|
||||
models / "dtm_csf_smooth.npz",
|
||||
x=x,
|
||||
y=x,
|
||||
z=np.add.outer(x * 0.0, x * 0.1234567),
|
||||
valid_mask=np.ones((11, 11), dtype=bool),
|
||||
)
|
||||
_patch(monkeypatch, root, None)
|
||||
|
||||
async def params(_connection, _project_id):
|
||||
return dict(PARAMS)
|
||||
|
||||
monkeypatch.setattr(terrain_router, "get_surface_confirmation_params", params)
|
||||
ask = terrain_router.ElevationRequest
|
||||
plain = asyncio.run(terrain_router.read_route_elevations(PID, ask(points=[(5.5, 5.0)])))
|
||||
fine = asyncio.run(
|
||||
terrain_router.read_route_elevations(PID, ask(points=[(5.5, 5.0)], decimals=6))
|
||||
)
|
||||
assert plain["z"] == [round(5.5 * 0.1234567, 3)]
|
||||
assert fine["z"] == [round(5.5 * 0.1234567, 6)]
|
||||
|
||||
Reference in New Issue
Block a user