当前位置: 首页>>代码示例>>Python>>正文


Python KML_ElementMaker.hotspot方法代码示例

本文整理汇总了Python中pykml.factory.KML_ElementMaker.hotspot方法的典型用法代码示例。如果您正苦于以下问题:Python KML_ElementMaker.hotspot方法的具体用法?Python KML_ElementMaker.hotspot怎么用?Python KML_ElementMaker.hotspot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pykml.factory.KML_ElementMaker的用法示例。


在下文中一共展示了KML_ElementMaker.hotspot方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: add_style

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import hotspot [as 别名]
def add_style(doc, color, highlight):

    # Add the normal style for the KML
    doc.append(KML.Style(
        KML.IconStyle(
            KML.color(color),
            KML.scale(1.1),
            KML.Icon(
                KML.href('http://www.gstatic.com/mapspro/images/stock/503-wht-blank_maps.png')
            ),
            KML.hotspot('', x='16', y='31', xunits='pixels', yunits='insetPixels'),
        ),

        KML.LabelStyle(
            KML.scale(1.1)
        ),

        id='icon-503-{}-normal'.format(color)))

    # Add the highlight style for the KML
    doc.append(KML.Style(
        KML.IconStyle(
            KML.color(highlight),
            KML.scale(1.1),
            KML.Icon(
                KML.href('http://www.gstatic.com/mapspro/images/stock/503-wht-blank_maps.png')
            ),
            KML.hotSpot('', x='16', y='31', xunits='pixels', yunits='insetPixels'),
        ),

        KML.LabelStyle(
            KML.scale(1.1)
        ),

        id='icon-503-{}-highlight'.format(highlight)))

    # Set the style map
    doc.append(KML.StyleMap(
        KML.Pair(
            KML.key('normal'),
            KML.styleUrl('#icon-503-{}-normal'.format(color))
        ),

        KML.Pair(
            KML.key('highlight'),
            KML.styleUrl('#icon-503-{}-highlight'.format(highlight))
        ),

        id='icon-503-{}'.format(color)))

    return doc
开发者ID:mlockwood,项目名称:go_transit_src,代码行数:53,代码来源:stop_kml.py

示例2: validate

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import hotspot [as 别名]
def validate():
    table = {}
    reader = open('{}/gtfs/files/shapes.txt'.format(REPORT_PATH))
    for line in reader:
        shape, lat, lng, seq = re.split(',', line.rstrip())
        if shape == 'shape_id':
            continue
        if shape not in table:
            table[shape] = {}
        table[shape][seq] = (lat, lng)

    # For each shape
    for shape in table:

        doc = KML.Document(KML.name('Shape {}'.format(shape)))

        # For each sequence in order
        for seq in sorted(table[shape].keys()):
            # Add a placemark in the KML file
            doc.append(KML.Placemark(
                KML.name('{}'.format(seq)),
                KML.styleUrl('#icon-503-777777'),
                KML.Point(
                    KML.coordinates('{},{},0'.format(table[shape][seq][1], table[shape][seq][0]))
                )
            ))

        # Add the normal style for the KML
        doc.append(KML.Style(
            KML.IconStyle(
                KML.color('ff777777'),
                KML.scale(1.1),
                KML.Icon(
                    KML.href('http://www.gstatic.com/mapspro/images/stock/503-wht-blank_maps.png')
                ),
                KML.hotspot('', x='16', y='31', xunits='pixels', yunits='insetPixels'),
            ),

            KML.LabelStyle(
                KML.scale(1.1)
            ),

            id='icon-503-777777-normal'))

        # Add the highlight style for the KML
        doc.append(KML.Style(
            KML.IconStyle(
                KML.color('ff555555'),
                KML.scale(1.1),
                KML.Icon(
                    KML.href('http://www.gstatic.com/mapspro/images/stock/503-wht-blank_maps.png')
                ),
                KML.hotSpot('', x='16', y='31', xunits='pixels', yunits='insetPixels'),
            ),

            KML.LabelStyle(
                KML.scale(1.1)
            ),

            id='icon-503-555555-highlight'))

        # Set the style map
        doc.append(KML.StyleMap(
            KML.Pair(
                KML.key('normal'),
                KML.styleUrl('#icon-503-777777-normal')
            ),

            KML.Pair(
                KML.key('highlight'),
                KML.styleUrl('#icon-503-777777-highlight')
            ),

            id='icon-503-777777'))

        # Send KML file to string and replace spurious \
        kml = KML.kml(doc)
        kml = etree.tostring(kml, pretty_print=True).decode('utf-8', errors='strict').replace('\\', '')

        # Add encoding line
        final = ["<?xml version='1.0' encoding='UTF-8'?>"]

        # Unescape the CDATA description HTML
        for line in re.split('\n', kml):
            if re.search('\<description\>', line):
                final.append(unescape(line))
            else:
                final.append(line)

        # Write the file
        set_directory('{}/gtfs/test'.format(REPORT_PATH))
        writer = open('{}/gtfs/test/shape_{}.kml'.format(REPORT_PATH, shape), 'w')
        writer.write('\n'.join(final))
开发者ID:mlockwood,项目名称:go_transit_src,代码行数:95,代码来源:validate_shape_kml.py


注:本文中的pykml.factory.KML_ElementMaker.hotspot方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。