def test_remove_false_nodes(self): test_file_path2 = mm.datasets.get_path("tests") self.false_network = gpd.read_file(test_file_path2, layer="network") self.false_network["vals"] = range(len(self.false_network)) fixed = mm.remove_false_nodes(self.false_network) assert len(fixed) == 56 assert isinstance(fixed, gpd.GeoDataFrame) assert self.false_network.crs.equals(fixed.crs) assert sorted(self.false_network.columns) == sorted(fixed.columns) fixed_series = mm.remove_false_nodes(self.false_network.geometry) assert len(fixed_series) == 56 assert isinstance(fixed_series, gpd.GeoSeries) # assert self.false_network.crs.equals(fixed_series.crs) GeoPandas 0.8 BUG multiindex = self.false_network.explode() fixed_multiindex = mm.remove_false_nodes(multiindex) assert len(fixed_multiindex) == 56 assert isinstance(fixed, gpd.GeoDataFrame) assert sorted(self.false_network.columns) == sorted(fixed.columns)
def test_close_gaps(self): l1 = LineString([(1, 0), (2, 1)]) l2 = LineString([(2.1, 1), (3, 2)]) l3 = LineString([(3.1, 2), (4, 0)]) l4 = LineString([(4.1, 0), (5, 0)]) l5 = LineString([(5.1, 0), (6, 0)]) df = gpd.GeoDataFrame(geometry=[l1, l2, l3, l4, l5]) closed = mm.close_gaps(df, 0.25) assert len(closed) == len(df) merged = mm.remove_false_nodes(closed) assert len(merged) == 1 assert merged.length[0] == pytest.approx(7.0502, rel=1e-3)
def time_remove_false_nodes(self): mm.remove_false_nodes(self.false_network)