-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathparkingxml2aptdat.py
executable file
·108 lines (91 loc) · 3.63 KB
/
parkingxml2aptdat.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# (C) 2015 d-laser http://wiki.flightgear.org/User:Laserman
# --------------------------------------------------------------------------
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# --------------------------------------------------------------------------
# convert from Flightgear/TaxiDraw parking.xml or ICAO.groundnet.xml
# to "1300" type lines in apt.dat format
#
# you will find input files for this script in $FGDATA/AI/Airports
# and $FGDATA/Airports/?/?/?/
#
# purpose: to merge parking locations from legacy files
# and edit them all together in WED
#
# hot to use:
#
# download the latest apt.dat of your airport,
# open it in a text editor,
# insert the lines that this script made
# save the file
# in WED: import apt.dat
# remove duplicates
import sys, getopt
import xml.etree.ElementTree as ET
def convert_to_decimal(foo):
lonl = foo.split(' ')
#print lonl[0] , lonl[1]
lon = lonl[0].replace('W', '-')
lon = lon.replace('E', '')
lon = lon.replace('N', '')
lon = lon.replace('S', '-')
#print lon
dlon = float(lon) + (float(lonl[1])/60)
#print dlon
return dlon
def convert_to_decimal_lat(lat):
return 0
def main(argv):
helptext = 'parkingxml2aptdat.py -i <inputfile> '
#inputfile = "Airports/E/D/D/EDDF.groundnet.xml"
heading = 0
try:
opts, args = getopt.getopt(argv,"hi:")
except getopt.GetoptError:
print helptext
sys.exit(2)
for opt, arg in opts:
if opt == '-h':
print helptext
sys.exit()
elif opt == "-i":
inputfile = arg
print 'Input file is ', inputfile
#print 'Number of arguments:', len(sys.argv), 'arguments.'
#print 'Argument List:', str(sys.argv)
tree = ET.parse(inputfile)
root = tree.getroot()
xp_type = "heavy|jets"
xp_service = "gate"
for child in root:
if child.tag == 'parkingList':
print child.tag,child.attrib
for cc in child:
#print cc.tag,cc.attrib
if cc.tag == 'Parking':
# <Parking index="0" type="gate" name="V109" lat="N50 2.991748" lon="E8 35.487733" heading="160.6" radius="44" pushBackRoute="92" airlineCodes="" />
#print cc.attrib['index'] , cc.attrib['type'], cc.attrib['name'] , cc.attrib['number'], cc.attrib['lat'] , cc.attrib['lon'], cc.attrib['heading'] , cc.attrib['radius']
name = cc.attrib['name']
if "number" in cc.attrib:
name = name + cc.attrib['number']
heading = cc.attrib['heading']
lon = convert_to_decimal(cc.attrib['lon'])
lat = convert_to_decimal(cc.attrib['lat'])
#1300 51.64821489 007.16123693 74.61 tie_down turboprops|props Apron start 3
print "1300", lat, lon, heading, xp_service, xp_type, name
if __name__ == "__main__":
main(sys.argv[1:])