Support more region utils, such as convex hull
This commit is contained in:
@@ -5564,6 +5564,47 @@ class TestApi:
|
||||
self.leave(p)
|
||||
|
||||
|
||||
# 32 region_util
|
||||
|
||||
|
||||
def test_get_nodes_in_boundary(self):
|
||||
p = 'test_get_nodes_in_boundary'
|
||||
read_inp(p, f'./inp/net3.inp', '3')
|
||||
open_project(p)
|
||||
|
||||
vds = calculate_virtual_district(p, ['107', '139', '267', '211'])['virtual_districts']
|
||||
nodes = get_nodes_in_boundary(p, vds[0]['boundary'])
|
||||
assert nodes == ['10', '101', '103', '105', '107', '109', '111', '113', '115', '117', '119', '120', '121', '125', '139', '149', '151', '153', '157', '159', '161', '191', '193', '195', '197', '257', '259', '261', '263', '267', 'Lake']
|
||||
|
||||
self.leave(p)
|
||||
|
||||
|
||||
def test_get_nodes_in_region(self):
|
||||
p = 'test_get_nodes_in_region'
|
||||
read_inp(p, f'./inp/net3.inp', '3')
|
||||
open_project(p)
|
||||
|
||||
vds = calculate_virtual_district(p, ['107', '139', '267', '211'])['virtual_districts']
|
||||
add_region(p, ChangeSet({'id': 'r', 'boundary': vds[0]['boundary']}))
|
||||
|
||||
nodes = get_nodes_in_region(p, 'r')
|
||||
assert nodes == ['10', '101', '103', '105', '107', '109', '111', '113', '115', '117', '119', '120', '121', '125', '139', '149', '151', '153', '157', '159', '161', '191', '193', '195', '197', '257', '259', '261', '263', '267', 'Lake']
|
||||
|
||||
self.leave(p)
|
||||
|
||||
|
||||
def test_calculate_convex_hull(self):
|
||||
p = 'test_calculate_convex_hull'
|
||||
read_inp(p, f'./inp/net3.inp', '3')
|
||||
open_project(p)
|
||||
|
||||
nodes = ['10', '101', '103', '105', '109', '111', '115', '117', '119', '120', '139', '257', '259', '261', '263', '267', 'Lake']
|
||||
ch = calculate_convex_hull(p, nodes)
|
||||
assert ch == [(23.38, 12.95), (12.96, 21.31), (8.0, 27.53), (9.0, 27.85), (33.28, 24.54), (23.38, 12.95)]
|
||||
|
||||
self.leave(p)
|
||||
|
||||
|
||||
# 33 region
|
||||
|
||||
|
||||
@@ -5652,7 +5693,6 @@ class TestApi:
|
||||
def test_virtual_district(self):
|
||||
p = 'test_virtual_district'
|
||||
read_inp(p, f'./inp/net3.inp', '3')
|
||||
|
||||
open_project(p)
|
||||
|
||||
result = calculate_virtual_district(p, ['107', '139', '267', '211'])
|
||||
|
||||
Reference in New Issue
Block a user