Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get more OTP itinerary info + fix wrong coords order #113

Merged
merged 6 commits into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions routingpy/routers/google.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,12 +369,8 @@ def parse_direction_json(response, alternatives):
duration += leg["duration"]["value"]
distance += leg["distance"]["value"]
for step in leg["steps"]:
geometry.extend(
[
list(reversed(coords))
for coords in utils.decode_polyline5(step["polyline"]["points"])
]
)
geometry.extend(utils.decode_polyline5(step["polyline"]["points"]))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah good catch. we refactored the polyline stuff (a few years ago IIRC), and this must've slipped.


return Direction(geometry=geometry, duration=duration, distance=distance, raw=response)

def isochrones(self): # pragma: no cover
Expand Down
16 changes: 9 additions & 7 deletions routingpy/routers/opentripplanner_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ class OpenTripPlannerV2:

def __init__(
self,
api_key: Optional[str] = None,
base_url: Optional[str] = _DEFAULT_BASE_URL,
user_agent: Optional[str] = None,
timeout: Optional[int] = DEFAULT,
Expand All @@ -45,8 +44,6 @@ def __init__(
"""
Initializes an OpenTripPlannerV2 client.

:param api_key: NOT USED, only for compatibility with other providers.

:param base_url: The base URL for the request. Defaults to localhost. Should not have a
trailing slash.
:type base_url: str
Expand Down Expand Up @@ -148,9 +145,14 @@ def directions(
) {{
itineraries {{
duration
startTime
endTime
legs {{
startTime
endTime
duration
distance
mode
legGeometry {{
points
}}
Expand Down Expand Up @@ -195,7 +197,7 @@ def _parse_legs(self, legs):
geometry = []
for leg in legs:
points = utils.decode_polyline5(leg["legGeometry"]["points"])
geometry.extend(points)
geometry.extend(list(reversed(points)))
distance += int(leg["distance"])

return geometry, distance
Expand Down Expand Up @@ -283,13 +285,13 @@ def raster(
use. Default: "WALK,TRANSIT"
:type profile: str

:time: Departure date and time. The default value is now.
:time: Departure date and time (timezone aware). The default value is now (UTC).
:type time: datetime.datetime

:cutoff: The maximum travel duration in seconds. The default value is one hour.

:arrive_by: Whether the itinerary should depart at the specified time (False), or arrive to
the destination at the specified time (True). Default value: False.
:arrive_by: Set to False when searching from the location and True when searching to the
location. Default value: False.
:type arrive_by: bool

:param dry_run: Print URL and parameters without sending the request.
Expand Down