diff --git a/api/s34_sa_gen.py b/api/s34_sa_gen.py index 4b5cd12..a500f47 100644 --- a/api/s34_sa_gen.py +++ b/api/s34_sa_gen.py @@ -1,10 +1,14 @@ from .s32_region_util import calculate_boundary, inflate_boundary 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: cs = ChangeSet() + for id in get_all_service_area_ids(name): + cs.delete({'type': 'service_area', 'id': id}) + sass = calculate_service_area(name) time_index = 0 diff --git a/test_tjnetwork.py b/test_tjnetwork.py index 2c8bc0c..d345cdc 100644 --- a/test_tjnetwork.py +++ b/test_tjnetwork.py @@ -6181,6 +6181,16 @@ class TestApi: assert sa['source'] == 'j1' assert sa['nodes'] == ['j1'] + assert get_all_service_area_ids(p) == ['sa'] + sas = get_all_service_areas(p) + assert len(sas) == 1 + sa = sas[0] + assert sa['id'] == 'sa' + assert sa['time_index'] == 1 + assert sa['boundary'] == [(0.0, 0.0), (1.0, 0.0), (1.0, 1.0), (0.0, 0.0)] + assert sa['source'] == 'j1' + assert sa['nodes'] == ['j1'] + delete_service_area(p, ChangeSet({'id': 'sa'})) sa = get_service_area(p, 'sa') assert sa == {} @@ -6288,6 +6298,15 @@ class TestApi: cs = generate_service_area(p).operations assert len(cs) == 78 + assert len(get_all_service_area_ids(p)) == 78 + assert len(get_all_service_areas(p)) == 78 + + cs = generate_service_area(p).operations + assert len(cs) == 78 * 2 + + assert len(get_all_service_area_ids(p)) == 78 + assert len(get_all_service_areas(p)) == 78 + self.leave(p)