- 필지 경계가 하나도 안 보이고 도곽을 통째로 감싼 필지가 있으면 정보 묶음 맨 위에 「구역 전체가 이 필지 안 (시군구 읍면동 리)」 한 줄 - 검증_sub4(용화리 국유림 산77-15임 한 필지 안): 화면에 안내 1개 + 지번·지목·면적·소유자 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013rJwJMVL4EE31y77TB11AP
80 lines
3.3 KiB
Python
80 lines
3.3 KiB
Python
"""B07 용지도 — 필지마다 지번·지목·면적·소유자 한 묶음 · 빈 값은 빈 줄 (59-6)."""
|
|
|
|
import pytest
|
|
|
|
from B07_DesignDetail.B07_DesignDetail_Engine_Cad_Landuse import (
|
|
JIBUN_LAYER_ID,
|
|
MM,
|
|
build_landuse_drawing,
|
|
)
|
|
|
|
|
|
def _square(x0: float, size: float) -> list[tuple[float, float]]:
|
|
return [(x0, 0.0), (x0 + size, 0.0), (x0 + size, size), (x0, size), (x0, 0.0)]
|
|
|
|
|
|
def test_one_label_group_per_parcel() -> None:
|
|
full = {"pnu": "A", "jibun": "95전", "jimok": "전", "parea": 4916, "owner_nm": "개인"}
|
|
split = {"pnu": "B", "jibun": "산1임", "jimok": "임야", "parea": 12.4, "owner_nm": ""}
|
|
parcels = [
|
|
{"ring": _square(0.0, 40.0), "props": full},
|
|
# 도곽에 잘려 두 조각이 된 필지 — 정보는 큰 조각에 한 번만
|
|
{"ring": _square(100.0, 10.0), "props": split},
|
|
{"ring": _square(200.0, 30.0), "props": split},
|
|
# 도곽을 통째로 감싼 필지 — 경계 없이 정보만
|
|
{"ring": [], "props": {"pnu": "C", "jibun": "산77"}, "label_at": (500.0, 500.0)},
|
|
]
|
|
drawing = build_landuse_drawing("landuse", "용지도", [], [], parcels, [], [])
|
|
texts = [e for e in drawing["entities"] if e.get("layerId") == JIBUN_LAYER_ID]
|
|
labels = [e["shapeData"]["label"] for e in texts]
|
|
assert labels == ["95전", "전", "4,916㎡", "개인", "산1임", "임야", "12㎡", "산77"]
|
|
groups = {round(e["shapeData"]["basePoint"]["x"], 6) for e in texts}
|
|
assert len(groups) == 3
|
|
# 쪼개진 필지는 큰 조각(200~230 m) 가운데에
|
|
split_x = {
|
|
e["shapeData"]["basePoint"]["x"] for e in texts if e["shapeData"]["label"] == "산1임"
|
|
}
|
|
assert split_x.pop() == pytest.approx(215.0 * MM)
|
|
|
|
|
|
def test_zone_inside_one_parcel_is_named_once(tmp_path) -> None:
|
|
"""작은 구역이 큰 필지 하나 안에 통째로 — 경계선이 없어도 어느 필지인지 한 번 적는다 (68-2)."""
|
|
import json
|
|
|
|
from B07_DesignDetail.B07_DesignDetail_Router_Support_Basin import _clip_parcels
|
|
|
|
props = {
|
|
"pnu": "P1",
|
|
"sgg_nm": "봉화군",
|
|
"emd_nm": "재산면",
|
|
"ri_nm": "갈산리",
|
|
"jibun": "산77-1임",
|
|
"jimok": "임야",
|
|
"parea": 1234567,
|
|
"owner_nm": "국",
|
|
}
|
|
big = [[0.0, 0.0], [10.0, 0.0], [10.0, 10.0], [0.0, 10.0], [0.0, 0.0]]
|
|
geojson = {
|
|
"type": "FeatureCollection",
|
|
"features": [
|
|
{
|
|
"type": "Feature",
|
|
"properties": props,
|
|
"geometry": {"type": "Polygon", "coordinates": [big]},
|
|
}
|
|
],
|
|
}
|
|
path = tmp_path / "parcels.geojson"
|
|
path.write_text(json.dumps(geojson, ensure_ascii=False), encoding="utf-8")
|
|
parcels = _clip_parcels(path, "EPSG:4326", (4.0, 4.0, 6.0, 6.0))
|
|
assert len(parcels) == 1 and parcels[0]["ring"] == []
|
|
|
|
route = [(4.5, 4.5), (5.5, 5.5)]
|
|
drawing = build_landuse_drawing("landuse", "용지도", route, [], parcels, [], [])
|
|
labels = [
|
|
e["shapeData"]["label"] for e in drawing["entities"] if e.get("layerId") == JIBUN_LAYER_ID
|
|
]
|
|
notes = [label for label in labels if label.startswith("구역 전체가 이 필지 안")]
|
|
assert notes == ["구역 전체가 이 필지 안 (봉화군 재산면 갈산리)"]
|
|
assert labels[1:] == ["산77-1임", "임야", "1,234,567㎡", "국"]
|