Support inflate delta

This commit is contained in:
WQY\qiong
2023-05-19 22:59:25 +08:00
parent 4e14b9398d
commit 99c82fcf15
4 changed files with 16 additions and 16 deletions

View File

@@ -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)