Skip to content

Commit

Permalink
Fix incorrect geodesic function call by correcting latitude and longi…
Browse files Browse the repository at this point in the history
…tude order
  • Loading branch information
joda9 committed Sep 17, 2024
1 parent e669953 commit a8360f4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
5 changes: 1 addition & 4 deletions edisgo/tools/geo.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

from typing import TYPE_CHECKING

import geopy.distance
import pandas as pd

from geopy.distance import geodesic
Expand Down Expand Up @@ -349,9 +348,7 @@ def calculate_distance_to_buses_df(
"""
distances = buses_df.apply(
lambda row: geopy.distance.distance(
(row["x"], row["y"]), (point.x, point.y)
).km,
lambda row: geodesic((row["y"], row["x"]), (point.y, point.x)).km,
axis=1,
)
buses_df.loc[:, "distance"] = distances
Expand Down
2 changes: 1 addition & 1 deletion tests/tools/test_geo.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ def test_find_nearest_bus(self):
point = Point((10.002736, 47.5426))
nearest_bus, dist = geo.find_nearest_bus(point, self.edisgo.topology.buses_df)
assert nearest_bus == "BranchTee_mvgd_33535_lvgd_1163360000_building_431698"
assert np.isclose(dist, 0.0008622, atol=1e-6)
assert np.isclose(dist, 0.000806993475812168, atol=1e-6)

0 comments on commit a8360f4

Please sign in to comment.