Skip to content

Commit

Permalink
feat: 390 make sections optional (#391)
Browse files Browse the repository at this point in the history
* chore: make sections optional

* test: add test for network config with only project and network section
  • Loading branch information
ArdtK authored Apr 2, 2024
1 parent 3eb385d commit 7f9722f
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ def get_network_section(self) -> NetworkSection:

def get_origins_destinations_section(self) -> OriginsDestinationsSection:
_section = "origins_destinations"
if _section not in self._parser:
return OriginsDestinationsSection()

_od_section = OriginsDestinationsSection(**self._parser[_section])
_od_section.origin_out_fraction = self._parser.getint(
_section, "origin_out_fraction", fallback=_od_section.origin_out_fraction
Expand All @@ -187,12 +190,14 @@ def get_isolation_section(self) -> IsolationSection:
_section = "isolation"
if _section not in self._parser:
return IsolationSection()

return IsolationSection(**self._parser[_section])

def get_hazard_section(self) -> HazardSection:
_section = "hazard"
if _section not in self._parser:
return HazardSection()

_hazard_section = HazardSection(**self._parser[_section])
_hazard_section.hazard_map = list(
map(
Expand All @@ -212,6 +217,8 @@ def get_hazard_section(self) -> HazardSection:

def get_cleanup_section(self) -> CleanupSection:
_section = "cleanup"
if _section not in self._parser:
return CleanupSection()

_cleanup_section = CleanupSection()
_cleanup_section.snapping_threshold = self._parser.getboolean(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def network_ini_filepath(self, request: pytest.FixtureRequest) -> Path:
"network_ini_filepath",
[
pytest.param("1_network_shape"),
pytest.param("1_network_shape_minimal_config"),
pytest.param("2_network_shape"),
pytest.param("3_network_osm_download"),
],
Expand Down
13 changes: 13 additions & 0 deletions tests/test_data/1_network_shape_minimal_config/network.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[project]
name = 1_network_shape_minimal_config

[network]
directed = False
source = shapefile
primary_file = test_network_domrep.shp
diversion_file = None
file_id = ID
polygon = None
network_type = drive
road_types = motorway
save_gpkg = True
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
UTF-8
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]]
Binary file not shown.
Binary file not shown.

0 comments on commit 7f9722f

Please sign in to comment.