This commit is contained in:
2026-07-19 11:36:25 +09:00
parent db817b940a
commit e18753416f
7 changed files with 106 additions and 46 deletions
+40 -16
View File
@@ -1,20 +1,27 @@
import sys
import os
from pathlib import Path
# Add project root to sys.path
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
from B03_FileInput.B03_FileInput_Engine_Analyze import (
analyze_las_metadata,
analyze_prj_metadata,
analyze_tif_metadata,
analyze_las_metadata,
)
BASE_DIR = Path("D:/02_Software_Prog/임도설계 및 견적자동화 프로그램 개발")
PRJ_PATH = BASE_DIR / "storage/1/3/acb9170b-9ac8-49b3-82a0-51cfa32bb42d/B03_FileInput/input/prj/result.prj"
TIF_PATH = BASE_DIR / "storage/1/3/acb9170b-9ac8-49b3-82a0-51cfa32bb42d/B03_FileInput/input/tif/result.tif"
LAS_PATH = BASE_DIR / "storage/1/3/acb9170b-9ac8-49b3-82a0-51cfa32bb42d/B03_FileInput/input/las/cloud_merged.las"
PRJ_PATH = (
BASE_DIR / "storage/1/3/acb9170b-9ac8-49b3-82a0-51cfa32bb42d/B03_FileInput/input/prj/result.prj"
)
TIF_PATH = (
BASE_DIR / "storage/1/3/acb9170b-9ac8-49b3-82a0-51cfa32bb42d/B03_FileInput/input/tif/result.tif"
)
LAS_PATH = (
BASE_DIR
/ "storage/1/3/acb9170b-9ac8-49b3-82a0-51cfa32bb42d/B03_FileInput/input/las/cloud_merged.las"
)
def run_tests():
print("--- 1. Testing PRJ Metadata Extraction ---")
@@ -23,12 +30,20 @@ def run_tests():
print("PRJ Metadata:")
for k, v in prj_meta.items():
print(f" {k}: {v}")
# Assertions based on PLAN.md expectations
assert prj_meta.get("epsg") == 5187, f"Expected horizontal EPSG to be 5187, got {prj_meta.get('epsg')}"
assert prj_meta.get("crs_status") == "custom_vertical_crs", f"Expected custom_vertical_crs, got {prj_meta.get('crs_status')}"
assert prj_meta.get("vertical_crs") is not None, "Expected vertical_crs metadata to be present"
assert "KNGeoid24" in prj_meta["vertical_crs"]["name"], f"Expected KNGeoid24 in vertical crs name, got {prj_meta['vertical_crs']['name']}"
assert prj_meta.get("epsg") == 5187, (
f"Expected horizontal EPSG to be 5187, got {prj_meta.get('epsg')}"
)
assert prj_meta.get("crs_status") == "custom_vertical_crs", (
f"Expected custom_vertical_crs, got {prj_meta.get('crs_status')}"
)
assert prj_meta.get("vertical_crs") is not None, (
"Expected vertical_crs metadata to be present"
)
assert "KNGeoid24" in prj_meta["vertical_crs"]["name"], (
f"Expected KNGeoid24 in vertical crs name, got {prj_meta['vertical_crs']['name']}"
)
print("PRJ test passed successfully.")
else:
print(f"PRJ file not found at {PRJ_PATH}")
@@ -39,9 +54,11 @@ def run_tests():
print("TIF Metadata:")
for k, v in tif_meta.items():
print(f" {k}: {v}")
assert tif_meta.get("epsg") == 5187, f"Expected EPSG to be 5187, got {tif_meta.get('epsg')}"
assert tif_meta.get("crs_status") == "identified", f"Expected identified, got {tif_meta.get('crs_status')}"
assert tif_meta.get("crs_status") == "identified", (
f"Expected identified, got {tif_meta.get('crs_status')}"
)
assert tif_meta.get("vertical_crs") is None, "Expected no vertical crs for TIF file"
print("TIF test passed successfully.")
else:
@@ -57,14 +74,21 @@ def run_tests():
print(f" {k}: id={v.get('id')}, num_dimensions={len(v.get('dimensions', []))}")
else:
print(f" {k}: {v}")
assert las_meta.get("epsg") == 5187, f"Expected EPSG to be 5187, got {las_meta.get('epsg')}"
assert las_meta.get("crs_status") == "custom_vertical_crs", f"Expected custom_vertical_crs, got {las_meta.get('crs_status')}"
assert las_meta.get("vertical_crs") is not None, "Expected vertical_crs metadata to be present"
assert "KNGeoid24" in las_meta["vertical_crs"]["name"], f"Expected KNGeoid24 in vertical crs name, got {las_meta['vertical_crs']['name']}"
assert las_meta.get("crs_status") == "custom_vertical_crs", (
f"Expected custom_vertical_crs, got {las_meta.get('crs_status')}"
)
assert las_meta.get("vertical_crs") is not None, (
"Expected vertical_crs metadata to be present"
)
assert "KNGeoid24" in las_meta["vertical_crs"]["name"], (
f"Expected KNGeoid24 in vertical crs name, got {las_meta['vertical_crs']['name']}"
)
print("LAS test passed successfully.")
else:
print(f"LAS file not found at {LAS_PATH}")
if __name__ == "__main__":
run_tests()
+27 -16
View File
@@ -35,51 +35,57 @@ for rel_path, abs_path in list(all_wiki_files.items()):
continue
if rel_path in ["index", "log", "index.md", "log.md"]:
continue
with open(abs_path, "r", encoding="utf-8") as f:
lines = f.readlines()
line_count = len(lines)
content = "".join(lines)
# Rule 14: Max 100 lines
if line_count > 100:
warnings.append(f"[Line Count] `{rel_path}.md` exceeds 100 lines ({line_count} lines).")
# Check YAML Frontmatter via simple regex
frontmatter_match = re.match(r"^---\s*\n(.*?)\n---\s*\n", content, re.DOTALL)
if not frontmatter_match:
errors.append(f"[Frontmatter] `{rel_path}.md` has no valid YAML frontmatter.")
continue
fm_text = frontmatter_match.group(1)
# Simple regex parsing for status & page_id
status_match = re.search(r"^status:\s*(\w+)", fm_text, re.MULTILINE)
page_id_match = re.search(r"^page_id:\s*([^\n\r]+)", fm_text, re.MULTILINE)
if not status_match:
errors.append(f"[Status] `{rel_path}.md` has no status field in frontmatter.")
else:
status = status_match.group(1).strip()
if status not in ["draft", "stable", "stale"]:
errors.append(f"[Status] `{rel_path}.md` has invalid status '{status}'. Must be draft, stable, or stale.")
errors.append(
f"[Status] `{rel_path}.md` has invalid status '{status}'. Must be draft, stable, or stale."
)
elif status == "stale":
warnings.append(f"[Stale Page] `{rel_path}.md` is marked as stale and needs updates from raw inputs.")
warnings.append(
f"[Stale Page] `{rel_path}.md` is marked as stale and needs updates from raw inputs."
)
# Rule 5: page_id required for pages/
if "pages/" in rel_path:
if not page_id_match:
errors.append(f"[page_id] `{rel_path}.md` is in pages/ but lacks a 'page_id' field.")
# Check for broken wikilinks in content
links = wikilink_pat.findall(content)
for link in links:
link_clean = link.strip().replace("\\", "/").split("#")[0] # ignore anchor for file existence check
link_clean = (
link.strip().replace("\\", "/").split("#")[0]
) # ignore anchor for file existence check
if not link_clean:
continue
found = False
# 1. Absolute link from vault root (e.g. concepts/storage_paths)
if link_clean in all_wiki_files:
found = True
@@ -98,7 +104,7 @@ for rel_path, abs_path in list(all_wiki_files.items()):
resolved = os.path.normpath(os.path.join(curr_dir, link_clean)).replace("\\", "/")
if resolved in all_wiki_files or resolved.replace("pages/", "") in all_wiki_files:
found = True
if not found:
errors.append(f"[Broken Link] `{rel_path}.md` contains broken wikilink: [[{link}]]")
@@ -108,8 +114,13 @@ for rel_path, abs_path in list(all_wiki_files.items()):
if file_name_no_ext not in index_content:
# check if relative path is in index
rel_path_no_ext = rel_path.replace(".md", "")
if rel_path_no_ext not in index_content and rel_path_no_ext.split("/")[-1] not in index_content:
warnings.append(f"[Orphan Page] `{rel_path}.md` is not linked or mentioned in index.md.")
if (
rel_path_no_ext not in index_content
and rel_path_no_ext.split("/")[-1] not in index_content
):
warnings.append(
f"[Orphan Page] `{rel_path}.md` is not linked or mentioned in index.md."
)
print("=== LINT ERRORS ===")
for e in sorted(list(set(errors))):