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


Python KML_ElementMaker.href方法代码示例

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


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

示例1: kmlpush

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import href [as 别名]
def kmlpush(pt,label,stylename="sn_shaded_dot"):
	global kmloutput,outkml
	from pykml.factory import KML_ElementMaker as KML
	if kmloutput is None:
		kmloutput = KML.kml(
		    KML.Document(
		        KML.Name("Sun Position"),
		        KML.Style(
			      KML.IconStyle(
			        KML.scale(1.0),
			        KML.Icon(
			          KML.href("http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png"),
			        ),
			        id="mystyle"
			      ),
			      id="pushpin"
			    ),
		        KML.Style(
			      KML.IconStyle(
			        KML.scale(1.0),
			        KML.Icon(
			          KML.href("http://maps.google.com/mapfiles/kml/pushpin/red-pushpin.png"),
			        ),
			        id="redmystyle"
			      ),
			      id="redpushpin"
			    ),
		        KML.Style(
		            KML.IconStyle(
		                KML.scale(1.2),
		                KML.Icon(
		                    KML.href("http://maps.google.com/mapfiles/kml/shapes/shaded_dot.png")
		                ),
		            ),
		            id="sn_shaded_dot",
		        )
		    )
		)
	if pt is None:
		from lxml import etree
		open(outkml,"wb").write(etree.tostring(kmloutput, pretty_print=True))
		return
	pt = KML.Placemark(
	    KML.name(label),
	    KML.styleUrl('#{0}'.format(stylename)),
	    KML.Point(
	        KML.extrude(True),
	        KML.altitudeMode('relativeToGround'),
	        KML.coordinates("{0},{1}".format(pt.lon.value,pt.lat.value)),
	    ),
	)
	kmloutput.Document.append(pt)
开发者ID:eruffaldi,项目名称:directionpole,代码行数:54,代码来源:locpole.py

示例2: add_style

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import href [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

示例3: create_network_link_element

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import href [as 别名]
def create_network_link_element(name, kml_file, ts_obj):

    lats, lons = flatten_lalos(None, ts_obj)

    network_link = KML.NetworkLink(
        KML.name(name),
        KML.visibility(1),
        KML.Region(
            KML.Lod(
                KML.minLodPixels(0),
                KML.maxLodPixels(1800)
            ),
            KML.LatLonAltBox(
                KML.north(lats[-1] + 0.5),
                KML.south(lats[0] - 0.5),
                KML.east(lons[-1] + 0.5),
                KML.west(lons[0] - 0.5)
            )
        ),
        KML.Link(
            KML.href(kml_file),
            KML.viewRefreshMode('onRegion')
        )
    )
    return network_link
开发者ID:hfattahi,项目名称:PySAR,代码行数:27,代码来源:save_kmz_timeseries.py

示例4: create_reference_point_element

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import href [as 别名]
def create_reference_point_element(inps, lats, lons, ts_obj):

    star_file = "star.png"

    colormap = mpl.cm.get_cmap(inps.colormap)  # set colormap
    norm = mpl.colors.Normalize(vmin=inps.vlim[0], vmax=inps.vlim[1])

    ref_yx = (int(ts_obj.metadata['REF_Y']), int(ts_obj.metadata['REF_X']))
    ref_lalo = (lats[ref_yx[0], ref_yx[1]], lons[ref_yx[0], ref_yx[1]])

    reference_point = KML.Placemark(
        KML.Style(
            KML.IconStyle(
                KML.color(get_color_for_velocity(0.0, colormap, norm)),
                KML.scale(1.),
                KML.Icon(KML.href("{}".format(star_file)))
            )
        ),
        KML.description("Reference point <br /> \n <br /> \n" +
                        generate_description_string(ref_lalo, ref_yx, 0.00, 0.00, 0.00, 1.00)
                        ),
        KML.Point(
            KML.coordinates("{}, {}".format(ref_lalo[1], ref_lalo[0]))
        )
    )

    return reference_point, star_file
开发者ID:hfattahi,项目名称:PySAR,代码行数:29,代码来源:save_kmz_timeseries.py

示例5: generate_kml

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import href [as 别名]
def generate_kml(places):
	doc = KML.kml(
	    KML.Document(
	        KML.Name("Awesome places"),
	        KML.Style(
	            KML.IconStyle(
	                KML.scale(1.2),
	                KML.Icon(
	                    KML.href("http://maps.google.com/mapfiles/kml/pal4/icon28.png")
	                ),
	            )
	        )
	    )
	)

	for data in places:
		pm = KML.Placemark(
   			KML.name(data.get("name")),
   			KML.Point(KML.coordinates(str(data.get("lng")) + "," + str(data.get("lat"))))
  		)
  		doc.Document.append(pm)

	result = etree.tostring(doc, pretty_print=True)
	result.replace("placemark", "Placemark")
	result.replace("point", "Point")

	return result
开发者ID:KevinBrown,项目名称:GoogleEarthVisualizations,代码行数:29,代码来源:cl_generate.py

示例6: test_basic_kml_document

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import href [as 别名]
    def test_basic_kml_document(self):
        """Tests the creation of a basic KML with Google Extensions ."""
        doc = KML.kml(
            GX.Tour(
                GX.Playlist(
                    GX.SoundCue(
                        KML.href('http://dev.keyhole.com/codesite/cntowerfacts.mp3')
                    ),
                    GX.Wait(
                        GX.duration(10)
                    ),
                    GX.FlyTo(
                        GX.duration(5),
                        GX.flyToMode('bounce'),
                        KML.LookAt(
                            KML.longitude(-79.387),
                            KML.latitude(43.643),
                            KML.altitude(0),
                            KML.heading(-172.3),
                            KML.tilt(10),
                            KML.range(1200),
                            KML.altitudeMode('relativeToGround'),
                        )
                    )
                )
            )
        )
        self.assertTrue(Schema('kml22gx.xsd').validate(doc))

        data = etree.tostring(doc, encoding='ascii')
        expected = \
            b'<kml xmlns:gx="http://www.google.com/kml/ext/2.2" ' \
            b'xmlns:atom="http://www.w3.org/2005/Atom" ' \
            b'xmlns="http://www.opengis.net/kml/2.2">' \
            b'<gx:Tour>' \
            b'<gx:Playlist>' \
            b'<gx:SoundCue>' \
            b'<href>http://dev.keyhole.com/codesite/cntowerfacts.mp3</href>' \
            b'</gx:SoundCue>' \
            b'<gx:Wait>' \
            b'<gx:duration>10</gx:duration>' \
            b'</gx:Wait>' \
            b'<gx:FlyTo>' \
            b'<gx:duration>5</gx:duration>' \
            b'<gx:flyToMode>bounce</gx:flyToMode>' \
            b'<LookAt>' \
            b'<longitude>-79.387</longitude>' \
            b'<latitude>43.643</latitude>' \
            b'<altitude>0</altitude>' \
            b'<heading>-172.3</heading>' \
            b'<tilt>10</tilt>' \
            b'<range>1200</range>' \
            b'<altitudeMode>relativeToGround</altitudeMode>' \
            b'</LookAt>' \
            b'</gx:FlyTo>' \
            b'</gx:Playlist>' \
            b'</gx:Tour>' \
            b'</kml>'

        self.assertXmlEquivalentOutputs(data, expected)
开发者ID:recombinant,项目名称:pykml,代码行数:62,代码来源:test_factory.py

示例7: initDocument

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import href [as 别名]
def initDocument():
	doc = KML.kml(
		KML.Document(
			KML.Name("Sun Position"),
			KML.Style(
				KML.IconStyle(
					KML.scale(1.2),
					KML.Icon(
						KML.href("http://maps.google.com/mapfiles/kml/shapes/shaded_dot.png")
					),
				),
				id="truc"
			),
			KML.Style(
				KML.LineStyle(
					KML.color("ff0000ff"),
					KML.width(1)
				),
				KML.PolyStyle(
					KML.color("ffff0000")
				),
				id="redLineBluePoly"
			)
		)
	)
	return doc
开发者ID:will421,项目名称:PROJET_VM,代码行数:28,代码来源:kmlwriter.py

示例8: generateKML

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import href [as 别名]
def generateKML(ids, spotList):
    km = KML.kml()
    doc = KML.Document(KML.name("Aires camping car info"))
    icones = glob.glob(LOGOS_FOLDER+"A*")
    for icone in icones:
        icone = icone.replace(DESC_FOLDER, "")
        type = os.path.basename(icone).replace("40.gif", "")
        style = KML.Style(
          KML.IconStyle(
            KML.scale(1.0),
            KML.Icon(
              KML.href(icone),
            ),
          ),
          id=type.lower()
        )
        doc.append(style)
    for id in ids:
        idStr = str(id)
        with codecs.open(DESC_FOLDER+"/"+idStr+".html",'r',encoding='utf-8') as f:
            place = KML.Placemark(
                    KML.name(spotList[id]["name"]),
                    KML.description(f.read()),
                    KML.styleUrl("#"+spotList[id]["type"].lower()),
                    KML.Point(
                        KML.coordinates(spotList[id]["lat"]+","+spotList[id]["long"])
                        )
                    )
            doc.append(place)
    km.append(doc)
    print(etree.tostring(km))
开发者ID:nleleu,项目名称:ccinfo,代码行数:33,代码来源:ccinfo.py

示例9: create_kml_from_waypoint

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import href [as 别名]
def create_kml_from_waypoint(waypoint):
    coordinates = "%s,%s" % (waypoint.long, waypoint.lat)
    doc = KML.kml(
        KML.Document(
            KML.Placemark(
                KML.name(waypoint.name),
                KML.description(waypoint.description if waypoint.description else ""),
                KML.Style(
                    KML.IconStyle(
                        KML.color("ffffffff"),
                        KML.scale(1.0),
                        KML.Icon(
                            KML.href("http://maps.google.com/mapfiles/kml/shapes/placemark_circle.png")
                        ),
                    ),
                    KML.LabelStyle(
                        KML.scale(0.0)
                    )
                ),
                KML.Point(
                    KML.coordinates(coordinates)
                )
            )
        )
    )
    return doc
开发者ID:lbosson,项目名称:geoblogger,代码行数:28,代码来源:kml_helpers.py

示例10: kml

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import href [as 别名]
def kml(locations):
    """KML file for the locations
    """
    # create document
    document = KML.kml(KML.Document(KML.name("Layer example")))
    # bullets
    for layer_code,layer_name in categories(locations):
        style = KML.Style(
            KML.IconStyle(
                KML.scale(1.0),
                KML.Icon(
                    KML.href('%slocations/%s.png' % (settings.MEDIA_URL, layer_code)),
                ),
                id='icon-%s' % layer_code
            ),
            id=layer_code
        )
        document.append(style)
    # locations
    folder = KML.Folder()
    for location in locations:
        placemark = KML.Placemark(
            KML.name(location['title']),
            KML.description('<![CDATA[ %s ]]>' % location['description']),
            KML.styleUrl('#%s' % location['category']),
            KML.Point(
                KML.coordinates(','.join([location['lng'],location['lat']]))
                ),
            )
        folder.append(placemark)
    document.append(folder)
    # rettsugo!
    return etree.tostring(document)
开发者ID:,项目名称:,代码行数:35,代码来源:

示例11: get_network_link

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import href [as 别名]
 def get_network_link(self, path, refresh = 1):
   return \
     KML.NetworkLink(
       KML.Link(
         KML.href(path),
         KML.refreshMode('onInterval'),
         KML.refreshInterval(str(refresh)),
       ),
     )
开发者ID:IoannisIn,项目名称:cellbots,代码行数:11,代码来源:earth.py

示例12: make_netlink

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import href [as 别名]
def make_netlink(url, region, name=None):
    netlink = KML.NetworkLink()
    if name:
        netlink.name = KML.name(name)
    if region:
        netlink.Region = region.kml_region()
    netlink.Link = KML.Link(KML.href(url), KML.viewRefreshMode("onRegion"))

    assert_valid(netlink)
    return netlink
开发者ID:pathintegral,项目名称:visionworkbench,代码行数:12,代码来源:plate2kml.py

示例13: __init__

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import href [as 别名]
    def __init__(self, poseTopicName, utmZoneNumber):
        rospy.loginfo("[KMLTourGenerator] init()")
        self.prevLinVel = 0.0
        self.prevAngVel = 0.0

        self.hasFinished = False

        self.hasOdom = False
        self.currOdom = None
        self.prevOdom = None
        self.subPose = rospy.Subscriber(poseTopicName, Odometry, self.poseHandler)

        self.utmZoneNumber = utmZoneNumber
        self.utmZoneLetter = 'U'
        self.zOffset = 2.0

        self.planCoordListStr = ''
        self.execCoordListStr = ''
        
        self.totalTime = 0.0
        
        # define a variable for the Google Extensions namespace URL string
        self.gxns = '{' + nsmap['gx'] + '}'

        # start with a base KML tour and playlist

        self.anim_fld = KML.Folder(
                    KML.name('Animations'),
                    id='animations',
                )
        
        self.path_fld = KML.Folder(
                    KML.name('Paths'),
                    id='paths',
                )

        self.tour_doc = KML.kml(
            KML.Document(
                KML.Style(
                    KML.IconStyle(
                        KML.scale(1.2),
                        KML.Icon(
                            KML.href("http://maps.google.com/mapfiles/kml/shapes/shaded_dot.png")
                        ),
                    ),
                    id='sn_shaded_dot',
                ),
                GX.Tour(
                    KML.name("Play me!"),
                    GX.Playlist(),
                ),
                self.anim_fld,
                self.path_fld
            )
        )
开发者ID:silviomaeta,项目名称:kml_util,代码行数:57,代码来源:generate_kml.py

示例14: create_style

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import href [as 别名]
 def create_style(id_, color, width, scale, icon):
   style = KML.Style(id=id_)
   if scale is not None:
     icon_style = KML.IconStyle(KML.scale(scale))
     if icon is not None:
       icon_style.append(KML.Icon(KML.href(icon)))
     style.append(icon_style)
   if (color is not None) and (width is not None):
     line_style = KML.LineStyle(KML.color(color), KML.width(width))
     style.append(line_style)
   return KmlStyle(id_, [style])
开发者ID:IoannisIn,项目名称:cellbots,代码行数:13,代码来源:earth.py

示例15: execute

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import href [as 别名]
    def execute(self):
        """
        Execute the command.
        """

        def __kml_table(data):
            """
            Helper method for creating the table of network data
            for the kml file.
            @param data: The parsed network data
            @type data: dict
            @return: Formatted kml table representation of the data.
            @rtype: string
            """
            kml_text = " <div style='height:400px;width:500px;overflow:auto'>\n   <table width='500'>\n"

            for key, value in data.items():
                kml_text += "       <tr><td>{0}</td><td>{1}</td></tr>\n".format(key, value)

            kml_text += "    </table>\n </div>\n"

            return kml_text

        networks = self.__network_service.list_models(source_file=self.__source_file)
        if len(networks) > 0:
            placemarks = []
            for network in networks:
                name = network.essid
                encryption = network.encryption
                href = "http://maps.google.com/mapfiles/kml/paddle/grn-stars.png"
                if not str(encryption).__contains__('WPA'):
                    href = "http://maps.google.com/mapfiles/kml/paddle/red-stars.png"

                pm = KML_ElementMaker.Placemark(
                    KML_ElementMaker.name(name),
                    KML_ElementMaker.description(__kml_table(network.as_dict())),
                    KML_ElementMaker.Style(
                        KML_ElementMaker.IconStyle(
                            KML_ElementMaker.Icon(
                                KML_ElementMaker.href(href)
                            ),
                        ),
                    ),
                    KML_ElementMaker.Point(
                        KML_ElementMaker.coordinates("{0},{1}".format(network.longitude, network.latitude))
                    )
                )
                placemarks.append(pm)

            fold = KML_ElementMaker.Folder()
            for placemark in placemarks:
                fold.append(placemark)

            self.__ofile.write(etree.tostring(fold, pretty_print=True))
开发者ID:maine-cyber,项目名称:kraken,代码行数:56,代码来源:commands.py


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