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
|
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()
|
cs = ChangeSet()
|
||||||
|
|
||||||
dmas = get_all_district_metering_areas(name)
|
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
|
i = 1
|
||||||
for nodes in calculate_district_metering_area_for_network(name, part_count, part_type):
|
for nodes in calculate_district_metering_area_for_network(name, part_count, part_type):
|
||||||
boundary = calculate_boundary(name, nodes)
|
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 })
|
cs.add({ 'type': 'district_metering_area', 'id': f"DMA_1_{i}", 'boundary': boundary, 'parent': None, 'nodes': nodes })
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
return execute_batch_command(name, cs)
|
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()
|
cs = ChangeSet()
|
||||||
|
|
||||||
for id in get_all_district_metering_area_ids(name):
|
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
|
i = 1
|
||||||
for nodes in calculate_district_metering_area_for_region(name, dma, part_count, part_type):
|
for nodes in calculate_district_metering_area_for_region(name, dma, part_count, part_type):
|
||||||
boundary = calculate_boundary(name, nodes)
|
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 })
|
cs.add({ 'type': 'district_metering_area', 'id': f"DMA_{level}_{i}", 'boundary': boundary, 'parent': dma, 'nodes': nodes })
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ from .s34_sa_cal import *
|
|||||||
from .s34_sa import get_all_service_area_ids
|
from .s34_sa import get_all_service_area_ids
|
||||||
from .batch_exe import execute_batch_command
|
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()
|
cs = ChangeSet()
|
||||||
|
|
||||||
for id in get_all_service_area_ids(name):
|
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 sas in sass:
|
||||||
for source, nodes in sas.items():
|
for source, nodes in sas.items():
|
||||||
boundary = calculate_boundary(name, nodes)
|
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 })
|
cs.add({ 'type': 'service_area', 'id': f"SA_{source}_{time_index}", 'boundary': boundary, 'time_index': time_index, 'source': source, 'nodes': nodes })
|
||||||
time_index += 1
|
time_index += 1
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ from .s35_vd_cal import *
|
|||||||
from .s35_vd import get_all_virtual_district_ids
|
from .s35_vd import get_all_virtual_district_ids
|
||||||
from .batch_exe import execute_batch_command
|
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()
|
cs = ChangeSet()
|
||||||
|
|
||||||
for id in get_all_virtual_district_ids(name):
|
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']
|
center = vd['center']
|
||||||
nodes = vd['nodes']
|
nodes = vd['nodes']
|
||||||
boundary = calculate_boundary(name, 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 })
|
cs.add({ 'type': 'virtual_district', 'id': f"VD_{center}", 'boundary': boundary, 'center': center, 'nodes': nodes })
|
||||||
|
|
||||||
return execute_batch_command(name, cs)
|
return execute_batch_command(name, cs)
|
||||||
|
|||||||
16
tjnetwork.py
16
tjnetwork.py
@@ -1057,11 +1057,11 @@ def get_all_district_metering_area_ids(name: str) -> list[str]:
|
|||||||
def get_all_district_metering_areas(name: str) -> list[dict[str, Any]]:
|
def get_all_district_metering_areas(name: str) -> list[dict[str, Any]]:
|
||||||
return api.get_all_district_metering_areas(name)
|
return api.get_all_district_metering_areas(name)
|
||||||
|
|
||||||
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:
|
||||||
return api.generate_district_metering_area(name, part_count, part_type)
|
return api.generate_district_metering_area(name, part_count, part_type, inflate_delta)
|
||||||
|
|
||||||
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:
|
||||||
return api.generate_sub_district_metering_area(name, dma, part_count, part_type)
|
return api.generate_sub_district_metering_area(name, dma, part_count, part_type, inflate_delta)
|
||||||
|
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
@@ -1092,8 +1092,8 @@ def get_all_service_area_ids(name: str) -> list[str]:
|
|||||||
def get_all_service_areas(name: str) -> list[dict[str, Any]]:
|
def get_all_service_areas(name: str) -> list[dict[str, Any]]:
|
||||||
return api.get_all_service_areas(name)
|
return api.get_all_service_areas(name)
|
||||||
|
|
||||||
def generate_service_area(name: str) -> ChangeSet:
|
def generate_service_area(name: str, inflate_delta: float = 0.5) -> ChangeSet:
|
||||||
return api.generate_service_area(name)
|
return api.generate_service_area(name, inflate_delta)
|
||||||
|
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
@@ -1124,8 +1124,8 @@ def get_all_virtual_district_ids(name: str) -> list[str]:
|
|||||||
def get_all_virtual_districts(name: str) -> list[dict[str, Any]]:
|
def get_all_virtual_districts(name: str) -> list[dict[str, Any]]:
|
||||||
return api.get_all_virtual_districts(name)
|
return api.get_all_virtual_districts(name)
|
||||||
|
|
||||||
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:
|
||||||
return api.generate_virtual_district(name, centers)
|
return api.generate_virtual_district(name, centers, inflate_delta)
|
||||||
|
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
|
|||||||
Reference in New Issue
Block a user