- reject_height_outliers: 반경 15 m(부족 시 45 m) 내 서로 다른 높이 값의 중앙값과 비교 - |편차| > 10 m 이고 주변 높이 범위 밖으로 5 m 초과 시에만 제외, 최악 높이 묶음부터 반복 - 1 mm 이내 높이는 같은 묶음(CAD 부동소수 오차), 제외 수는 rejected_height_outliers로 기록 - 운곡교: EL 5.624(306)·-112.719(16)만 제외, 격자 최저 -85.98→21.50 m, 8 m 초과 튐 88→1 - 산외: -22.21·127.4 제외, 봉우리 후보 87.35 유지 Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
48 lines
2.6 KiB
Python
48 lines
2.6 KiB
Python
import tempfile
|
|
from pathlib import Path
|
|
import unittest
|
|
import ezdxf
|
|
import numpy as np
|
|
from pierzainer_ground.survey_terrain import read_survey_block
|
|
|
|
class SurveyPolylineTests(unittest.TestCase):
|
|
def options(self):
|
|
return dict(terrain_block='*Model_Space',z_min=-200,z_max=200,exclude_zero=True,
|
|
contour_step_m=2,dedup_m=.001,cad_axes='YX')
|
|
|
|
def test_2d_header_height_not_zero_vertices(self):
|
|
doc=ezdxf.new();doc.modelspace().add_polyline2d([(100,200),(104,200),(104,204)],dxfattribs={'elevation':(0,0,45)})
|
|
points,counts,_=read_survey_block(Path('unused.dxf'),self.options(),doc=doc)
|
|
self.assertTrue(np.all(points[:,2]==45));self.assertEqual(counts['constant_height_polylines'],1)
|
|
self.assertTrue(any(np.array_equal(p,[200,100,45]) for p in points))
|
|
|
|
def test_ocs_axes_and_height_are_applied(self):
|
|
doc=ezdxf.new();doc.modelspace().add_lwpolyline([(100,200),(104,200),(104,204)],dxfattribs={'elevation':45,'extrusion':(0,0,-1)})
|
|
points,_,_=read_survey_block(Path('unused.dxf'),self.options(),doc=doc)
|
|
self.assertTrue(any(np.array_equal(p,[200,-100,-45]) for p in points))
|
|
|
|
def test_varying_3d_structure_is_not_a_contour(self):
|
|
doc=ezdxf.new();doc.modelspace().add_polyline3d([(1,1,20),(2,2,30),(3,3,40)])
|
|
with self.assertRaises(ValueError):read_survey_block(Path('unused.dxf'),self.options(),doc=doc)
|
|
|
|
def contours(self,msp,levels):
|
|
for k,z in enumerate(levels):
|
|
msp.add_lwpolyline([(0,10*k),(200,10*k)],dxfattribs={'elevation':z})
|
|
|
|
def test_stray_constant_height_symbols_are_rejected(self):
|
|
# Ungok case: dense short ticks at EL 5.624 and a few at -112.719 among 20-40 m contours.
|
|
doc=ezdxf.new();msp=doc.modelspace();self.contours(msp,[28,29,30,31,32,33])
|
|
for i in range(60):msp.add_lwpolyline([(40+2*i,20),(40+2*i,22)],dxfattribs={'elevation':5.624})
|
|
for i in range(4):msp.add_lwpolyline([(100+i,25),(100+i,27)],dxfattribs={'elevation':-112.719})
|
|
points,counts,_=read_survey_block(Path('unused.dxf'),self.options(),doc=doc)
|
|
self.assertEqual(counts['rejected_height_outliers'],64)
|
|
self.assertGreaterEqual(points[:,2].min(),28)
|
|
|
|
def test_real_peak_above_contours_is_kept(self):
|
|
doc=ezdxf.new();msp=doc.modelspace();self.contours(msp,[70,72,74,76,78,80])
|
|
msp.add_lwpolyline([(100,25),(100,27)],dxfattribs={'elevation':84})
|
|
points,counts,_=read_survey_block(Path('unused.dxf'),self.options(),doc=doc)
|
|
self.assertNotIn('rejected_height_outliers',counts);self.assertEqual(points[:,2].max(),84)
|
|
|
|
if __name__=='__main__':unittest.main()
|