fix(B04 도엽): 도곽선 N3L_H0010000 읽기(없으면 옛 방식) · 공용 창고 prune 막음 (PLAN 611-1 · 요구 486 · 493)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -39,9 +39,11 @@ from .B04_PreProcess_Engine_MapSheet import latlon_to_sheet5k, sheet5k_to_bounds
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# 도곽선 레이어 코드 (수치지형도 v2.0 도엽본)
|
||||
_SHEET_FRAME_CODE = "A0010000"
|
||||
# 도곽선 레이어 코드 (수치지형도 v2.0 도엽본) — 도곽선 N3L_H0010000 이 없는 zip 은 옛 A0010000(도로 면)로 대신
|
||||
_SHEET_FRAME_CODE = "N3L_H0010000"
|
||||
_SHEET_FRAME_FALLBACK_CODE = "A0010000"
|
||||
_SHEET_NO_RE = re.compile(r"(\d{8})")
|
||||
_SHARED_DIRNAME = "_shared" # storage/_shared 아래 = 여러 프로젝트가 같이 쓰는 창고
|
||||
|
||||
# 도엽본 좌표계 후보: 동부원점(5187)이 기본, 오라벨 zip은 중부원점(5186) 선언 사례 실측됨
|
||||
_CRS_CANDIDATES = ("EPSG:5187", "EPSG:5186", "EPSG:5185", "EPSG:5188")
|
||||
@@ -240,6 +242,9 @@ def prune_sheets(store_dir: str | Path, keep_sheet_nos: list[str]) -> list[str]:
|
||||
store = Path(store_dir)
|
||||
if not store.is_dir():
|
||||
return []
|
||||
if _SHARED_DIRNAME in store.resolve().parts:
|
||||
logger.info("도엽 정리: 공용 창고(%s)는 지우지 않음", store)
|
||||
return []
|
||||
keep = {str(sheet_no) for sheet_no in keep_sheet_nos}
|
||||
index = _load_index(store)
|
||||
removed: list[str] = []
|
||||
@@ -313,7 +318,7 @@ def ingest_zip(store_dir: str | Path, src_path: str | Path, sheet_no: str | None
|
||||
|
||||
|
||||
def _read_frame_bounds_wgs84(zip_path: Path) -> tuple[tuple[float, float, float, float], str]:
|
||||
"""zip 내 도곽선(A0010000) SHP bounds를 WGS84로 반환. (bounds, 사용된 CRS).
|
||||
"""zip 내 도곽선(N3L_H0010000 · 없으면 A0010000) SHP bounds를 WGS84로 반환. (bounds, 사용된 CRS).
|
||||
|
||||
선언된 PRJ가 오라벨(중부/동부원점 뒤바뀜)인 실측 사례가 있어, 파일명 도엽번호
|
||||
기준 예측 도곽과 대조해 정합한 CRS를 자동 판별한다.
|
||||
@@ -322,7 +327,11 @@ def _read_frame_bounds_wgs84(zip_path: Path) -> tuple[tuple[float, float, float,
|
||||
|
||||
with zipfile.ZipFile(zip_path) as zf:
|
||||
names = zf.namelist()
|
||||
shp = [n for n in names if n.upper().endswith(f"{_SHEET_FRAME_CODE}.SHP")]
|
||||
shp: list[str] = []
|
||||
for code in (_SHEET_FRAME_CODE, _SHEET_FRAME_FALLBACK_CODE):
|
||||
shp = [n for n in names if n.upper().endswith(f"{code}.SHP")]
|
||||
if shp:
|
||||
break
|
||||
if not shp:
|
||||
raise ValueError(f"{zip_path.name}: 도곽선({_SHEET_FRAME_CODE}) SHP 없음")
|
||||
base = shp[0][:-4]
|
||||
|
||||
Reference in New Issue
Block a user