• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python factory.KML_ElementMaker类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: plot_kml

def plot_kml(galaxy):
    """
    Hacky function to dump a galaxy to a kml.  Be sure pykml is installed before using.
    """
    from pykml.factory import KML_ElementMaker as KML
    from lxml import etree

    fld = KML.kml()

    for system in galaxy:
        a = KML.Placemark(
            KML.name('foo'),
            KML.Point(
                KML.coordinates('%f,%f' % (galaxy[system]["position_x"],galaxy[system]["position_y"]))
            )
        )
        fld.append(a)

        for dest in galaxy[system]['destinations']:
            a = KML.Placemark(
                KML.name("foo"),
                KML.LineString(
                    KML.coordinates(
                        "%s,%s %s,%s" % (galaxy[system]["position_x"],galaxy[system]["position_y"], galaxy[dest]["position_x"],galaxy[dest]["position_y"])
                    )
                )
            )
            fld.append(a)

    f = open("test.kml", 'wa')

    f.write(etree.tostring(fld, pretty_print=True))
    f.close()
开发者ID:gtaylor,项目名称:dott,代码行数:33,代码来源:universe_generation.py


示例2: to_kml

    def to_kml(self, round=None):
        from pykml.factory import KML_ElementMaker as KML
        poly = KML.Polygon(
            KML.tesselate("1")
        )
        outer = KML.outerBoundaryIs()
        inner = KML.innerBoundaryIs()
        has_inner = False
        for i in range(len(self.poly)):
            cnt = self.poly[i]
            coords = ''
            for p in cnt:
                coords += ','.join(map(str, p)) + ' '
            ring = KML.LinearRing(
                KML.coordinates(coords)
            )
            #hole = self.poly.isHole(i)
            #if hole == False:
            outer.append(ring)
            #else:
            #    inner.append(ring)
            #    has_inner = True

        poly.append(outer)
        if has_inner:
            poly.append(inner)

        return poly
开发者ID:Eugene-msc,项目名称:kartograph.py,代码行数:28,代码来源:polygon.py


示例3: init_kml_canvas

 def init_kml_canvas(self):
     from pykml.factory import KML_ElementMaker as KML
     kml = KML.kml(
         KML.Document(
             KML.name('kartograph map')
         )
     )
     return kml
开发者ID:Eugene-msc,项目名称:kartograph.py,代码行数:8,代码来源:kartograph.py


示例4: build_test_kml

def build_test_kml():
    """build a simple KML file with a simple LineString, for testing purposes"""

    from pykml.factory import KML_ElementMaker as KML
    from pykml.factory import GX_ElementMaker as GX
    from lxml import etree
    from django.http import HttpResponse

    kml = KML.kml(
        KML.Placemark(
            KML.name("build_test_kml output"),
            KML.LookAt(
                KML.longitude(146.806),
                KML.latitude(12.219),
                KML.heading(-60),
                KML.tilt(70),
                KML.range(6300),
                GX.altitudeMode("relativeToSeaFloor"),
            ),
            KML.LineString(
                KML.extrude(1),
                GX.altitudeMode("relativeToSeaFloor"),
                KML.coordinates(
                    "146.825,12.233,400 "
                    "146.820,12.222,400 "
                    "146.812,12.212,400 "
                    "146.796,12.209,400 "
                    "146.788,12.205,400"
                ),
            ),
        )
    )
    kml_str = etree.tostring(kml)
    return HttpResponse(kml_str, content_type="application/vnd.google-earth.kml")
开发者ID:pombredanne,项目名称:lizard-kml,代码行数:34,代码来源:kml.py


示例5: get_kml_doc

def get_kml_doc(llhs):
  """Generates a KML document from a Pandas table of single point
  solutions. Requires columns lat, lon, and height.

  """
  from pykml.parser import Schema
  from pykml.factory import KML_ElementMaker as KML
  from pykml.factory import GX_ElementMaker as GX
  center = llhs[['lat', 'lon', 'height']].mean()
  elts = lambda e: '%s,%s,%d' % (e['lon'], e['lat'], e['height'])
  coords = ' '.join(llhs.apply(elts, axis=1).values)
  xml_coords = KML.coordinates(coords)
  doc = KML.kml(
          KML.Placemark(
            KML.name("gx:altitudeMode Example"),
            KML.LookAt(
              KML.longitude(center.lon),
              KML.latitude(center.lat),
              KML.heading(center.height),
              KML.tilt(70),
              KML.range(6300),
              GX.altitudeMode("relativeToSeaFloor"),),
            KML.LineString(
              KML.extrude(1),
              GX.altitudeMode("relativeToSeaFloor"),
              xml_coords
            )
          )
        )
  return doc
开发者ID:imh,项目名称:gnss-analysis,代码行数:30,代码来源:build_map.py


示例6: execute

    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,代码行数:54,代码来源:commands.py


示例7: create_reference_point_element

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,代码行数:27,代码来源:save_kmz_timeseries.py


示例8: to_placemark

        def to_placemark(t):
            if t.route is None:
                return None

            geometries = []
            for ls in t.route:
                g = []
                for lon, lat in ls:
                    g.append('{},{}'.format(lon, lat))
                coordinates = ' '.join(g)

                geometry = KML.LineString(
                    KML.coordinates(coordinates))
                geometries.append(geometry)

            name = t.number
            if t.company is not None:
                name = '{} {}'.format(t.company, t.number)

            href = 'https://angkot.web.id/route/#/{}/'.format(t.id)
            return KML.Placemark(
                        KML.name(name),
                        ATOM.link(href=href),
                        ATOM.updated(t.updated.isoformat()),
                        KML.MultiGeometry(*geometries))
开发者ID:angkot,项目名称:angkot,代码行数:25,代码来源:export_kml.py


示例9: createKMLFromContainer

def createKMLFromContainer(data, filename):
    iconColors = ["ff0000ff", "ff00ff00", "ffff0000", "ff00ffff", "ffff00ff", "ffffff00"]
    doc = KML.Document()
    for i, color in enumerate(iconColors):
        doc.append(
            KML.Style(
                KML.IconStyle(
                    KML.color(color),
                ),
                id="report-style-" + str(i)
            )
        )
    doc.append(KML.Folder("all"))
    colorIndex = 0
    for tIndex, task in enumerate(data):
        print task
        for hIndex, house in enumerate(task.info["houses"]):
            pm = KML.Placemark(
                KML.styleUrl("#report-style-" + str(colorIndex % len(iconColors))),
                KML.name(str(tIndex) + "-" + str(hIndex)),
                KML.Point(
                    KML.coordinates("{0},{1}".format(house["geometry"]["coordinates"][0],
                                                     house["geometry"]["coordinates"][1]))
                )
            )

            doc.Folder.append(pm)
        colorIndex += 1
    out = open(filename, "wb")
    out.write(etree.tostring(doc, pretty_print=True))
    out.close()
开发者ID:teleyinex,项目名称:app-rural-geolocator,代码行数:31,代码来源:createHouseKML.py


示例10: create_network_link_element

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,代码行数:25,代码来源:save_kmz_timeseries.py


示例11: setToKMLPolygon

def setToKMLPolygon (inputSet, isMultiGeometry):
    """initializes container list for Polygon Coordinates"""
    PolygonCoords = [] 

    """Adds input coordinates to container list"""
    for eachCoord in inputSet:
        PolygonCoords.append(CoordinateToString(eachCoord, isMultiGeometry))

    """initializes string which contains polygon coordinates """
    PolygonCoordinatesString = ''

    for PolygonCoord in PolygonCoords:
        PolygonCoordinatesString = PolygonCoordinatesString + str(PolygonCoord)
    
    """Creates the KML polygon object"""
    KMLPolygon = KML.Polygon(
        KML.outerBoundaryIs(
            KML.LinearRing(
                KML.coordinates(
                    PolygonCoordinatesString
                )
            )
        )
    )
    return KMLPolygon
开发者ID:droberts01,项目名称:Hyperloop,代码行数:25,代码来源:CreatePolygonalRegion.py


示例12: test_to_wkt_list_simple_polygon

 def test_to_wkt_list_simple_polygon(self):
     """Tests the to_wkt_list function for a polygon with inner rings."""
     from pykml.util import to_wkt_list
     
     # create a polygon
     poly = KML.Polygon(
         KML.extrude('1'),
         KML.altitudeMode('relativeToGround'),
         KML.outerBoundaryIs(
           KML.LinearRing(
             KML.coordinates(
             '-122.366278,37.818844,30 '
             '-122.365248,37.819267,30 '
             '-122.365640,37.819861,30 '
             '-122.366669,37.819429,30 '
             '-122.366278,37.818844,30 '
             ),
           ),
         ),
       )
     
     poly_wkt_list = to_wkt_list(poly)
     
     self.assertEqual(len(poly_wkt_list), 1)
     self.assertEqual(
         poly_wkt_list[0], 
         ('POLYGON ((-122.366278 37.818844 30, '
                    '-122.365248 37.819267 30, '
                    '-122.365640 37.819861 30, '
                    '-122.366669 37.819429 30, '
                    '-122.366278 37.818844 30))')
     )
开发者ID:123abcde,项目名称:pykml,代码行数:32,代码来源:test_util.py


示例13: debugging

def debugging(latitude, longitude) :
    global initLat, initLon, me, ne, lat, lon, carryY, carryX, fld, filebool, angles
    lat=latitude
    lon=longitude
    #lat=filt(lat, a)
    #lon=filt(lon, a)
    #print lat, lon
    lat_rad = lat *math.pi/180.0
    lon_rad = lon *math.pi/180.0
    if(filebool == True) :
        pm = KML.Placemark(KML.name("Placemark %d" % count), KML.Point(KML.coordinates("%f,%f" % (lat, lon))))
        fld.append(pm)
        count = count + 1
    try :
        #print angles[2]
        if(initLat == 0) :
            br.sendTransform((0, 0, 0), tf.transformations.quaternion_from_euler(0, 0, carryYaw, "sxyz"), rospy.Time.now(), 'base_link', 'dummy')
            (trans, rot) = listener.lookupTransform('map', 'base_link', rospy.Time())
            angles = tf.transformations.euler_from_quaternion(rot)
            initLat = lat_rad
            initLon = lon_rad
            me = earth_radius*(1-earth_ecc*earth_ecc)/((1-earth_ecc*earth_ecc*math.sin(lat_rad)*math.sin(lat_rad))**1.5)
            ne = earth_radius/((1-earth_ecc*earth_ecc*math.sin(lat_rad)*math.sin(lat_rad))**0.5)
            br.sendTransform((0, 0, 0), tf.transformations.quaternion_from_euler(0, 0, -(carryYaw + angles[2])), rospy.Time.now(), 'map', 'world')
            #br.sendTransform((0, 0, 0), tf.transformations.quaternion_from_euler(0, 0, carryYaw), rospy.Time.now(), 'world', 'map')
        else :
            carryY=(lon_rad - initLon)*(ne+h)*math.cos(lat_rad)
            carryX=(lat_rad - initLat)*(me+h)
            print carryYaw
            #br.sendTransform((carryX -trans[0], carryY -trans[1], 0), tf.transformations.quaternion_from_euler(0, 0, carryYaw -angles[2], "sxyz"), rospy.Time.now(), 'base_link', 'world')
            br.sendTransform((-carryX, -carryY, 0), tf.transformations.quaternion_from_euler(0, 0, carryYaw, "sxyz"), rospy.Time.now(), 'base_link', 'dummy')
    except(tf.LookupException, tf.ConnectivityException, tf.ExtrapolationException) :
        print "exception"
开发者ID:Shedino,项目名称:RoverHighLevel,代码行数:33,代码来源:start.py


示例14:

 def test_basic_kml_document_2(self):
     """Tests the creation of a basic OGC KML document."""
     doc = KML.kml(
         KML.Document(
             KML.name("KmlFile"),
             KML.Placemark(
                 KML.name("Untitled Placemark"),
                 KML.Point(
                     KML.coordinates("-95.265,38.959,0")
                 )
             )
         )
     )
     self.assertTrue(Schema("kml22gx.xsd").validate(doc))
     self.assertEquals(
         etree.tostring(doc),
         '<kml xmlns:gx="http://www.google.com/kml/ext/2.2" '
              'xmlns:atom="http://www.w3.org/2005/Atom" '
              'xmlns="http://www.opengis.net/kml/2.2">'
           '<Document>'
             '<name>KmlFile</name>'
             '<Placemark>'
               '<name>Untitled Placemark</name>'
               '<Point>'
                 '<coordinates>-95.265,38.959,0</coordinates>'
               '</Point>'
             '</Placemark>'
           '</Document>'
         '</kml>'
     )
开发者ID:giricgoyal,项目名称:CS526_UIC_Fall2013,代码行数:30,代码来源:test_factory.py


示例15: generate_kml

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,代码行数:27,代码来源:cl_generate.py


示例16: update_kml

 def update_kml(self, request, response):
   change = KML.Change()
   create = KML.Create()
   delete = KML.Delete()
   doc = KML.Document(targetId=KmlPlacemark.DOC_ID)
   for id_, kpm in self.placemarks.items():
     if kpm.is_new:
       style_url = KmlStyleUtils.get_style_url_for_callsign(kpm.callsign)
       model_url = None # KmlStyleUtils.get_model_url_for_callsign(kpm.callsign, request.host_url)
       placemark = kpm.get_placemark(style_url, model_url)
       doc.append(placemark)
       kpm.is_new = False
     else:
       kpm.generate_update(change = change, create = create, delete = delete)
   if doc.countchildren() > 0:
     create.append(doc)
   update = KML.Update(KML.targetHref(request.path_url))
   if change.countchildren() > 0:
     update.append(change)
   if create.countchildren() > 0:
     update.append(create)
   if delete.countchildren() > 0:
     update.append(delete)
   network_link_control = KML.NetworkLinkControl(update)
   return KML.kml(network_link_control)
开发者ID:IoannisIn,项目名称:cellbots,代码行数:25,代码来源:earth.py


示例17: mission_route

def mission_route():
    """
    Flask route that dynamically generates a KML of the current mission
    as specified in the mission YAML.
    """
    # Retrieve origin and create a list of KML attributes
    origin = mission_planner.environment.origin
    kml_list = [KML.name("SRR Mission")]

    # Add placemarks for each mission waypoint.
    for task in mission_planner.mission:
        kml_list.append(frame_placemark(origin, task.name,
                                        task.location.x, task.location.y,
                                        marker='waypoint.png',
                                        color='ffff0000'))
        if not task.is_point:
            kml_list.append(
                bounds_placemark(origin, task.name + " bounds", task.bounds))

    # Create a KML document with this environment represented.
    doc = KML.kml(
        KML.Document(
            *kml_list
        )
    )
    return etree.tostring(doc)
开发者ID:cephalsystems,项目名称:srr,代码行数:26,代码来源:viewer.py


示例18: navigation_route

def navigation_route():
    """
    Flask route that dynamically generates a KML of the current navigation
    outputs from the navigation module.
    """
    # Retrieve origin and create a list of KML attributes
    origin = mission_planner.environment.origin
    rover_position = mission_planner.navigator.position
    rover_rotation = mission_planner.navigator.rotation
    rover_location = (rover_position, rover_rotation)
    goal = mission_planner.navigator.goal
    kml_list = [KML.name("SRR Navigation")]

    # Add placemark for rover location estimate.
    kml_list.append(frame_placemark(
        origin, "Rover", rover_position.x, rover_position.y, rover_rotation,
        marker='rover.png'))

    # Add placemark for navigation goal.
    if goal is not None:
        global_goal = srr.util.to_world(rover_location, goal)
        kml_list.append(frame_placemark(
            origin, "Goal", global_goal.x, global_goal.y,
            marker='goal.png', color='ff00ffff'))

    # Create a KML document with this environment represented.
    doc = KML.kml(
        KML.Document(
            *kml_list
        )
    )
    return etree.tostring(doc)
开发者ID:cephalsystems,项目名称:srr,代码行数:32,代码来源:viewer.py


示例19:

    def test_basic_kml_document_2(self):
        """Tests the creation of a basic OGC KML document."""
        doc = KML.kml(
            KML.Document(
                KML.name('KmlFile'),
                KML.Placemark(
                    KML.name('Untitled Placemark'),
                    KML.Point(
                        KML.coordinates('-95.265,38.959,0')
                    )
                )
            )
        )
        # validate against a local schema
        self.assertTrue(Schema('ogckml22.xsd').validate(doc))
        # validate against a remote schema
        self.assertTrue(Schema('http://schemas.opengis.net/kml/2.2.0/ogckml22.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'<Document>' \
            b'<name>KmlFile</name>' \
            b'<Placemark>' \
            b'<name>Untitled Placemark</name>' \
            b'<Point>' \
            b'<coordinates>-95.265,38.959,0</coordinates>' \
            b'</Point>' \
            b'</Placemark>' \
            b'</Document>' \
            b'</kml>'

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


示例20: TranslateShpFileToKML

def TranslateShpFileToKML(file):
  print 'Translating file %s' % file
  basename = os.path.splitext(os.path.basename(file))[0]
  doc = KML.kml(
    KML.Document(
      KML.name('US Census Tracts ' + basename),
      KML.Style(
        KML.LineStyle(
          KML.color('ff00ff00'),
          KML.width(2)
        ),
        KML.PolyStyle(
          KML.color('66006600')
        ),
        id="ts"
      )
    )
  )
  ProcessShpFile(file, basename, doc)

  kmlFilename = os.path.join(os.path.dirname(file), basename + '.kml')
  print 'Writing output file %s' % kmlFilename
  outputFile = open(kmlFilename, 'w+')
  outputFile.write(etree.tostring(doc, pretty_print=True))
  outputFile.close()
开发者ID:Wireless-Innovation-Forum,项目名称:Spectrum-Access-System,代码行数:25,代码来源:census_tracts_kml.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python parser.fromstring函数代码示例发布时间:2022-05-25
下一篇:
Python registry.ActorRegistry类代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap