Skip to content

Commit

Permalink
Get more OTP itinerary info + fix wrong coords order (#113)
Browse files Browse the repository at this point in the history
  • Loading branch information
khamaileon committed Aug 2, 2023
1 parent a008971 commit 862a7cf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
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"]))

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

0 comments on commit 862a7cf

Please sign in to comment.