Add more api for dma
This commit is contained in:
@@ -5882,6 +5882,38 @@ class TestApi:
|
||||
self.leave(p)
|
||||
|
||||
|
||||
def test_calculate_district_metering_area_for_region(self):
|
||||
p = 'test_calculate_district_metering_area_for_region'
|
||||
read_inp(p, f'./inp/net3.inp', '3')
|
||||
open_project(p)
|
||||
|
||||
assert get_node_coord(p, '177') == { 'x' : 0.0, 'y' : 0.0 }
|
||||
|
||||
add_region(p, ChangeSet({'id': 'r', 'boundary': [(-10000.0, -10000.0), (10000.0, -10000.0), (10000.0, 10000.0), (-10000.0, 10000.0), (-10000.0, -10000.0)]}))
|
||||
|
||||
nodes = get_nodes_in_region(p, 'r')
|
||||
assert len(nodes) == 97
|
||||
|
||||
dmas = calculate_district_metering_area_for_region(p, 'r', 3)
|
||||
assert dmas == [['10', '60', '601', '61', '101', '103', '105', '107', '109', '111', '113', '115', '117', '119', '120', '121', '123', '125', '145', '147', '149', '151', '153', '157', '159', '197', '257', '259', '261', '263', 'River', 'Lake'], ['35', '40', '161', '163', '164', '166', '167', '169', '171', '173', '179', '181', '183', '184', '185', '187', '189', '191', '193', '195', '199', '201', '203', '204', '205', '207', '265', '267', '269', '271', '273', '275', '1', '177'], ['15', '20', '50', '127', '129', '131', '139', '141', '143', '206', '208', '209', '211', '213', '215', '217', '219', '225', '229', '231', '237', '239', '241', '243', '247', '249', '251', '253', '255', '2', '3']]
|
||||
|
||||
self.leave(p)
|
||||
|
||||
|
||||
def test_calculate_district_metering_area_for_network(self):
|
||||
p = 'test_calculate_district_metering_area_for_region'
|
||||
read_inp(p, f'./inp/net3.inp', '3')
|
||||
open_project(p)
|
||||
|
||||
dmas = calculate_district_metering_area_for_network(p, 3)
|
||||
assert len(dmas) == 3
|
||||
assert dmas[0] == ['173', '184', '185', '199', '2', '201', '203', '205', '206', '207', '208', '209', '211', '213', '215', '217', '219', '225', '229', '231', '237', '239', '241', '243', '247', '249', '251', '253', '255', '273', '275', '50']
|
||||
assert dmas[1] == ['1', '10', '101', '103', '109', '111', '113', '161', '163', '164', '166', '167', '169', '171', '179', '181', '183', '187', '189', '191', '193', '195', '197', '204', '265', '267', '269', '271', '35', '40', 'Lake']
|
||||
assert dmas[2] == ['105', '107', '115', '117', '119', '120', '121', '123', '125', '127', '129', '131', '139', '141', '143', '145', '147', '149', '15', '151', '153', '157', '159', '20', '257', '259', '261', '263', '3', '60', '601', '61', 'River']
|
||||
|
||||
self.leave(p)
|
||||
|
||||
|
||||
# 34 service_area
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user