Browse Source

Merge branch 'master' of sol:src/igc2kmz

debian-sid
Tom Payne 14 years ago
parent
commit
1b1025a738
  1. 6
      bin/leonardo2kmz.py
  2. 14
      igc2kmz/__init__.py

6
bin/leonardo2kmz.py

@ -68,6 +68,8 @@ def main(argv):
parser.add_option('-u', '--url', metavar='URL', help='set URL')
parser.add_option('-d', '--directory', metavar='PATH', help='set directory')
parser.add_option('-e', '--engine', metavar='URL', help='set engine')
parser.add_option('-z', '--tz-offset', metavar='HOURS', type='int',
help='set timezone offset')
parser.add_option('--debug', action='store_true',
help='enable pretty KML output')
parser.set_defaults(output='igc2kmz.kmz')
@ -76,6 +78,7 @@ def main(argv):
parser.set_defaults(url=DEFAULT_URL)
parser.set_defaults(directory=DEFAULT_DIRECTORY)
parser.set_defaults(engine=DEFAULT_ENGINE)
parser.set_defaults(tz_offset=0)
parser.set_defaults(debug=False)
options, args = parser.parse_args(argv)
#
@ -176,7 +179,8 @@ def main(argv):
#
flights.append(flight)
#
kmz = flights2kmz(flights, roots=[screen_overlay])
kmz = flights2kmz(flights, roots=[screen_overlay],
tz_offset=options.tz_offset)
kmz.write(options.output, '2.2', debug=options.debug)
if __name__ == '__main__':

14
igc2kmz/__init__.py

@ -39,9 +39,7 @@ INFINITY = unicodedata.lookup('INFINITY').encode('utf_8')
MULTIPLICATION_SIGN = unicodedata.lookup('MULTIPLICATION SIGN').encode('utf_8')
UP_TACK = unicodedata.lookup('UP TACK').encode('utf_8')
IMAGES_DIR = os.path.normpath(os.path.join(os.path.dirname(__file__),
'..',
'images'))
BASE_DIR = os.path.normpath(os.path.join(os.path.dirname(__file__), '..'))
def make_table(rows, bgcolors='#dddddd #ffffff'.split()):
@ -188,15 +186,17 @@ class Stock(object):
line_style)
self.kmz.add_roots(self.xc_style2)
#
self.pixel_url = os.path.join(IMAGES_DIR, 'pixel.png')
self.kmz.add_files({self.pixel_url: open(self.pixel_url).read()})
self.pixel_url = os.path.join('images', 'pixel.png')
pixel = open(os.path.join(BASE_DIR, self.pixel_url)).read()
self.kmz.add_files({self.pixel_url: pixel})
#
self.visible_none_folder = self.make_none_folder(1)
self.invisible_none_folder = self.make_none_folder(0)
#
animation_icon_url = os.path.join(IMAGES_DIR, 'paraglider.png')
animation_icon_url = os.path.join('images', 'paraglider.png')
self.animation_icon = kml.Icon(href=animation_icon_url)
files = {animation_icon_url: open(animation_icon_url).read()}
animation_icon = open(os.path.join(BASE_DIR, animation_icon_url)).read()
files = {animation_icon_url: animation_icon}
self.kmz.add_files(files)

Loading…
Cancel
Save