Пример #1
0
def make_banner(options):
    leonardo_url = options.url + '/modules.php?name=leonardo'
    icon_url = options.url + options.icon
    icon = kml.Icon(href=icon_url)
    overlay_xy = kml.overlayXY(x=0.5,
                               y=1,
                               xunits='fraction',
                               yunits='fraction')
    screen_xy = kml.screenXY(x=0.5, y=1, xunits='fraction', yunits='fraction')
    size = kml.size(x=0, y=0, xunits='fraction', yunits='fraction')
    d = {'name': options.name, 'icon': icon_url, 'url': leonardo_url}
    ps = []
    ps.append('<a href="%(url)s"><img alt="%(name)s" src="%(icon)s" /></a>' %
              d)
    ps.append('<a href="%(url)s">%(name)s</a>' % d)
    ps.append('Created by <a href="http://github.com/twpayne/igc2kmz">'
              'igc2kmz</a><br/>Copyright &copy; Tom Payne, 2008')
    html = '<center>%s</center>' % ''.join('<p>%s</p>' % p for p in ps)
    description = kml.CDATA(html)
    balloon_style = kml.BalloonStyle(text=kml.CDATA('$[description]'))
    style = kml.Style(balloon_style)
    return kml.ScreenOverlay(icon,
                             overlay_xy,
                             screen_xy,
                             size,
                             style,
                             Snippet=None,
                             name=options.name,
                             description=description)
Пример #2
0
def make_takeoff_placemark(takeoff_row):
    coord = Coord.deg(takeoff_row.lat, -takeoff_row.lon, 0)
    point = kml.Point(coordinates=[coord])
    icon_style = kml.IconStyle(kml.Icon.palette(3, 40), scale=sqrt(0.6))
    label_style = kml.LabelStyle(scale=sqrt(0.6))
    style = kml.Style(icon_style, label_style)
    rows = []
    if takeoff_row.name:
        rows.append(('Name', takeoff_row.name))
    if takeoff_row.intName:
        if takeoff_row.intName != takeoff_row.name:
            rows.append(('Name in English', takeoff_row.intName))
    if takeoff_row.location:
        rows.append(('Location', takeoff_row.location))
    if takeoff_row.intLocation:
        if takeoff_row.intLocation != takeoff_row.location:
            rows.append(('Location in English', takeoff_row.intLocation))
    if takeoff_row.countryCode:
        rows.append(('Country', takeoff_row.countryCode))
    if takeoff_row.description:
        rows.append(('Description', takeoff_row.description))
    if takeoff_row.link:
        rows.append(('URL', '<a href="%(link)s">%(link)s</a>' % takeoff_row))
    if takeoff_row.modifyDate:
        rows.append(('Last modified', takeoff_row.modifyDate))
    description = kml.CDATA(make_table(rows))
    return kml.Placemark(point,
                         style,
                         Snippet=None,
                         name=takeoff_row.name,
                         description=description)
Пример #3
0
def main(argv):
    parser = optparse.OptionParser(usage='Usage; %prog [options]')
    parser.add_option('-o', '--output', metavar='FILENAME')
    parser.add_option('-n', '--name', metavar='STRING')
    parser.add_option('-i', '--icon', metavar='STRING')
    parser.add_option('-u', '--url', metavar='STRING')
    parser.set_defaults(name=DEFAULT_NAME)
    parser.set_defaults(icon=DEFAULT_ICON)
    parser.set_defaults(url=DEFAULT_URL)
    options, args = parser.parse_args(argv)
    icon = kml.Icon(href=options.icon)
    overlay_xy = kml.overlayXY(x=0.5,
                               y=1,
                               xunits='fraction',
                               yunits='fraction')
    screen_xy = kml.screenXY(x=0.5, y=1, xunits='fraction', yunits='fraction')
    size = kml.size(x=0, y=0, xunits='fraction', yunits='fraction')
    d = {'name': options.name, 'icon': options.icon, 'url': options.url}
    ps = []
    ps.append('<a href="%(url)s"><img alt="%(name)s" src="%(icon)s" /></a>' %
              d)
    ps.append('<a href="%(url)s">%(name)s</a>' % d)
    ps.append('Created by <a href="http://github.com/twpayne/igc2kmz">'
              'igc2kmz</a><br/>Copyright &copy; Tom Payne, 2008')
    html = '<center>%s</center' % ''.join('<p>%s</p>' % p for p in ps)
    description = kml.CDATA(html)
    snippet = kml.Snippet()
    balloon_style = kml.BalloonStyle(text=kml.CDATA('$[description]'))
    style = kml.Style(balloon_style)
    screen_overlay = kml.ScreenOverlay(icon,
                                       overlay_xy,
                                       screen_xy,
                                       size,
                                       snippet,
                                       style,
                                       name=options.name,
                                       description=description)
    output = open(options.output, 'w') if options.output else sys.stdout
    screen_overlay.pretty_write(output)