1.添加同步S文件到TA文件中的功能。
This commit is contained in:
parent
223ed5a228
commit
9de2208b8f
|
|
@ -158,7 +158,61 @@ class TaFileObject:
|
|||
|
||||
# 将S文件中的塔高同步到TA文件中。
|
||||
def sync_tower_height_from_S(self):
|
||||
|
||||
enter_string = input(
|
||||
"Will synchronize height in S to Ta. Enter S2T to proceed.\n"
|
||||
)
|
||||
if enter_string.lower() != "s2t":
|
||||
print("Not confirmed.")
|
||||
return
|
||||
# 先取得所有S的呼高
|
||||
s_tower_height_dic = {}
|
||||
s_as_single = SFileAsSingle(self._SFile)
|
||||
for s_entry in s_as_single.content():
|
||||
if s_entry[0] == "首端转角号" or s_entry[0] == "塔号":
|
||||
continue
|
||||
tower_number = s_entry[0]
|
||||
tower_height = s_entry[7]
|
||||
s_tower_height_dic[tower_number] = tower_height
|
||||
ta_content = self._read(self._file_path)
|
||||
new_ta_content = list(ta_content)
|
||||
for index, ta_entry in enumerate(ta_content):
|
||||
ta_tower_number = ta_entry[0]
|
||||
if ta_tower_number in s_tower_height_dic:
|
||||
if (
|
||||
abs(
|
||||
float(new_ta_content[index][9])
|
||||
- float(s_tower_height_dic[ta_tower_number])
|
||||
)
|
||||
> 1e-5 # 新旧呼高不一致
|
||||
):
|
||||
print(
|
||||
"Tower {tower_number} height({old_height} -> {new_height}) in S has been synchronized to TA.\n".format(
|
||||
tower_number=ta_tower_number,
|
||||
old_height=ta_content[index][9],
|
||||
new_height=s_tower_height_dic[ta_tower_number],
|
||||
)
|
||||
)
|
||||
new_tower_height = s_tower_height_dic[ta_tower_number]
|
||||
new_ta_content[index][9] = new_tower_height # 将S文件中的塔高赋值到TA文件中
|
||||
# 修改TA中WNSZ_51这样的塔名
|
||||
old_tower_name_height = ta_entry[8]
|
||||
tower_name = old_tower_name_height.split("_")[0]
|
||||
new_tower_name_height = "{tower_name}_{new_height}".format(
|
||||
tower_name=tower_name, new_height=new_tower_height
|
||||
)
|
||||
new_ta_content[index][8] = new_tower_name_height
|
||||
# 备份TA文件
|
||||
ta_file_dir = get_directory(self._file_path)
|
||||
ta_file_name = get_file_name_with_extention(self._file_path)[0]
|
||||
backup_time = file_backup_time()
|
||||
backup_file_path = "{ta_file_dir}/{ta_file_name}{backup_time}.TA".format(
|
||||
ta_file_dir=ta_file_dir, ta_file_name=ta_file_name, backup_time=backup_time
|
||||
)
|
||||
shutil.copy(self._file_path, backup_file_path)
|
||||
with open(self._file_path, "w") as ta_file:
|
||||
for ta_c in new_ta_content:
|
||||
ta_file.write("{ta_c}\n".format(ta_c=",".join(ta_c)))
|
||||
print("Synchronization form S to TA is finished.")
|
||||
pass
|
||||
|
||||
def start(self):
|
||||
|
|
|
|||
1
main.py
1
main.py
|
|
@ -10,6 +10,7 @@ if __name__ == "__main__":
|
|||
r"d:\工程\灵州-青山\排位\72-169\S072.DAT",
|
||||
]
|
||||
ta_object = TaFileObject(r"d:\工程\灵州-青山\排位\道亨\最终排位\最终排位.TA", SFile)
|
||||
# ta_object.sync_tower_height_from_S()
|
||||
ta_object.start()
|
||||
# generate_ta_from_csv.generate_ta(r"d:\工程\灵州-青山\排位\道亨\最终排位\最终排位.TA",SFile,r'd:\工程\灵州-青山\排位\道亨\成果表.csv')
|
||||
print("Finished.")
|
||||
|
|
|
|||
Loading…
Reference in New Issue