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

Python geometry.as_shape函数代码示例

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

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



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

示例1: testGeometryCollection

 def testGeometryCollection(self):
     self.assertRaises(TypeError,geometry.GeometryCollection)
     self.assertRaises(TypeError,geometry.GeometryCollection, None)
     p = geometry.Polygon([(0, 0), (1, 1), (1, 0), (0, 0)])
     e = [(0, 0), (0, 2), (2, 2), (2, 0), (0, 0)]
     i = [(1, 0), (0.5, 0.5), (1, 1), (1.5, 0.5), (1, 0)]
     ph = geometry.Polygon(e, [i])
     p0 = geometry.Point(0, 0)
     p1 = geometry.Point(-1, -1)
     r = geometry.LinearRing([(0, 0), (1, 1), (1, 0), (0, 0)])
     l = geometry.LineString([(0, 0), (1, 1)])
     gc = geometry.GeometryCollection([p,ph,p0,p1,r,l])
     self.assertEqual(len(list(gc.geoms)),6)
     self.assertEqual(len(gc), 6)
     self.assertEqual(gc.bounds, (-1.0, -1.0, 2.0, 2.0))
     self.assertEqual(gc.__geo_interface__,
             geometry.as_shape(gc).__geo_interface__)
     self.assertEqual(gc.__geo_interface__,
             geometry.as_shape(gc.__geo_interface__).__geo_interface__)
     f = geometry._Feature()
     gc1 = geometry.GeometryCollection([p.__geo_interface__,ph,p0,p1,r,l.__geo_interface__])
     self.assertEqual(gc.__geo_interface__,gc1.__geo_interface__)
     self.assertRaises(NotImplementedError, geometry.GeometryCollection, [p,f])
     mp1 = geometry.MultiPoint([p0, p1])
     self.assertRaises(ValueError, geometry.GeometryCollection, [p,mp1])
开发者ID:karimbahgat,项目名称:Tably,代码行数:25,代码来源:test_main.py


示例2: test_polygon

 def test_polygon(self):
     f = geometry.Polygon([(0, 0), (1, 1), (1, 0), (0, 0)])
     s = geometry.as_shape(f)
     self.assertEqual(f.__geo_interface__, s.__geo_interface__)
     e = [(0, 0), (0, 2), (2, 2), (2, 0), (0, 0)]
     i = [(1, 0), (0.5, 0.5), (1, 1), (1.5, 0.5), (1, 0)]
     f = geometry.Polygon(e, [i])
     s = geometry.as_shape(f)
     self.assertEqual(f.__geo_interface__, s.__geo_interface__)
     ext = [(0, 0), (0, 2), (2, 2), (2, 0), (0, 0)]
     int_1 = [(0.5, 0.25), (1.5, 0.25), (1.5, 1.25), (0.5, 1.25), (0.5, 0.25)]
     int_2 = [(0.5, 1.25), (1, 1.25), (1, 1.75), (0.5, 1.75), (0.5, 1.25)]
     f = geometry.Polygon(ext, [int_1, int_2])
     s = geometry.as_shape(f)
     self.assertEqual(f.__geo_interface__, s.__geo_interface__)
开发者ID:benjwadams,项目名称:pygeoif,代码行数:15,代码来源:test_main.py


示例3: test_feature

 def test_feature(self):
     self.assertRaises(TypeError, geometry.Feature)
     self.assertEqual(self.f1.__geo_interface__, geometry.as_shape(self.f1).__geo_interface__)
     self.assertEqual(
         self.f1.__geo_interface__,
         {
             "type": "Feature",
             "bbox": (0.0, 0.0, 1.0, 1.0),
             "geometry": {
                 "type": "Polygon",
                 "bbox": (0.0, 0.0, 1.0, 1.0),
                 "coordinates": (((0.0, 0.0), (0.0, 1.0), (1.0, 1.0), (1.0, 0.0), (0.0, 0.0)),),
             },
             "properties": {},
         },
     )
     self.f1.properties["coords"] = {}
     self.f1.properties["coords"]["cube"] = (0, 0, 0)
     self.assertEqual(
         self.f1.__geo_interface__,
         {
             "type": "Feature",
             "bbox": (0.0, 0.0, 1.0, 1.0),
             "geometry": {
                 "type": "Polygon",
                 "bbox": (0.0, 0.0, 1.0, 1.0),
                 "coordinates": (((0.0, 0.0), (0.0, 1.0), (1.0, 1.0), (1.0, 0.0), (0.0, 0.0)),),
             },
             "properties": {"coords": {"cube": (0, 0, 0)}},
         },
     )
     self.assertEqual(self.f1.geometry.bounds, (0.0, 0.0, 1.0, 1.0))
     del self.f1.properties["coords"]
开发者ID:benjwadams,项目名称:pygeoif,代码行数:33,代码来源:test_main.py


示例4: test_feature

 def test_feature(self):
     self.assertRaises(TypeError, geometry.Feature)
     self.assertEqual(self.f1.__geo_interface__,
                      geometry.as_shape(self.f1).__geo_interface__)
     self.assertEqual(self.f1.__geo_interface__,
                      {'type': 'Feature',
                       'bbox': (0.0, 0.0, 1.0, 1.0),
                       'geometry': {'type': 'Polygon',
                                    'bbox': (0.0, 0.0, 1.0, 1.0),
                                    'coordinates': (((0.0, 0.0), (0.0, 1.0),
                                                     (1.0, 1.0), (1.0, 0.0),
                                                     (0.0, 0.0)),),
                                    },
                       'properties': {}
                       })
     self.f1.properties['coords'] = {}
     self.f1.properties['coords']['cube'] = (0, 0, 0)
     self.assertEqual(self.f1.__geo_interface__,
                      {'type': 'Feature',
                       'bbox': (0.0, 0.0, 1.0, 1.0),
                       'geometry': {'type': 'Polygon',
                                    'bbox': (0.0, 0.0, 1.0, 1.0),
                                    'coordinates': (((0.0, 0.0), (0.0, 1.0),
                                                     (1.0, 1.0), (1.0, 0.0),
                                                     (0.0, 0.0)),),
                                    },
                       'properties': {'coords': {'cube': (0, 0, 0)}}
                       })
     self.assertEqual(self.f1.geometry.bounds, (0.0, 0.0, 1.0, 1.0))
     del self.f1.properties['coords']
开发者ID:cleder,项目名称:pygeoif,代码行数:30,代码来源:test_main.py


示例5: test_multipolygon

 def test_multipolygon(self):
     f = geometry.MultiPolygon([(((0.0, 0.0), (0.0, 1.0), (1.0, 1.0),
                                  (1.0, 0.0)), [((0.1, 0.1), (0.1, 0.2),
                                                 (0.2, 0.2), (0.2, 0.1))])
                                ])
     s = geometry.as_shape(f)
     self.assertEqual(f.__geo_interface__, s.__geo_interface__)
开发者ID:cleder,项目名称:pygeoif,代码行数:7,代码来源:test_main.py


示例6: test_featurecollection

 def test_featurecollection(self):
     self.assertRaises(TypeError, geometry.FeatureCollection)
     self.assertRaises(TypeError, geometry.FeatureCollection, None)
     self.assertEqual(len(list(self.fc.features)), 2)
     self.assertEqual(len(self.fc), 2)
     self.assertEqual(self.fc.bounds, (0.0, 0.0, 2.0, 2.0))
     self.assertEqual(self.fc.__geo_interface__, geometry.as_shape(self.fc).__geo_interface__)
     self.assertEqual([self.f1, self.f2], [feature for feature in self.fc])
开发者ID:benjwadams,项目名称:pygeoif,代码行数:8,代码来源:test_main.py


示例7: test_geometrycollection

 def test_geometrycollection(self):
     p = geometry.Point(0, 1)
     l = geometry.LineString([(0, 0), (1, 1)])
     f = geometry.GeometryCollection([p, l])
     s = geometry.as_shape(f)
     self.assertEqual(f.__geo_interface__, s.__geo_interface__)
     self.assertEqual(f.__geo_interface__["geometries"][0], p.__geo_interface__)
     self.assertEqual(f.__geo_interface__["geometries"][1], l.__geo_interface__)
开发者ID:benjwadams,项目名称:pygeoif,代码行数:8,代码来源:test_main.py


示例8: testPolygon

 def testPolygon(self):
     p = geometry.Polygon([(0, 0), (1, 1), (1, 0), (0, 0)])
     self.assertEqual(p.exterior.coords, ((0.0, 0.0), (1.0, 1.0),
                                         (1.0, 0.0), (0.0, 0.0)))
     self.assertEqual(list(p.interiors), [])
     self.assertEqual(p.__geo_interface__, {'type': 'Polygon',
                         'coordinates': (((0.0, 0.0), (1.0, 1.0),
                         (1.0, 0.0), (0.0, 0.0)),)})
     self.assertEqual(p.bounds,(0.0, 0.0, 1.0, 1.0))
     r = geometry.LinearRing([(0, 0), (1, 1), (1, 0), (0, 0)])
     p1 = geometry.Polygon(r)
     self.assertEqual(p1.exterior.coords, r.coords)
     e = [(0, 0), (0, 2), (2, 2), (2, 0), (0, 0)]
     i = [(1, 0), (0.5, 0.5), (1, 1), (1.5, 0.5), (1, 0)]
     ph1 = geometry.Polygon(e, [i])
     self.assertEqual(ph1.__geo_interface__,
         geometry.as_shape(ph1).__geo_interface__)
     self.assertEqual(ph1.exterior.coords, tuple(e))
     self.assertEqual(list(ph1.interiors)[0].coords, tuple(i))
     self.assertEqual(ph1.__geo_interface__, {'type': 'Polygon',
             'coordinates': (((0.0, 0.0), (0.0, 2.0), (2.0, 2.0),
                             (2.0, 0.0), (0.0, 0.0)),
                             ((1.0, 0.0), (0.5, 0.5),
                             (1.0, 1.0), (1.5, 0.5), (1.0, 0.0)))})
     ext = [(0, 0), (0, 2), (2, 2), (2, 0), (0, 0)]
     int_1 = [(0.5, 0.25), (1.5, 0.25), (1.5, 1.25), (0.5, 1.25), (0.5, 0.25)]
     int_2 = [(0.5, 1.25), (1, 1.25), (1, 1.75), (0.5, 1.75), (0.5, 1.25)]
     ph2 = geometry.Polygon(ext, [int_1, int_2])
     self.assertEqual(ph2.exterior.coords, tuple(ext))
     self.assertEqual(list(ph2.interiors)[0].coords, tuple(int_1))
     self.assertEqual(list(ph2.interiors)[1].coords, tuple(int_2))
     self.assertEqual(ph2.__geo_interface__, {'type': 'Polygon',
             'coordinates': (((0.0, 0.0), (0.0, 2.0), (2.0, 2.0),
                     (2.0, 0.0), (0.0, 0.0)),
                     ((0.5, 0.25), (1.5, 0.25),
                     (1.5, 1.25), (0.5, 1.25), (0.5, 0.25)),
                     ((0.5, 1.25), (1.0, 1.25), (1.0, 1.75),
                     (0.5, 1.75), (0.5, 1.25)))})
     ph3 = geometry.Polygon(ph2)
     self.assertEqual(ph2.__geo_interface__, ph3.__geo_interface__)
     # if a polygon is passed as constructor holes will be ignored
     # XXX or should holes be added to the polygon?
     ph4 = geometry.Polygon(ph2, [i])
     self.assertEqual(ph2.__geo_interface__, ph4.__geo_interface__)
     coords = ((0., 0.), (0., 1.), (1., 1.), (1., 0.), (0., 0.))
     polygon = geometry.Polygon(coords)
     ph5 = geometry.Polygon(
            (
            ((0.0, 0.0), (0.0, 1.0), (1.0, 1.0), (1.0, 0.0)),
            ((0.1, 0.1), (0.1, 0.2), (0.2, 0.2), (0.2, 0.1))
            ))
     r1 = geometry.LinearRing([(0, 0), (2, 2), (2, 0), (0, 0)])
     r2 = geometry.LinearRing([(0.5, 0.5), (1, 1), (1, 0), (0.5, 0.5)])
     p6 = geometry.Polygon(r1, [r2])
     pt = geometry.Point(0, 1)
     self.assertRaises(TypeError, geometry.Polygon, pt)
     self.assertRaises(TypeError, geometry.Polygon, 0)
     self.assertRaises(TypeError, geometry.Polygon, pt, [pt])
开发者ID:karimbahgat,项目名称:Tably,代码行数:58,代码来源:test_main.py


示例9: test_feature_with_id

 def test_feature_with_id(self):
     self.assertEqual(self.f3.id, '1')
     self.assertEqual(self.f3.__geo_interface__,
                      {'type': 'Feature',
                       'bbox': (0.0, 0.0, 1.0, 1.0),
                       'geometry': {'type': 'Polygon',
                                    'bbox': (0.0, 0.0, 1.0, 1.0),
                                    'coordinates': (((0.0, 0.0), (0.0, 1.0),
                                                     (1.0, 1.0), (1.0, 0.0),
                                                     (0.0, 0.0)),),
                                    },
                       'id': '1',
                       'properties': {}
                       })
     self.assertEqual(self.f3.__geo_interface__,
                      geometry.as_shape(self.f3).__geo_interface__)
开发者ID:cleder,项目名称:pygeoif,代码行数:16,代码来源:test_main.py


示例10: test_feature_with_id

 def test_feature_with_id(self):
     self.assertEqual(self.f3.id, "1")
     self.assertEqual(
         self.f3.__geo_interface__,
         {
             "type": "Feature",
             "bbox": (0.0, 0.0, 1.0, 1.0),
             "geometry": {
                 "type": "Polygon",
                 "bbox": (0.0, 0.0, 1.0, 1.0),
                 "coordinates": (((0.0, 0.0), (0.0, 1.0), (1.0, 1.0), (1.0, 0.0), (0.0, 0.0)),),
             },
             "id": "1",
             "properties": {},
         },
     )
     self.assertEqual(self.f3.__geo_interface__, geometry.as_shape(self.f3).__geo_interface__)
开发者ID:benjwadams,项目名称:pygeoif,代码行数:17,代码来源:test_main.py


示例11: test_dict_asshape

 def test_dict_asshape(self):
     f = geometry.MultiLineString([[[0.0, 0.0], [1.0, 2.0]]])
     s = geometry.as_shape(f.__geo_interface__)
     self.assertEqual(f.__geo_interface__, s.__geo_interface__)
开发者ID:benjwadams,项目名称:pygeoif,代码行数:4,代码来源:test_main.py


示例12: test_multilinestring

 def test_multilinestring(self):
     f = geometry.MultiLineString([[[0.0, 0.0], [1.0, 2.0]]])
     s = geometry.as_shape(f)
     self.assertEqual(f.__geo_interface__, s.__geo_interface__)
     self.assertEqual((0, 0, 1, 2), f.bounds)
开发者ID:benjwadams,项目名称:pygeoif,代码行数:5,代码来源:test_main.py


示例13: test_multipoint

 def test_multipoint(self):
     f = geometry.MultiPoint([[0.0, 0.0], [1.0, 2.0]])
     s = geometry.as_shape(f)
     self.assertEqual(f.__geo_interface__, s.__geo_interface__)
开发者ID:benjwadams,项目名称:pygeoif,代码行数:4,代码来源:test_main.py


示例14: test_linearring

 def test_linearring(self):
     f = geometry.LinearRing([(0, 0), (1, 1), (1, 0), (0, 0)])
     s = geometry.as_shape(f)
     self.assertEqual(f.__geo_interface__, s.__geo_interface__)
开发者ID:benjwadams,项目名称:pygeoif,代码行数:4,代码来源:test_main.py


示例15: test_point

 def test_point(self):
     f = geometry.Point(0, 1)
     s = geometry.as_shape(f)
     self.assertEqual(f.__geo_interface__, s.__geo_interface__)
开发者ID:benjwadams,项目名称:pygeoif,代码行数:4,代码来源:test_main.py


示例16: data_geojson

 def data_geojson(self):
     style = {}
     global_style = utils.get_feature_styles(self.context)
     style['fill'] = global_style['polygoncolor']
     style['stroke'] = global_style['linecolor']
     style['width'] = global_style['linewidth']
     if global_style.get('marker_image', None):
         img = get_marker_image(self.context, global_style['marker_image'])
         style['image'] = img
     else:
         style['image'] = None
     json_result = []
     self.pc = api.portal.get_tool('portal_catalog')
     for contact in self.get_contacts():
         brain = self.pc.unrestrictedSearchResults(UID=contact.UID())[0]
         if contact.use_parent_address:
             brain = self.pc.unrestrictedSearchResults(
                 UID=contact.aq_parent.UID())[0]
         if brain.zgeo_geometry == Missing.Value:
             continue
         if brain.collective_geo_styles == Missing.Value:
             continue
         if brain.collective_geo_styles.get('use_custom_styles', False) and \
                brain.collective_geo_styles.get('marker_image', None):
             img = get_marker_image(self.context, brain.collective_geo_styles['marker_image'])
             style['image'] = img
         geom = {'type': brain.zgeo_geometry['type'],
                 'coordinates': brain.zgeo_geometry['coordinates']}
         if geom['coordinates']:
             if geom['type']:
                 classes = geom['type'].lower() + ' '
             else:
                 classes = ''
             address = get_address(contact)
             number = ''
             if address.get('number', None):
                 number = ', {0}'.format(address['number'])
             formated_address = '{0}{1}<br />{2} {3}'.format(
                 safe_utf8(address.get('street') or ''),
                 number,
                 address.get('zip_code') or '',
                 safe_utf8(address.get('city') or '')
             )
             img = ''
             if self.context.see_logo_in_popup:
                 acc = getattr(contact, 'logo', None)
                 if acc and acc.filename:
                     img = '{0}/@@images/logo/thumb'.format(
                         contact.absolute_url()
                     )
             classes += brain.getPath().split('/')[-2].replace('.', '-')
             json_result.append(
                 geojson.Feature(
                     id=contact.id.replace('.', '-'),
                     geometry=as_shape(geom),
                     style=style,
                     properties={
                         'title': brain.Title,
                         'description': brain.Description,
                         'style': style,
                         'url': brain.getURL(),
                         'classes': classes,
                         'image': img,
                         'address': formated_address
                     }))
     feature_collection = geojson.FeatureCollection(json_result)
     feature_collection.update({'title': self.context.title})
     return geojson.dumps(feature_collection)
开发者ID:IMIO,项目名称:cpskin.core,代码行数:68,代码来源:related_contacts.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python geometry.from_wkt函数代码示例发布时间:2022-05-25
下一篇:
Python var.Var类代码示例发布时间: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