95 lines
3.5 KiB
Python
95 lines
3.5 KiB
Python
import sys
|
|
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,
|
|
)
|
|
|
|
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"
|
|
)
|
|
|
|
|
|
def run_tests():
|
|
print("--- 1. Testing PRJ Metadata Extraction ---")
|
|
if PRJ_PATH.exists():
|
|
prj_meta = analyze_prj_metadata(PRJ_PATH)
|
|
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']}"
|
|
)
|
|
print("PRJ test passed successfully.")
|
|
else:
|
|
print(f"PRJ file not found at {PRJ_PATH}")
|
|
|
|
print("\n--- 2. Testing TIF Metadata Extraction ---")
|
|
if TIF_PATH.exists():
|
|
tif_meta = analyze_tif_metadata(TIF_PATH)
|
|
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("vertical_crs") is None, "Expected no vertical crs for TIF file"
|
|
print("TIF test passed successfully.")
|
|
else:
|
|
print(f"TIF file not found at {TIF_PATH}")
|
|
|
|
print("\n--- 3. Testing LAS Metadata Extraction ---")
|
|
if LAS_PATH.exists():
|
|
las_meta = analyze_las_metadata(LAS_PATH)
|
|
print("LAS Metadata:")
|
|
for k, v in las_meta.items():
|
|
# Exclude large dimensions output for print readability
|
|
if k == "point_format":
|
|
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']}"
|
|
)
|
|
print("LAS test passed successfully.")
|
|
else:
|
|
print(f"LAS file not found at {LAS_PATH}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
run_tests()
|