增加树线功能。
Signed-off-by: n3040 <ijustforregister@gmail.com>
This commit is contained in:
parent
7ad5ad4c70
commit
ed76be5f7c
|
|
@ -0,0 +1,9 @@
|
|||
build
|
||||
dist
|
||||
out_dxf
|
||||
__pycache__
|
||||
.idea
|
||||
*.spec
|
||||
canva
|
||||
*.xls*
|
||||
*.toml
|
||||
|
|
@ -0,0 +1,131 @@
|
|||
PROJ
|
||||
LQ 800 6
|
||||
|
||||
|
||||
PATH
|
||||
{SEGMENT_N} {TOWER_NUM_START} 0
|
||||
{SEGMENT}
|
||||
|
||||
SECTION
|
||||
{SEGMENT_S} {SEGMENT_E} LQ2710 JL/G1A-400/50 2.5 4 2.25 JLB35A-150 3.35 4 30.85 0.75
|
||||
|
||||
|
||||
|
||||
CONTROL
|
||||
2500 50 .5E-5 -.5E-5 2.0 500 2.5 2500
|
||||
1 1 15 6 20 0
|
||||
|
||||
|
||||
TOWER
|
||||
26 0 6
|
||||
ZS129A1 ZBC1 34 48 0 150000 0
|
||||
H-2*21 48 25 9.64 53 53 53
|
||||
ZS129A2 ZBC1 49 54 0 150000 0
|
||||
H-2*21 48 25 9.64 53 53 53
|
||||
ZS129A1 ZBC1 35 48 0 150000 0
|
||||
H-2*21 48 25 9.64 53 53 53
|
||||
ZS129A2 ZBC1 49 54 0 150000 0
|
||||
H-2*21 48 25 9.64 53 53 53
|
||||
ZS229A1 ZBC2 35 48 0 150000 0
|
||||
H-2*21 50 28.27 11.88 52 52 52
|
||||
ZS229A2 ZBC2 49 51 0 150000 0
|
||||
H-2*21 50 28.27 11.88 52 52 52
|
||||
ZS229A3 ZBC2 52 60 0 150000 0
|
||||
H-2*21 50 28.27 11.88 52 52 52
|
||||
ZS229A4 ZBC2 61 72 0 150000 0
|
||||
H-2*21 50 28.27 11.88 52 52 52
|
||||
ZS229A1 ZBC2 35 48 0 150000 0
|
||||
H-2*21 50 28.27 11.88 52 52 52
|
||||
ZS229A2 ZBC2 49 51 0 150000 0
|
||||
H-2*21 50 28.27 11.88 52 52 52
|
||||
ZS229A3 ZBC2 52 60 0 150000 0
|
||||
H-2*21 50 28.27 11.88 52 52 52
|
||||
ZS229A4 ZBC2 61 72 0 150000 0
|
||||
H-2*21 50 28.27 11.88 52 52 52
|
||||
ZS329A1 ZBC3 35 48 0 150000 0
|
||||
H-2*21 54 32.41 13.02 53.5 53.5 53.5
|
||||
ZS329A2 ZBC3 49 51 0 150000 0
|
||||
H-2*21 54 32.41 13.02 53.5 53.5 53.5
|
||||
ZS329A3 ZBC3 52 60 0 150000 0
|
||||
H-2*21 54 32.41 13.02 53.5 53.5 53.5
|
||||
ZS329A4 ZBC3 61 72 0 150000 0
|
||||
H-2*21 54 32.41 13.02 53.5 53.5 53.5
|
||||
ZS329A1 ZBC3 35 48 0 150000 0
|
||||
H-2*21 54 32.41 13.02 53.5 53.5 53.5
|
||||
ZS329A2 ZBC3 49 51 0 150000 0
|
||||
H-2*21 54 32.41 13.02 53.5 53.5 53.5
|
||||
ZS329A3 ZBC3 52 60 0 150000 0
|
||||
H-2*21 54 32.41 13.02 53.5 53.5 53.5
|
||||
ZS329A4 ZBC3 61 72 0 150000 0
|
||||
H-2*21 54 32.41 13.02 53.5 53.5 53.5
|
||||
ZS429A1 ZBC4 35 48 0 150000 0
|
||||
H-2*21 58 34.50 14.06 56.5 56.5 56.5
|
||||
ZS429A2 ZBC4 49 51 0 150000 0
|
||||
H-2*21 58 34.50 14.06 56.5 56.5 56.5
|
||||
ZS429A3 ZBC4 52 60 0 150000 0
|
||||
H-2*21 58 34.50 14.06 56.5 56.5 56.5
|
||||
ZS429A1 ZBC4 35 48 0 150000 0
|
||||
H-2*21 58 34.50 14.06 56.5 56.5 56.5
|
||||
ZS429A2 ZBC4 49 51 0 150000 0
|
||||
H-2*21 58 34.50 14.06 56.5 56.5 56.5
|
||||
ZS429A3 ZBC4 52 60 0 150000 0
|
||||
H-2*21 58 34.50 14.06 56.5 56.5 56.5
|
||||
JG129A JC1 27 57 0 150000 0
|
||||
2*42-50 2*42-50 H-2*21
|
||||
JG229A JC2 27 57 0 150000 0
|
||||
2*42-50 2*42-50 H-2*21
|
||||
JG329A JC3 27 51 0 150000 0
|
||||
2*42-50 2*42-50 H-2*21
|
||||
JG429A JC4 27 67 0 150000 0
|
||||
2*42-50 2*42-50 H-2*21
|
||||
DJC DJC 27 42 0 150000 0
|
||||
2*42-50 2*42-50 H-2*21
|
||||
MX MX 31 42 0 150000 0
|
||||
2*42-50 2*42-50 H-2*21
|
||||
|
||||
*FIXED
|
||||
0 J1
|
||||
111.9 J1
|
||||
479 ZB2
|
||||
953 ZB2
|
||||
1258 ZB2
|
||||
1531.8 J1
|
||||
2074.6 ZB2
|
||||
2282.1 J1
|
||||
2586.3 ZB2
|
||||
3087.1 ZB2
|
||||
3559.5 ZB2
|
||||
3973 ZB2
|
||||
4212.8 ZB2
|
||||
|
||||
|
||||
|
||||
*NOTOWER
|
||||
|
||||
|
||||
|
||||
|
||||
*TGRP
|
||||
|
||||
|
||||
|
||||
|
||||
*FILE
|
||||
{CONTROL_FILE}.DAT
|
||||
|
||||
|
||||
*CLRNCE
|
||||
76970 77050 34
|
||||
|
||||
|
||||
*CHK
|
||||
10216 1
|
||||
|
||||
LR
|
||||
1 1 -400
|
||||
|
||||
|
||||
LINEBIKE
|
||||
2600 1.3 4.7 40
|
||||
|
||||
|
||||
26
dem.py
26
dem.py
|
|
@ -9,13 +9,6 @@ import pandas as pd
|
|||
from pw import DFile, ControlFile
|
||||
import dem_utils
|
||||
|
||||
ezdxf.options.set(
|
||||
"odafc-addon",
|
||||
"win_exec_path",
|
||||
"d:/ProgramFiles/ODAFileConverter/ODAFileConverter.exe",
|
||||
)
|
||||
from ezdxf.addons.odafc import export_dwg
|
||||
|
||||
|
||||
class Dem:
|
||||
def __init__(self, toml_path):
|
||||
|
|
@ -23,6 +16,7 @@ class Dem:
|
|||
toml_dict = tomli.load(tf)
|
||||
self._toml_dict = toml_dict
|
||||
dem_file_path = toml_dict["parameter"]["dem_file_path"]
|
||||
self._tree_height = toml_dict["parameter"]["tree_height"]
|
||||
self._dataset = gdal.Open(dem_file_path)
|
||||
self._dem_resolution = self._dataset.GetGeoTransform()[1]
|
||||
|
||||
|
|
@ -101,12 +95,27 @@ class Dem:
|
|||
],
|
||||
dxfattribs={"color": 5},
|
||||
) # 蓝色
|
||||
# 树的线
|
||||
if self._tree_height > 0:
|
||||
dm_msp.add_polyline2d(
|
||||
[
|
||||
(x_axis[i] / 5, (center_elevation[i] + self._tree_height) * 2)
|
||||
for i in range(len(center_elevation))
|
||||
]
|
||||
)
|
||||
toml_dict = self._toml_dict
|
||||
out_dxf_file_dir = toml_dict["parameter"]["out_dxf_file_dir"]
|
||||
os.makedirs(out_dxf_file_dir, exist_ok=True)
|
||||
# dm_doc.saveas(
|
||||
# f"{out_dxf_file_dir}/D{400+int(start_point_name[1:])}.dxf"
|
||||
# ) # 写断面文件
|
||||
ezdxf.options.set(
|
||||
"odafc-addon",
|
||||
"win_exec_path",
|
||||
"d:/ProgramFiles/ODAFileConverter/ODAFileConverter.exe",
|
||||
)
|
||||
from ezdxf.addons.odafc import export_dwg
|
||||
|
||||
export_dwg(
|
||||
dm_doc,
|
||||
f"{out_dxf_file_dir}/D{100+int(start_point_name[1:])}.dwg",
|
||||
|
|
@ -153,6 +162,7 @@ class Dem:
|
|||
center_elevation,
|
||||
left_elevation,
|
||||
right_elevation,
|
||||
self._tree_height
|
||||
)
|
||||
d_file.save(out_dxf_file_dir)
|
||||
self._copy_db_file()
|
||||
|
|
@ -297,7 +307,7 @@ class Dem:
|
|||
def _read_path_file(self):
|
||||
toml_dict = self._toml_dict
|
||||
path_file = toml_dict["parameter"]["path_file"]
|
||||
excel_pds = pd.read_excel(path_file)
|
||||
excel_pds = pd.read_excel(path_file, header=None)
|
||||
return excel_pds
|
||||
|
||||
def _copy_db_file(self):
|
||||
|
|
|
|||
11
main_dem.py
11
main_dem.py
|
|
@ -1,8 +1,13 @@
|
|||
from dem_utils import distance
|
||||
import sys
|
||||
from dem import Dem
|
||||
import ezdxf
|
||||
from loguru import logger
|
||||
if __name__ == "__main__":
|
||||
dem = Dem('db.toml')
|
||||
if len(sys.argv) < 2:
|
||||
toml_file_path = r"db_JS.toml"
|
||||
else:
|
||||
toml_file_path = sys.argv[1]
|
||||
logger.info(f'读取配置文件{toml_file_path}')
|
||||
dem = Dem(toml_file_path)
|
||||
dem.get_dem_info(if_print=True)
|
||||
dem.write_dxf()
|
||||
print("Finished.")
|
||||
37
pw.py
37
pw.py
|
|
@ -4,7 +4,14 @@ import numpy as np
|
|||
# D文件
|
||||
class DFile:
|
||||
def __init__(
|
||||
self, start_num, end_num, mileage: np.ndarray, center_z, left_z, right_z
|
||||
self,
|
||||
start_num,
|
||||
end_num,
|
||||
mileage: np.ndarray,
|
||||
center_z,
|
||||
left_z,
|
||||
right_z,
|
||||
tree_height,
|
||||
):
|
||||
self.start_num = start_num
|
||||
self.end_num = end_num
|
||||
|
|
@ -12,6 +19,7 @@ class DFile:
|
|||
self._center_z = center_z
|
||||
self._left_z = left_z
|
||||
self._right_z = right_z
|
||||
self._tree_height = tree_height
|
||||
pass
|
||||
|
||||
def save(self, out_dir):
|
||||
|
|
@ -28,6 +36,21 @@ class DFile:
|
|||
mat[:, 2] = center_z
|
||||
mat[:, 3] = left_z
|
||||
mat[:, 4] = right_z
|
||||
if self._tree_height > 0:
|
||||
mat = np.concatenate(
|
||||
(
|
||||
np.array([mat[0, :]]),
|
||||
np.array([[197, 0, 0, 0, self._tree_height]]),
|
||||
mat[1:, :],
|
||||
)
|
||||
) # 197
|
||||
mat = np.concatenate(
|
||||
(
|
||||
mat[0:-2, :],
|
||||
np.array([[198, mat[-1,1], 0, 0, self._tree_height]]),
|
||||
np.array([mat[-1, :]]),
|
||||
),
|
||||
) # 198
|
||||
with open(f"{out_dir}/D{100+start_num-4000}.txt", "w") as d_file:
|
||||
for foo in mat:
|
||||
d_file.write(f"{foo[0]:.0f}\t")
|
||||
|
|
@ -63,10 +86,16 @@ class ControlFile:
|
|||
with open(c_file_template_path) as c_file_template:
|
||||
c_template = c_file_template.read()
|
||||
c_template = c_template.replace("{SEGMENT_N}", str(len(segments)))
|
||||
c_template=c_template.replace("{TOWER_NUM_START}", f'{tower_start_number}')
|
||||
c_template=c_template.replace("{SEGMENT}", "\n".join([str(seg-4000+100) for seg in segments]))
|
||||
c_template = c_template.replace(
|
||||
"{TOWER_NUM_START}", f"{tower_start_number}"
|
||||
)
|
||||
c_template = c_template.replace(
|
||||
"{SEGMENT}", "\n".join([str(seg - 4000 + 100) for seg in segments])
|
||||
)
|
||||
c_template = c_template.replace("{SEGMENT_S}", f"{segments[0]-4000+100}")
|
||||
c_template = c_template.replace("{SEGMENT_E}", f"{segments[-1]-4000+100}")
|
||||
c_template=c_template.replace("{CONTROL_FILE}", f"S{segments[0]-4000+100}")
|
||||
c_template = c_template.replace(
|
||||
"{CONTROL_FILE}", f"S{segments[0]-4000+100}"
|
||||
)
|
||||
with open(f"{out_dir}/C{segments[0]-4000+100}.dat", "w") as c_file:
|
||||
c_file.write(c_template)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,11 @@
|
|||
import transformer
|
||||
import pandas as pd
|
||||
if __name__=='__main__':
|
||||
proj=transformer.Projector(transformer.EPSG_WGS_84,transformer.EPSG_CGCS_2000_108E)
|
||||
bzx=pd.read_excel(r'd:\3040\Desktop\宝中线.xlsx')
|
||||
lat=bzx['纬度']
|
||||
lon=bzx['经度']
|
||||
y,x=proj.transform(lat.to_numpy(),lon.to_numpy())
|
||||
xy_df=pd.DataFrame({'y':y,'x':x})
|
||||
print(xy_df)
|
||||
xy_df.to_excel(r'd:\3040\Desktop\宝中线xy.xlsx')
|
||||
Loading…
Reference in New Issue