本文整理汇总了Python中shapely.geometry.Polygon.almost_equals方法的典型用法代码示例。如果您正苦于以下问题:Python Polygon.almost_equals方法的具体用法?Python Polygon.almost_equals怎么用?Python Polygon.almost_equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类shapely.geometry.Polygon
的用法示例。
在下文中一共展示了Polygon.almost_equals方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_edit
# 需要导入模块: from shapely.geometry import Polygon [as 别名]
# 或者: from shapely.geometry.Polygon import almost_equals [as 别名]
def test_edit(self, dbsession, test_app, roles_test_data):
role = roles_test_data['roles'][10]
form = self.get_item(test_app, role.id).form
assert 'secretary_10' == form['name'].value
expected = Polygon([(1167544.3397631699, 5748064.729594703),
(1180453.0256760044, 6074797.96820131),
(658348.6696383564, 6080273.63626964),
(664577.4194513536, 5753148.2510447875),
(1167544.3397631699, 5748064.729594703)])
assert expected.almost_equals(shape(json.loads(form['extent'].value)))
functionalities = roles_test_data['functionalities']
assert set((
functionalities['default_basemap'][0].id,
functionalities['location'][0].id,
functionalities['location'][1].id
)) == set(f.id for f in role.functionalities)
self.check_checkboxes(
form,
'functionalities',
[{
'label': '{}={}'.format(f.name, f.value),
'value': str(f.id),
'checked': f in role.functionalities
} for f in sum([roles_test_data['functionalities'][name]
for name in ('default_basemap', 'location')],
[])])
ras = roles_test_data['restrictionareas']
assert set((ras[0].id, ras[1].id)) == set(ra.id for ra in role.restrictionareas)
self.check_checkboxes(
form,
'restrictionareas',
[{
'label': ra.name,
'value': str(ra.id),
'checked': ra in role.restrictionareas
} for ra in sorted(ras, key=lambda ra: ra.name)])
form['name'] = 'New name'
form['description'] = 'New description'
form['extent'] = json.dumps({
'type': 'Polygon',
'coordinates': [[
[1000000, 5800000],
[1000000, 6000000],
[700000, 6000000],
[700000, 5800000],
[1000000, 5800000]
]]
})
functionality_ids = [
roles_test_data['functionalities']['default_basemap'][1].id,
roles_test_data['functionalities']['location'][1].id,
roles_test_data['functionalities']['default_basemap'][2].id]
form['functionalities'] = [str(id) for id in functionality_ids]
ra_ids = [
roles_test_data['restrictionareas'][2].id,
roles_test_data['restrictionareas'][3].id]
form['restrictionareas'] = [str(id) for id in ra_ids]
resp = form.submit('submit')
assert str(role.id) == re.match('http://localhost/roles/(.*)', resp.location).group(1)
dbsession.expire(role)
assert 'New name' == role.name
assert 'New description' == role.description
expected = Polygon([(719383.7988896352, 109062.8141734005),
(716689.3301397888, 245909.7643546755),
(513083.1504351135, 245400.5416369234),
(511073.1973649057, 108541.7344432737),
(719383.7988896352, 109062.8141734005)])
assert expected.almost_equals(to_shape(role.extent))
assert set(functionality_ids) == set([f.id for f in role.functionalities])
assert set(ra_ids) == set([f.id for f in role.restrictionareas])