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


Python KML_ElementMaker.displayName方法代码示例

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


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

示例1: test_getXmlWithCDATA

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import displayName [as 别名]
 def test_getXmlWithCDATA(self):
     '''tests the format_as_cdata function'''
     from pykml.util import format_xml_with_cdata
     
     kmlobj = KML.kml(
         KML.Document(
             KML.Placemark(
                 KML.name('foobar'),
                 KML.styleUrl('#big_label'),
                 KML.description('<html>'),
                 KML.text('<html>'),
                 KML.linkDescription('<html>'),
                 KML.displayName('<html>')
             )
         )
     )
     self.assertEqual(
         etree.tostring(format_xml_with_cdata(kmlobj)),
         '<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>'
             '<Placemark>'
               '<name>foobar</name>'
               '<styleUrl>#big_label</styleUrl>'
               '<description><![CDATA[<html>]]></description>'
               '<text><![CDATA[<html>]]></text>'
               '<linkDescription><![CDATA[<html>]]></linkDescription>'
               '<displayName><![CDATA[<html>]]></displayName>'
             '</Placemark>'
           '</Document>'
         '</kml>'
     )
开发者ID:123abcde,项目名称:pykml,代码行数:35,代码来源:test_util.py

示例2: test_getXmlWithCDATA

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import displayName [as 别名]
    def test_getXmlWithCDATA(self):
        """tests the format_as_cdata function"""
        from pykml.util import format_xml_with_cdata

        kml_obj = KML.kml(
            KML.Document(
                KML.Placemark(
                    KML.name('foobar'),
                    KML.styleUrl('#big_label'),
                    KML.description('<html>'),
                    KML.text('<html>'),
                    KML.linkDescription('<html>'),
                    KML.displayName('<html>')
                )
            )
        )

        root = format_xml_with_cdata(kml_obj)

        data = etree.tostring(root, encoding='utf-8', xml_declaration=True)
        expected = \
            '<?xml version="1.0" encoding="UTF-8"?>' \
            '<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>' \
            '<Placemark>' \
            '<name>foobar</name>' \
            '<styleUrl>#big_label</styleUrl>' \
            '<description><![CDATA[<html>]]></description>' \
            '<text><![CDATA[<html>]]></text>' \
            '<linkDescription><![CDATA[<html>]]></linkDescription>' \
            '<displayName><![CDATA[<html>]]></displayName>' \
            '</Placemark>' \
            '</Document>' \
            '</kml>'
        expected = expected.encode('utf-8')

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

示例3: ConvertShapeToPlacemark

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import displayName [as 别名]
def ConvertShapeToPlacemark(shape, geoid, aland, awater, kml):
  #if len(shape.parts) > 1:
  #  print '----------geoid=%s aland=%s awater=%s' % (geoid, aland, awater)
  if shape.shapeType != 5:
    raise Exception('Unexpected shape type [%d] in file' % shape.shapeType)

  pm = KML.Placemark(
    KML.name('%s' % geoid),
    KML.styleUrl('#ts'),
    KML.ExtendedData(
      KML.Data(
        KML.displayName('ALAND'),
        KML.value(aland),
        name='string'
      ),
      KML.Data(
        KML.displayName('AWATER'),
        KML.value(awater),
        name='string'
      )
    ),
    KML.MultiGeometry(
      KML.Polygon(
        KML.extrude(0),
        KML.altitudeMode('clampToGround')
      )
    )
  )

  # The parentPoly will be used to append rings, and a
  # new Polygon will be appended for multiple rings in
  # a geography.
  parentPoly = pm.MultiGeometry.Polygon

  #if len(shape.parts) > 1:
  #  print 'shape has %d parts' % len(shape.parts)
  for i in range(0, len(shape.parts)):
    lo = shape.parts[i]
    hi = len(shape.points)
    if i < len(shape.parts) - 1:
      hi = shape.parts[i + 1]
    #if len(shape.parts) > 1:
    #  print 'shape has points in [%d, %d) of %d' % (lo, hi, len(shape.points))
    if (shape.points[lo][0] != shape.points[hi-1][0] or
        shape.points[lo][1] != shape.points[hi-1][1]):
      raise Exception('Loop endpoints in [%d, %d) do not match' % (lo, hi))
    coords = []
    for j in reversed(range(lo, hi)):
      lng = shape.points[j][0]
      lat = shape.points[j][1]
      coords.append([lng, lat])

    latlngCoords = []
    for c in coords:
      latlngCoords.append('%f,%f,0' % (c[0], c[1]))
    coordinates = ' '.join(latlngCoords)

    # Note: need LinearRing to compute ccw. Need Polygon to compute contains().
    spoly = SPolygon(coords)
    if i == 0:
      parentSpoly = spoly
    ring = polygon.LinearRing(coords)

    # Some sanity checks to make sure all rings are closed, non-empty,
    # and valid.
    if not ring.is_ring:
      raise Exception('Badly formatted non-ring : %s' % geoid)
    if ring.is_empty:
      raise Exception('Empty geometry found: %s' % geoid)
    if not ring.is_valid:
      raise Exception('Invalid ring: %s' % geoid)

    if not ring.is_ccw:
      # This ring is an internal (enclave) ring.
      rring = copy.deepcopy(ring)
      rring.coords = list(rring.coords)[::-1]
      # Shapely contains does not handle point-overlaps. This
      # means that enclaves which touch the containing ring
      # are not handled correctly. To cure this, we check two
      # points.
      if not (parentSpoly.contains(SPoint(rring.coords[0])) or
              parentSpoly.contains(SPoint(rring.coords[1]))):
        print 'Out-of-order enclave'
        # print 'ring %s does not contain %s' % (parentSpoly, ring)
        # print ring
        # print rring
        # Note: if this triggers, we will need to store the polys
        # to figure out which one is the enclosing one. Hopefully
        # the census files will not exhibit this, although it is
        # legal strictly according to the shapefule spec.
        raise Exception('Out-of-order enclave')
        coordinates = coordinates + ' 0,0,0'
        parentPoly.append(KML.innerBoundaryIs(
          KML.LinearRing(
            KML.coordinates(coordinates)
          )
        ))
      else:
        # Find the containing poly...
        parentPoly.append(KML.innerBoundaryIs(
#.........这里部分代码省略.........
开发者ID:Wireless-Innovation-Forum,项目名称:Spectrum-Access-System,代码行数:103,代码来源:census_tracts_kml.py

示例4: main

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import displayName [as 别名]

#.........这里部分代码省略.........
        for when in times:
            track.append(KML.when(when))
        for coord in coords:
            track.append(KML.coordinates(coord))
            
        '''
        doc.append(KML.Placemark(
            KML.LookAt(
                KML.longitude(plon),
                KML.latitude(plat),
                KML.tilt(45),
                KML.heading(0),  # make this behind the guy
                KML.altitudeMode("relativeToGround"),
                KML.range(50),
                ),
            KML.Point(
                KML.altitudeMode("relativeToGround"),
                ,
                ,
                )
            ))
        '''
        
    elif options.points:
        #for coord in coords:
        #    ls.append(KML.coordinates(coord))
        lasttime = t.asc2epoch(times[0])
        totdist = 0
        for i in range(len(times)):
            thistime = t.asc2epoch(times[i])
            dur = thistime - lasttime
            lasttime = thistime
            totdist += dists[i]
            ex = KML.ExtendedData(
                KML.Data(KML.displayName('time'),KML.value(times[i])),
                KML.Data(KML.displayName('duration'),KML.value(dur)),
                KML.Data(KML.displayName('totdistance'),KML.value(int(round(totdist)))),
                )
            plm = KML.Placemark(
                #KML.name(times[i]),
                KML.name(''),
                KML.styleUrl(iconstylename),
                )
            plm.append(ex)
            plm.append(KML.Point(
                KML.altitudeMode('clampToGround'),
                KML.coordinates(coords[i])))
            doc.append(plm)
    
    else:
        if options.color:
            doc.append(
                KML.Style(
                    KML.LineStyle(
                    KML.color(colors[options.color]),
                    KML.width(5),
                    ),
                id=options.color))
            stylename = '#{0}'.format(options.color)
        
        '''
        <LineString id="ID">
          <!-- specific to LineString -->
          <gx:altitudeOffset>0</gx:altitudeOffset>  <!-- double -->
          <extrude>0</extrude>                      <!-- boolean -->
          <tessellate>0</tessellate>                <!-- boolean -->
          <altitudeMode>clampToGround</altitudeMode> 
              <!-- kml:altitudeModeEnum: clampToGround, relativeToGround, or absolute -->
              <!-- or, substitute gx:altitudeMode: clampToSeaFloor, relativeToSeaFloor -->
          <gx:drawOrder>0</gx:drawOrder>            <!-- integer --> 
          <coordinates>...</coordinates>            <!-- lon,lat[,alt] -->
        </LineString>
        '''
        plm = KML.Placemark(
            KML.name('runtrack'),
            )
        if options.color:
            plm.append(KML.styleUrl(stylename))
        doc.append(plm)
        ls = KML.LineString(
            KML.altitudeMode('clampToGround'),
#            KML.extrude(1),
#            KML.tessellate(1),
            )
        plm.append(ls)
        #for coord in coords:
        #    ls.append(KML.coordinates(coord))
        kcoords = ''
        for coord in coords:
            kcoords += coord + ' \n'
        ls.append(KML.coordinates(kcoords))
        
    _GPX.close()

    kml = KML.kml(doc)
    
    docstr = etree.tostring(kml, pretty_print=True)
    OUT = open(outfile,'w')
    OUT.write(docstr)
    OUT.close()
开发者ID:MikeTYang,项目名称:running,代码行数:104,代码来源:gpx2kml.py


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