diff --git a/README.md b/README.md index cccf8ab..0120445 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ poi_from_bbox = OsmGt.poi_from_bbox( ) # 2 methods available: -poi_study_area_data_wkt = poi_from_bbox.study_area_geom() # to get the wkt of the data +poi_study_area_data_wkt = poi_from_bbox.study_area_geom() # to get the shapely Polygon of the study data poi_gdf = poi_from_bbox.get_gdf() # to get the geodataframe containing all the POIs @@ -44,13 +44,13 @@ roads_from_location = OsmGt.roads_from_location( ) roads_from_bbox = OsmGt.roads_from_bbox( - (-74.018433, 40.718087, -73.982749, 40.733356), + (4.0237426757812, 46.019674567761, 4.1220188140869, 46.072575637028), mode="pedestrian", # 'pedestrian' or 'vehicle' supported additionnal_nodes=None, # optional, to connect nodes on the roads network (geodataframe or None) ) # 3 methods available: -roads_study_area_data_wkt = roads_from_location.study_area_geom() # to get the wkt of the data +roads_study_area_data_wkt = roads_from_location.study_area_geom() # to get the shapely Polygon of the study data roads_gdf = roads_from_location.get_gdf() # to get the geodataframe containing all the roads roads_graph = roads_from_location.get_graph() # to get the graph (graph-tool graph) of the osm network ``` diff --git a/osmgt/compoments/core.py b/osmgt/compoments/core.py index fd160cd..dfe3aa8 100644 --- a/osmgt/compoments/core.py +++ b/osmgt/compoments/core.py @@ -72,8 +72,9 @@ def from_bbox(self, bbox_value): self._bbox_mode = True self.logger.info(f"From bbox: {bbox_value}") self.logger.info("Loading data...") + self.study_area_geom = box(*bbox_value, ccw=True) + # reordered because of nominatim self._bbox_value = (bbox_value[1], bbox_value[0], bbox_value[3], bbox_value[2]) - self.study_area_geom = box(*self._bbox_value, ccw=True) def _get_study_area_from_bbox(self, bbox): return diff --git a/osmgt/compoments/roads.py b/osmgt/compoments/roads.py index 2703ff9..8655ab0 100644 --- a/osmgt/compoments/roads.py +++ b/osmgt/compoments/roads.py @@ -74,10 +74,9 @@ def get_graph(self): graph = GraphHelpers(is_directed=network_queries[self._mode]["directed_graph"]) for feature in self._output_data: - geom_coords = feature[self._GEOMETRY_FIELD].coords graph.add_edge( - Point(geom_coords[0]).wkt, - Point(geom_coords[-1]).wkt, + Point(feature[self._GEOMETRY_FIELD].coords[0]).wkt, + Point(feature[self._GEOMETRY_FIELD].coords[-1]).wkt, feature[self._TOPO_FIELD], shape(feature[self._GEOMETRY_FIELD]).length, ) diff --git a/tests/test_main.py b/tests/test_main.py index 9f3d6ca..b60f606 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -106,7 +106,7 @@ def test_run_from_bbox_func_usa(pois_default_columns_from_output, roads_default_ for colunm_expected in roads_default_columns_from_output: assert colunm_expected in columns_computed - #check graph + # check graph assert len(list(graph_computed.edges())) > 0 assert len(list(graph_computed.vertices())) > 0 assert type(graph_computed.vertices_content) == dict @@ -114,7 +114,7 @@ def test_run_from_bbox_func_usa(pois_default_columns_from_output, roads_default_ def test_if_path_can_be_computed(points_gdf_from_coords): - + # TODO add the same test with bbox... location_name = "roanne" poi_from_web_found_gdf = OsmGt.poi_from_location(location_name).get_gdf()