コード例 #1
0
    def test_enclosures(self):
        basic = mm.enclosures(self.df_streets)
        assert len(basic) == 7
        assert isinstance(basic, gpd.GeoDataFrame)

        limited = mm.enclosures(self.df_streets, gpd.GeoSeries([self.limit]))
        assert len(limited) == 20
        assert isinstance(limited, gpd.GeoDataFrame)

        b = self.limit.bounds
        additional_barrier = gpd.GeoSeries([LineString([(b[0], b[1]), (b[2], b[3])])])

        additional = mm.enclosures(
            self.df_streets, gpd.GeoSeries([self.limit]), [additional_barrier]
        )
        assert len(additional) == 28
        assert isinstance(additional, gpd.GeoDataFrame)

        with pytest.raises(TypeError):
            additional = mm.enclosures(
                self.df_streets, gpd.GeoSeries([self.limit]), additional_barrier
            )

        # test clip
        limit = self.df_streets.unary_union.convex_hull.buffer(-100)
        encl = mm.enclosures(self.df_streets, limit=gpd.GeoSeries([limit]), clip=True)
        assert len(encl) == 18
コード例 #2
0
    def test_get_node_id(self):
        nx = mm.gdf_to_nx(self.df_streets)
        nodes, edges = mm.nx_to_gdf(nx)
        self.df_buildings["nID"] = mm.get_network_id(self.df_buildings,
                                                     self.df_streets, "nID")
        ids = mm.get_node_id(self.df_buildings, nodes, edges, "nodeID", "nID")
        assert not ids.isna().any()

        convex_hull = edges.unary_union.convex_hull
        enclosures = mm.enclosures(edges, limit=gpd.GeoSeries([convex_hull]))
        enclosed_tess = mm.Tessellation(self.df_buildings,
                                        unique_id="uID",
                                        enclosures=enclosures).tessellation
        links = mm.get_network_ratio(enclosed_tess, edges)
        enclosed_tess[links.columns] = links

        ids = mm.get_node_id(
            enclosed_tess,
            nodes,
            edges,
            node_id="nodeID",
            edge_keys="edgeID_keys",
            edge_values="edgeID_values",
        )

        assert not ids.isna().any()
コード例 #3
0
    def test_get_network_ratio(self):
        convex_hull = self.df_streets.unary_union.convex_hull
        enclosures = mm.enclosures(self.df_streets, limit=gpd.GeoSeries([convex_hull]))
        enclosed_tess = mm.Tessellation(
            self.df_buildings, unique_id="uID", enclosures=enclosures
        ).tessellation
        links = mm.get_network_ratio(enclosed_tess, self.df_streets, initial_buffer=10)

        assert links.edgeID_values.apply(lambda x: sum(x)).sum() == len(enclosed_tess)
        assert links.loc[149, "edgeID_keys"] == [13, 30, 27, 29, 28]
コード例 #4
0
    def setup_method(self):

        test_file_path = mm.datasets.get_path("bubenec")
        self.df_buildings = gpd.read_file(test_file_path, layer="buildings")
        self.df_tessellation = gpd.read_file(test_file_path,
                                             layer="tessellation")
        self.df_streets = gpd.read_file(test_file_path, layer="streets")
        self.df_streets["nID"] = range(len(self.df_streets))
        self.limit = mm.buffered_limit(self.df_buildings, 50)
        self.enclosures = mm.enclosures(self.df_streets,
                                        gpd.GeoSeries([self.limit.exterior]))
コード例 #5
0
    def test_enclosures(self):
        basic = mm.enclosures(self.df_streets)
        assert len(basic) == 7
        assert isinstance(basic, gpd.GeoDataFrame)

        limited = mm.enclosures(self.df_streets, gpd.GeoSeries([self.limit]))
        assert len(limited) == 20
        assert isinstance(limited, gpd.GeoDataFrame)

        b = self.limit.bounds
        additional_barrier = gpd.GeoSeries([LineString([(b[0], b[1]), (b[2], b[3])])])

        additional = mm.enclosures(
            self.df_streets, gpd.GeoSeries([self.limit]), [additional_barrier]
        )
        assert len(additional) == 28
        assert isinstance(additional, gpd.GeoDataFrame)

        with pytest.raises(TypeError):
            additional = mm.enclosures(
                self.df_streets, gpd.GeoSeries([self.limit]), additional_barrier
            )