Skip to content

Commit

Permalink
Changed more shp to gpkg
Browse files Browse the repository at this point in the history
  • Loading branch information
frederique-hub committed Oct 13, 2023
1 parent a1d289f commit 399f543
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion ra2ce/graph/exporters/geodataframe_network_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@


class GeoDataFrameNetworkExporter(NetworkExporterBase):
def export_to_shp(self, output_dir: Path, export_data: gpd.GeoDataFrame) -> None:
def export_to_gpkg(self, output_dir: Path, export_data: gpd.GeoDataFrame) -> None:
_output_shp_path = output_dir / (self._basename + ".gpkg")
export_data.to_file(
_output_shp_path, index=False
Expand Down
2 changes: 1 addition & 1 deletion ra2ce/graph/exporters/multi_graph_network_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
class MultiGraphNetworkExporter(NetworkExporterBase):
pickle_path: Optional[Path]

def export_to_shp(self, output_dir: Path, export_data: MULTIGRAPH_TYPE) -> None:
def export_to_gpkg(self, output_dir: Path, export_data: MULTIGRAPH_TYPE) -> None:
if not output_dir.is_dir():
output_dir.mkdir(parents=True)

Expand Down
4 changes: 2 additions & 2 deletions ra2ce/graph/exporters/network_exporter_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def __init__(self, basename: str, export_types: List[str]) -> None:
self._export_types = export_types
self.pickle_path = None

def export_to_shp(self, output_dir: Path, export_data: NETWORK_TYPE) -> None:
def export_to_gpkg(self, output_dir: Path, export_data: NETWORK_TYPE) -> None:
"""
Exports the given data into a `*.gpkg` file.
Expand Down Expand Up @@ -75,4 +75,4 @@ def export(self, export_path: Path, export_data: Any) -> None:
self.export_to_pickle(export_path, export_data)

if "shp" in self._export_types:
self.export_to_shp(export_path, export_data)
self.export_to_gpkg(export_path, export_data)
4 changes: 2 additions & 2 deletions tests/graph/exporters/test_geodataframe_network_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def test_initialize(self):
assert isinstance(_exporter, NetworkExporterBase)

@pytest.mark.skip(reason="TODO: Needs to define GeoDataFrame dummydata.")
def test_export_to_shp(self, request: pytest.FixtureRequest):
def test_export_to_gpkg(self, request: pytest.FixtureRequest):
# 1. Define test data.
_output_dir = test_results / request.node.name
if _output_dir.is_dir():
Expand All @@ -30,7 +30,7 @@ def test_export_to_shp(self, request: pytest.FixtureRequest):
_export_data = GeoDataFrame()

# 2. Run test.
_exporter.export_to_shp(_output_dir, _export_data)
_exporter.export_to_gpkg(_output_dir, _export_data)

# 3. Verify final expectations.
assert _output_dir.is_dir()
Expand Down
4 changes: 2 additions & 2 deletions tests/graph/exporters/test_multi_graph_network_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def test_initialize(self):
assert isinstance(_exporter, NetworkExporterBase)
assert isinstance(_exporter, Ra2ceExporterProtocol)

def test_export_to_shp_creates_dir(self, request: pytest.FixtureRequest):
def test_export_to_gpkg_creates_dir(self, request: pytest.FixtureRequest):
"""
TODO: Create dummy export_data (MULTIGRAPH_TYPE) so we don't have to wrap it in a pytest.raises.
"""
Expand All @@ -29,7 +29,7 @@ def test_export_to_shp_creates_dir(self, request: pytest.FixtureRequest):

# 2. Run test.
with pytest.raises(Exception):
_exporter.export_to_shp(_test_dir, None)
_exporter.export_to_gpkg(_test_dir, None)

# 3. Verify expectations.
assert _test_dir.exists()
Expand Down

0 comments on commit 399f543

Please sign in to comment.