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


Python KML_ElementMaker.innerBoundaryIs方法代码示例

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


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

示例1: test_to_wkt_list_complex_polygon

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import innerBoundaryIs [as 别名]
 def test_to_wkt_list_complex_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 '
             ),
           ),
         ),
         KML.innerBoundaryIs(
           KML.LinearRing(
             KML.coordinates(
             '-122.366212,37.818977,30 '
             '-122.365424,37.819294,30 '
             '-122.365704,37.819731,30 '
             '-122.366212,37.818977,30 '
             ),
           ),
         ),
         KML.innerBoundaryIs(
           KML.LinearRing(
             KML.coordinates(
             '-122.366212,37.818977,30 '
             '-122.365704,37.819731,30 '
             '-122.366488,37.819402,30 '
             '-122.366212,37.818977,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), '
                   '(-122.366212 37.818977 30, '
                    '-122.365424 37.819294 30, '
                    '-122.365704 37.819731 30, '
                    '-122.366212 37.818977 30), '
                   '(-122.366212 37.818977 30, '
                    '-122.365704 37.819731 30, '
                    '-122.366488 37.819402 30, '
                    '-122.366212 37.818977 30))')
     )
开发者ID:123abcde,项目名称:pykml,代码行数:62,代码来源:test_util.py

示例2: to_kml

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import innerBoundaryIs [as 别名]
    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,代码行数:30,代码来源:polygon.py

示例3: ConvertShapeToPlacemark

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

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import innerBoundaryIs [as 别名]
                KML.Polygon(
                    KML.extrude(1),
                    KML.altitudeMode("clampToGround"),
                    KML.outerBoundaryIs(KML.LinearRing(KML.coordinates(" ".join(exteriorCoords)))),
                )
            ),
        )

        if zone.interiors:
            for i in range(0, len(zone.interiors)):
                coords = zone.interiors[i].coords
                interiorCoords = []
                for c in coords:
                    interiorCoords.append("%s,%s,0" % (c[0], c[1]))
                pm.MultiGeometry.Polygon.append(
                    KML.innerBoundaryIs(KML.LinearRing(KML.coordinates(" ".join(interiorCoords))))
                )

    elif len(zones[name]) > 1:
        print "Exporting multigeometry for %s" % name
        pm = KML.Placemark(KML.name(name), KML.styleUrl("#stl"), KML.MultiGeometry())

        for zone in zones[name]:
            coords = zone.exterior.coords
            exteriorCoords = []
            for c in coords:
                exteriorCoords.append("%s,%s,0" % (c[0], c[1]))
            p = KML.Polygon(
                KML.extrude(1),
                KML.altitudeMode("clampToGround"),
                KML.outerBoundaryIs(KML.LinearRing(KML.coordinates(" ".join(exteriorCoords)))),
开发者ID:Wireless-Innovation-Forum,项目名称:Spectrum-Access-System,代码行数:33,代码来源:protection_zones.py


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