Skip to content

Commit

Permalink
fix (core.py) bbox coords order
Browse files Browse the repository at this point in the history
  • Loading branch information
amauryval committed Aug 10, 2020
1 parent a1463a2 commit 7906ac1
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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
```
Expand Down
3 changes: 2 additions & 1 deletion osmgt/compoments/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions osmgt/compoments/roads.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,15 @@ 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
assert len(graph_computed.vertices_content) > 0


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()

Expand Down

0 comments on commit 7906ac1

Please sign in to comment.