当前位置: 首页>>代码示例>>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方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: frame_placemark

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import hotSpot [as 别名]
def frame_placemark(origin, name, x, y, theta=0.0,
                    marker='axes.png', scale=1.0, color='ffffffff'):
    frame = srr.util.local_to_global(origin, x, y, theta)

    return KML.Placemark(
        KML.name(name),
        KML.Point(
            KML.coordinates("{lon},{lat},{alt}".format(
                lon=frame[0], lat=frame[1], alt=0)),
            ),
        KML.LookAt(
            KML.longitude(frame[0]),
            KML.latitude(frame[1]),
            KML.altitude(0),
            KML.heading(frame[2]),
            KML.tilt(0),
            KML.roll(0),
            KML.altitudeMode("relativeToGround"),
            KML.range(DEFAULT_HEIGHT)
        ),
        KML.Style(
            KML.IconStyle(
                KML.scale(scale),
                KML.heading(frame[2]),
                KML.color(color),
                KML.Icon(
                    KML.href(flask.url_for('static',
                                           filename=marker,
                                           _external=True)),
                    ),
                KML.hotSpot(x="0.5", y="0.5",
                            xunits="fraction",
                            yunits="fraction")
                ),
            )
        )
开发者ID:cephalsystems,项目名称:srr,代码行数:38,代码来源:viewer.py

示例3: 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

示例4:

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import hotSpot [as 别名]
    [5,'ffff00aa'],
    [6,'ff00ffff'],
    [7,'ff0000ff'],
]

# create a series of Icon Styles
for threshold,color in iconstyles:
    doc.append(
        KML.Style(
            KML.IconStyle(
                KML.color(color),
                KML.scale(threshold/2),
                KML.Icon(
                    KML.href("http://maps.google.com/mapfiles/kml/shapes/earthquake.png"),
                ),
                KML.hotSpot(x="0.5",y="0",xunits="fraction",yunits="fraction"),
            ),
            balloonstyle,
            id="earthquake-style-{threshold}".format(threshold=threshold),
        )
    )

doc.append(KML.Folder())

# read in a csv file, and create a placemark for each record
url="http://earthquake.usgs.gov/earthquakes/catalogs/eqs7day-M2.5.txt"
fileobject = urllib2.urlopen(url)
for row in csv.DictReader(fileobject):
    timestamp = datetime.strptime(row["Datetime"], "%A, %B %d, %Y %H:%M:%S %Z")
    pm = KML.Placemark(
        KML.name("Magnitude={0}".format(row['Magnitude'])),
开发者ID:123abcde,项目名称:pykml,代码行数:33,代码来源:example_csv_to_kml.py

示例5: main

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import hotSpot [as 别名]
def main():
    """
    Create a KML document with a folder and a style for each earthquake
    magnitude
    """
    doc = KML.Document()

    icon_styles = [
        [2, 'ff000000'],
        [3, 'ffff0000'],
        [4, 'ff00ff55'],
        [5, 'ffff00aa'],
        [6, 'ff00ffff'],
        [7, 'ff0000ff'],
    ]

    # create a series of Icon Styles
    for threshold, color in icon_styles:
        doc.append(
            KML.Style(
                KML.IconStyle(
                    KML.color(color),
                    KML.scale(threshold / 2),
                    KML.Icon(
                        KML.href('http://maps.google.com/mapfiles/kml/shapes/earthquake.png'),
                    ),
                    KML.hotSpot(x='0.5', y='0', xunits='fraction', yunits='fraction'),
                ),
                get_balloon_style(),
                id='earthquake-style-{threshold}'.format(threshold=threshold),
            )
        )

    doc.append(KML.Folder())

    # read in a csv file, and create a placemark for each record
    url = 'http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/2.5_week.csv'
    fileobject = urlopen(url)

    if six.PY3:  # fileobject is bytes, csv requires string
        import codecs
        fileobject = codecs.getreader('utf-8')(fileobject)

    for row in csv.DictReader(fileobject):
        timestamp = datetime.strptime(row['time'], '%Y-%m-%dT%H:%M:%S.%fZ')
        pm = KML.Placemark(
            KML.name('Magnitude={0}'.format(row['mag'])),
            KML.TimeStamp(
                KML.when(timestamp.strftime('%Y-%m-%dT%H:%M:%SZ')),
            ),
            KML.styleUrl(
                '#earthquake-style-{thresh}'.format(
                    thresh=int(float(row['mag']))
                )
            ),
            make_extended_data_elements(row),
            KML.Point(
                KML.coordinates('{0},{1}'.format(row['longitude'], row['latitude']))
            )
        )
        doc.Folder.append(pm)

    # check if the schema is valid
    schema_gx = Schema('kml22gx.xsd')
    schema_gx.assertValid(doc)

    kml = KML.kml(doc)

    print(etree.tostring(format_xml_with_cdata(kml),
                         pretty_print=True,
                         encoding='utf-8',
                         xml_declaration=True).decode())
开发者ID:recombinant,项目名称:pykml,代码行数:74,代码来源:example_csv_to_kml.py

示例6: create_style

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import hotSpot [as 别名]
def create_style(id_name, poly_colour, line_colour="FF000000", line_width="2"):

	# create a KML document with a folder and a default style
	stylename = "ballooon_style"
	balloon_text = """
	<font size="5"><b>$[name]</b></font><br>
	<br>
	<table width="500" border="1" cellspacing="0" cellpadding="6">
     <col width="150">
     <col width="350">

     <tr align="left" valign="top">
       <td><b>Dates:</b></td>
       <td>$[dates]</td>
     </tr>

     <tr align="left" valign="top">
       <td><b>Status:</b></td>
       <td>$[status]</td>
     </tr>

     <tr align="left" valign="top">
       <td><b>History:</td>
       <td>$[history]</td>
     </tr>
	 
	 <tr align="left" valign="top">
       <td><b>1912 Address:</td>
       <td>$[addrss]</td>
     </tr>
	 
	 <tr align="left" valign="top">
       <td><b>Sources:</td>
       <td>$[sources]</td>
     </tr>

</table><br>

<table width="500" border="1" cellspacing="0" cellpadding="6">

     <tr align="center" valign="top">
        <td><b>Photos</b></td>
     </tr>

     <tr align="left" valign="top">
       <td>$[photos]</td>
     </tr>

</table>"""

	out_style = KML.Style(
					KML.IconStyle(
						KML.scale(1.1),
						KML.Icon(
							KML.href("http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png"),
						),
						KML.hotSpot(x="20",y="2",xunits="pixels",yunits="pixels"),
					),
					KML.LineStyle(
						KML.color(line_colour),
						KML.width(line_width),
					),
					KML.PolyStyle(
						KML.color(poly_colour),
					),
					KML.BalloonStyle(
						KML.text(balloon_text),
					), 
					id=id_name,
				)
				
	#print "out_style: " + str(out_style)
	
	return out_style
开发者ID:kballant,项目名称:My_Scripts,代码行数:76,代码来源:kml_editor.py


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