|
@@ -30,12 +30,13 @@ def parse_arguments():
|
|
default='lst',
|
|
default='lst',
|
|
help='要处理的数据类型 (lst 或 pgvil)'
|
|
help='要处理的数据类型 (lst 或 pgvil)'
|
|
)
|
|
)
|
|
-
|
|
|
|
|
|
+
|
|
# 定义参数
|
|
# 定义参数
|
|
parser.add_argument(
|
|
parser.add_argument(
|
|
'--zip-path',
|
|
'--zip-path',
|
|
type=Path,
|
|
type=Path,
|
|
- default=Path('V2I_CSAE53-2020_HazardousLocationW_LST_02-01.zip'),
|
|
|
|
|
|
+ # default=Path('/home/server/桌面/XGJ/dataprocess/V2V_CSAE53-2020_ForwardCollision_LST_02-01.zip'),
|
|
|
|
+ default=Path('/home/server/桌面/XGJ/dataprocess/V2I_CSAE53-2020_HazardousLocationW_LST_02-01.zip'),
|
|
help='输入的ZIP数据文件路径'
|
|
help='输入的ZIP数据文件路径'
|
|
)
|
|
)
|
|
|
|
|
|
@@ -49,7 +50,7 @@ def parse_arguments():
|
|
parser.add_argument(
|
|
parser.add_argument(
|
|
'--output-dir',
|
|
'--output-dir',
|
|
type=Path,
|
|
type=Path,
|
|
- default=Path('output'),
|
|
|
|
|
|
+ default=Path('./data_zhaoyuan3/'),
|
|
help='输出目录的基础路径'
|
|
help='输出目录的基础路径'
|
|
)
|
|
)
|
|
|
|
|
|
@@ -66,14 +67,14 @@ def parse_arguments():
|
|
default=0.0,
|
|
default=0.0,
|
|
help='X坐标偏移量'
|
|
help='X坐标偏移量'
|
|
)
|
|
)
|
|
-
|
|
|
|
|
|
+
|
|
parser.add_argument(
|
|
parser.add_argument(
|
|
'--y-offset',
|
|
'--y-offset',
|
|
type=float,
|
|
type=float,
|
|
default=0.0,
|
|
default=0.0,
|
|
help='Y坐标偏移量'
|
|
help='Y坐标偏移量'
|
|
)
|
|
)
|
|
-
|
|
|
|
|
|
+
|
|
parser.add_argument(
|
|
parser.add_argument(
|
|
'--config',
|
|
'--config',
|
|
type=Path,
|
|
type=Path,
|
|
@@ -87,7 +88,7 @@ def parse_arguments():
|
|
default=Path('plugins'),
|
|
default=Path('plugins'),
|
|
help='插件目录路径'
|
|
help='插件目录路径'
|
|
)
|
|
)
|
|
-
|
|
|
|
|
|
+
|
|
parser.add_argument(
|
|
parser.add_argument(
|
|
'--resources-dir',
|
|
'--resources-dir',
|
|
type=Path,
|
|
type=Path,
|
|
@@ -100,27 +101,27 @@ def parse_arguments():
|
|
action='store_true',
|
|
action='store_true',
|
|
help='启用并行处理'
|
|
help='启用并行处理'
|
|
)
|
|
)
|
|
-
|
|
|
|
|
|
+
|
|
parser.add_argument(
|
|
parser.add_argument(
|
|
'--no-parallel',
|
|
'--no-parallel',
|
|
action='store_true',
|
|
action='store_true',
|
|
help='禁用并行处理'
|
|
help='禁用并行处理'
|
|
)
|
|
)
|
|
-
|
|
|
|
|
|
+
|
|
parser.add_argument(
|
|
parser.add_argument(
|
|
'--max-workers',
|
|
'--max-workers',
|
|
type=int,
|
|
type=int,
|
|
default=None,
|
|
default=None,
|
|
help='并行处理的最大工作线程数'
|
|
help='并行处理的最大工作线程数'
|
|
)
|
|
)
|
|
-
|
|
|
|
|
|
+
|
|
parser.add_argument(
|
|
parser.add_argument(
|
|
'--batch-size',
|
|
'--batch-size',
|
|
type=int,
|
|
type=int,
|
|
default=10000,
|
|
default=10000,
|
|
help='处理大数据集时的批处理大小'
|
|
help='处理大数据集时的批处理大小'
|
|
)
|
|
)
|
|
-
|
|
|
|
|
|
+
|
|
parser.add_argument(
|
|
parser.add_argument(
|
|
'--log-level',
|
|
'--log-level',
|
|
type=str,
|
|
type=str,
|
|
@@ -128,14 +129,14 @@ def parse_arguments():
|
|
default='INFO',
|
|
default='INFO',
|
|
help='日志级别'
|
|
help='日志级别'
|
|
)
|
|
)
|
|
-
|
|
|
|
|
|
+
|
|
parser.add_argument(
|
|
parser.add_argument(
|
|
'--log-dir',
|
|
'--log-dir',
|
|
type=Path,
|
|
type=Path,
|
|
default=Path('logs'),
|
|
default=Path('logs'),
|
|
help='日志文件目录'
|
|
help='日志文件目录'
|
|
)
|
|
)
|
|
-
|
|
|
|
|
|
+
|
|
parser.add_argument(
|
|
parser.add_argument(
|
|
'--no-log-file',
|
|
'--no-log-file',
|
|
action='store_true',
|
|
action='store_true',
|
|
@@ -151,17 +152,17 @@ def setup_config(args):
|
|
zip_name = args.zip_path.stem
|
|
zip_name = args.zip_path.stem
|
|
output_dir = args.output_dir / zip_name
|
|
output_dir = args.output_dir / zip_name
|
|
output_dir.mkdir(parents=True, exist_ok=True)
|
|
output_dir.mkdir(parents=True, exist_ok=True)
|
|
-
|
|
|
|
|
|
+
|
|
print(f"输出目录: {output_dir}")
|
|
print(f"输出目录: {output_dir}")
|
|
|
|
|
|
# 加载配置
|
|
# 加载配置
|
|
config = load_config(args.config)
|
|
config = load_config(args.config)
|
|
-
|
|
|
|
|
|
+
|
|
# 更新配置中的输出目录为包含zip名称的子目录
|
|
# 更新配置中的输出目录为包含zip名称的子目录
|
|
config['paths']['output_dir'] = str(output_dir)
|
|
config['paths']['output_dir'] = str(output_dir)
|
|
config['paths']['data_dir'] = str(output_dir) # 确保数据也输出到同一目录
|
|
config['paths']['data_dir'] = str(output_dir) # 确保数据也输出到同一目录
|
|
config['paths']['temp_dir'] = str(output_dir) # 确保临时文件也在同一目录
|
|
config['paths']['temp_dir'] = str(output_dir) # 确保临时文件也在同一目录
|
|
-
|
|
|
|
|
|
+
|
|
# 使用命令行参数覆盖配置文件中的设置
|
|
# 使用命令行参数覆盖配置文件中的设置
|
|
if args.use_parallel and args.no_parallel:
|
|
if args.use_parallel and args.no_parallel:
|
|
print("警告: 同时指定了 --use-parallel 和 --no-parallel,将使用 --use-parallel")
|
|
print("警告: 同时指定了 --use-parallel 和 --no-parallel,将使用 --use-parallel")
|
|
@@ -170,30 +171,30 @@ def setup_config(args):
|
|
config['processing']['use_parallel'] = True
|
|
config['processing']['use_parallel'] = True
|
|
elif args.no_parallel:
|
|
elif args.no_parallel:
|
|
config['processing']['use_parallel'] = False
|
|
config['processing']['use_parallel'] = False
|
|
-
|
|
|
|
|
|
+
|
|
if args.max_workers is not None:
|
|
if args.max_workers is not None:
|
|
config['processing']['max_workers'] = args.max_workers
|
|
config['processing']['max_workers'] = args.max_workers
|
|
-
|
|
|
|
|
|
+
|
|
if args.batch_size != 10000: # 不等于默认值
|
|
if args.batch_size != 10000: # 不等于默认值
|
|
config['processing']['batch_size'] = args.batch_size
|
|
config['processing']['batch_size'] = args.batch_size
|
|
-
|
|
|
|
|
|
+
|
|
# 更新日志配置
|
|
# 更新日志配置
|
|
config['logging']['level'] = args.log_level
|
|
config['logging']['level'] = args.log_level
|
|
config['logging']['log_dir'] = str(args.log_dir)
|
|
config['logging']['log_dir'] = str(args.log_dir)
|
|
config['logging']['log_to_file'] = not args.no_log_file
|
|
config['logging']['log_to_file'] = not args.no_log_file
|
|
-
|
|
|
|
|
|
+
|
|
# 更新坐标系配置
|
|
# 更新坐标系配置
|
|
config['coordinates']['utm_zone'] = args.utm_zone
|
|
config['coordinates']['utm_zone'] = args.utm_zone
|
|
config['coordinates']['x_offset'] = args.x_offset
|
|
config['coordinates']['x_offset'] = args.x_offset
|
|
config['coordinates']['y_offset'] = args.y_offset
|
|
config['coordinates']['y_offset'] = args.y_offset
|
|
-
|
|
|
|
|
|
+
|
|
# 更新路径配置
|
|
# 更新路径配置
|
|
config['paths']['plugins_dir'] = str(args.plugins_dir)
|
|
config['paths']['plugins_dir'] = str(args.plugins_dir)
|
|
config['paths']['resources_dir'] = str(args.resources_dir)
|
|
config['paths']['resources_dir'] = str(args.resources_dir)
|
|
-
|
|
|
|
|
|
+
|
|
# 应用更新后的配置
|
|
# 应用更新后的配置
|
|
update_config(config)
|
|
update_config(config)
|
|
-
|
|
|
|
|
|
+
|
|
return output_dir
|
|
return output_dir
|
|
|
|
|
|
|
|
|
|
@@ -206,7 +207,7 @@ def process_plugins(args, output_dir, final_csv_path):
|
|
# 处理自定义数据
|
|
# 处理自定义数据
|
|
print("处理并合并自定义数据...")
|
|
print("处理并合并自定义数据...")
|
|
folders = resource_manager.list_zip_folders(args.zip_path)
|
|
folders = resource_manager.list_zip_folders(args.zip_path)
|
|
-
|
|
|
|
|
|
+
|
|
for folder in folders:
|
|
for folder in folders:
|
|
plugin = plugin_manager.get_plugin_for_data(args.zip_path, folder)
|
|
plugin = plugin_manager.get_plugin_for_data(args.zip_path, folder)
|
|
if not plugin:
|
|
if not plugin:
|
|
@@ -220,22 +221,22 @@ def process_plugins(args, output_dir, final_csv_path):
|
|
folder,
|
|
folder,
|
|
output_dir
|
|
output_dir
|
|
)
|
|
)
|
|
-
|
|
|
|
|
|
+
|
|
if plugin_output is not None and not plugin_output.empty:
|
|
if plugin_output is not None and not plugin_output.empty:
|
|
output_file = output_dir / f"{folder}_processed.csv"
|
|
output_file = output_dir / f"{folder}_processed.csv"
|
|
print(f'插件输出文件: {output_file}')
|
|
print(f'插件输出文件: {output_file}')
|
|
plugin_output.to_csv(output_file, index=False)
|
|
plugin_output.to_csv(output_file, index=False)
|
|
-
|
|
|
|
|
|
+
|
|
if not resource_manager.validate_plugin_output(output_file):
|
|
if not resource_manager.validate_plugin_output(output_file):
|
|
print(f"警告: 插件输出验证失败: {folder}")
|
|
print(f"警告: 插件输出验证失败: {folder}")
|
|
continue
|
|
continue
|
|
-
|
|
|
|
|
|
+
|
|
# 合并自定义数据与主数据文件
|
|
# 合并自定义数据与主数据文件
|
|
print(f"合并 {folder} 数据...")
|
|
print(f"合并 {folder} 数据...")
|
|
if resource_manager.merge_plugin_data(
|
|
if resource_manager.merge_plugin_data(
|
|
- final_csv_path,
|
|
|
|
- output_file,
|
|
|
|
- final_csv_path
|
|
|
|
|
|
+ final_csv_path,
|
|
|
|
+ output_file,
|
|
|
|
+ final_csv_path
|
|
):
|
|
):
|
|
print(f"成功合并 {folder} 数据")
|
|
print(f"成功合并 {folder} 数据")
|
|
else:
|
|
else:
|
|
@@ -251,16 +252,16 @@ def main():
|
|
try:
|
|
try:
|
|
# 设置配置
|
|
# 设置配置
|
|
output_dir = setup_config(args)
|
|
output_dir = setup_config(args)
|
|
-
|
|
|
|
|
|
+
|
|
print("开始数据处理流程")
|
|
print("开始数据处理流程")
|
|
print(f"从以下位置加载配置: {args.config}")
|
|
print(f"从以下位置加载配置: {args.config}")
|
|
-
|
|
|
|
|
|
+
|
|
# 根据数据类型选择处理流程
|
|
# 根据数据类型选择处理流程
|
|
if args.data_type == 'lst':
|
|
if args.data_type == 'lst':
|
|
final_csv_path = process_lst_data(
|
|
final_csv_path = process_lst_data(
|
|
zip_data_path=args.zip_path,
|
|
zip_data_path=args.zip_path,
|
|
output_base_dir=output_dir,
|
|
output_base_dir=output_dir,
|
|
- trafficlight_json_path=args.trafficlight_json,
|
|
|
|
|
|
+ trafficlight_json_path=args.trafficlight_json,
|
|
utm_zone=args.utm_zone,
|
|
utm_zone=args.utm_zone,
|
|
x_offset=args.x_offset,
|
|
x_offset=args.x_offset,
|
|
y_offset=args.y_offset
|
|
y_offset=args.y_offset
|
|
@@ -276,13 +277,13 @@ def main():
|
|
else:
|
|
else:
|
|
print(f"不支持的数据类型: {args.data_type}")
|
|
print(f"不支持的数据类型: {args.data_type}")
|
|
sys.exit(1)
|
|
sys.exit(1)
|
|
-
|
|
|
|
|
|
+
|
|
if not final_csv_path:
|
|
if not final_csv_path:
|
|
print(f"{args.data_type}内置数据处理失败")
|
|
print(f"{args.data_type}内置数据处理失败")
|
|
sys.exit(1)
|
|
sys.exit(1)
|
|
-
|
|
|
|
|
|
+
|
|
print(f"\n{args.data_type}内置处理流程成功完成!")
|
|
print(f"\n{args.data_type}内置处理流程成功完成!")
|
|
-
|
|
|
|
|
|
+
|
|
# 处理插件数据
|
|
# 处理插件数据
|
|
process_plugins(args, output_dir, final_csv_path)
|
|
process_plugins(args, output_dir, final_csv_path)
|
|
|
|
|