Support inflate delta
This commit is contained in:
@@ -4,7 +4,7 @@ from .s33_dma import get_all_district_metering_area_ids, get_all_district_meteri
|
||||
from .batch_exe import execute_batch_command
|
||||
|
||||
|
||||
def generate_district_metering_area(name: str, part_count: int = 1, part_type: int = PARTITION_TYPE_RB) -> ChangeSet:
|
||||
def generate_district_metering_area(name: str, part_count: int = 1, part_type: int = PARTITION_TYPE_RB, inflate_delta: float = 0.5) -> ChangeSet:
|
||||
cs = ChangeSet()
|
||||
|
||||
dmas = get_all_district_metering_areas(name)
|
||||
@@ -21,14 +21,14 @@ def generate_district_metering_area(name: str, part_count: int = 1, part_type: i
|
||||
i = 1
|
||||
for nodes in calculate_district_metering_area_for_network(name, part_count, part_type):
|
||||
boundary = calculate_boundary(name, nodes)
|
||||
boundary = inflate_boundary(name, boundary)
|
||||
boundary = inflate_boundary(name, boundary, inflate_delta)
|
||||
cs.add({ 'type': 'district_metering_area', 'id': f"DMA_1_{i}", 'boundary': boundary, 'parent': None, 'nodes': nodes })
|
||||
i += 1
|
||||
|
||||
return execute_batch_command(name, cs)
|
||||
|
||||
|
||||
def generate_sub_district_metering_area(name: str, dma: str, part_count: int = 1, part_type: int = PARTITION_TYPE_RB) -> ChangeSet:
|
||||
def generate_sub_district_metering_area(name: str, dma: str, part_count: int = 1, part_type: int = PARTITION_TYPE_RB, inflate_delta: float = 0.5) -> ChangeSet:
|
||||
cs = ChangeSet()
|
||||
|
||||
for id in get_all_district_metering_area_ids(name):
|
||||
@@ -40,7 +40,7 @@ def generate_sub_district_metering_area(name: str, dma: str, part_count: int = 1
|
||||
i = 1
|
||||
for nodes in calculate_district_metering_area_for_region(name, dma, part_count, part_type):
|
||||
boundary = calculate_boundary(name, nodes)
|
||||
boundary = inflate_boundary(name, boundary)
|
||||
boundary = inflate_boundary(name, boundary, inflate_delta)
|
||||
cs.add({ 'type': 'district_metering_area', 'id': f"DMA_{level}_{i}", 'boundary': boundary, 'parent': dma, 'nodes': nodes })
|
||||
i += 1
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ from .s34_sa_cal import *
|
||||
from .s34_sa import get_all_service_area_ids
|
||||
from .batch_exe import execute_batch_command
|
||||
|
||||
def generate_service_area(name: str) -> ChangeSet:
|
||||
def generate_service_area(name: str, inflate_delta: float = 0.5) -> ChangeSet:
|
||||
cs = ChangeSet()
|
||||
|
||||
for id in get_all_service_area_ids(name):
|
||||
@@ -15,7 +15,7 @@ def generate_service_area(name: str) -> ChangeSet:
|
||||
for sas in sass:
|
||||
for source, nodes in sas.items():
|
||||
boundary = calculate_boundary(name, nodes)
|
||||
boundary = inflate_boundary(name, boundary)
|
||||
boundary = inflate_boundary(name, boundary, inflate_delta)
|
||||
cs.add({ 'type': 'service_area', 'id': f"SA_{source}_{time_index}", 'boundary': boundary, 'time_index': time_index, 'source': source, 'nodes': nodes })
|
||||
time_index += 1
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ from .s35_vd_cal import *
|
||||
from .s35_vd import get_all_virtual_district_ids
|
||||
from .batch_exe import execute_batch_command
|
||||
|
||||
def generate_virtual_district(name: str, centers: list[str]) -> ChangeSet:
|
||||
def generate_virtual_district(name: str, centers: list[str], inflate_delta: float = 0.5) -> ChangeSet:
|
||||
cs = ChangeSet()
|
||||
|
||||
for id in get_all_virtual_district_ids(name):
|
||||
@@ -15,7 +15,7 @@ def generate_virtual_district(name: str, centers: list[str]) -> ChangeSet:
|
||||
center = vd['center']
|
||||
nodes = vd['nodes']
|
||||
boundary = calculate_boundary(name, nodes)
|
||||
boundary = inflate_boundary(name, boundary)
|
||||
boundary = inflate_boundary(name, boundary, inflate_delta)
|
||||
cs.add({ 'type': 'virtual_district', 'id': f"VD_{center}", 'boundary': boundary, 'center': center, 'nodes': nodes })
|
||||
|
||||
return execute_batch_command(name, cs)
|
||||
|
||||
Reference in New Issue
Block a user