forked from daohu527/imap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
82 lines (64 loc) · 2.44 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# -*- coding: utf-8 -*-
#!/usr/bin/env python
# Copyright 2021 daohu527 <[email protected]>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import argparse
import global_var
from lib.draw import add_editor, show_map
from lib.convertor import Opendrive2Apollo
def convert_map_format():
opendrive2apollo = Opendrive2Apollo(args.input, args.output)
opendrive2apollo.set_parameters(only_driving=True)
opendrive2apollo.convert()
opendrive2apollo.save_map()
def show_open_drive_map():
opendrive2apollo = Opendrive2Apollo(args.map)
opendrive2apollo.set_parameters(only_driving=True)
opendrive2apollo.convert()
if __name__ == "__main__":
parser = argparse.ArgumentParser(
description="Mapshow is a tool to display hdmap info on a map.",
prog="mapshow.py")
parser.add_argument(
"-m", "--map", action="store", type=str, required=False,
help="Specify the map file in txt or binary format")
parser.add_argument(
"-l", "--lane", action="store", type=str, required=False,
help="Find lane by lane id")
parser.add_argument(
"-f", "--format", action="store", type=str, required=False,
nargs='?', const="0", help="Convert format")
parser.add_argument(
"-i", "--input", action="store", type=str, required=False,
help="map input path")
parser.add_argument(
"-o", "--output", action="store", type=str, required=False,
help="map output path")
args = parser.parse_args()
# 1. Init global var
global_var._init()
# 2. show map
if args.map is not None:
# TODO(zero): fix two windows
suffix = args.map.split(".")[1]
if suffix == "bin" or suffix == "txt":
add_editor()
show_map(args.map, args.lane)
elif suffix == "xodr":
show_open_drive_map()
else:
pass
# 3. convert opendrive map to apllo
if args.format is not None:
convert_map_format()