diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/Travel/Status/MOTIS.pm | 2 | ||||
| -rw-r--r-- | lib/Travel/Status/MOTIS/Polyline.pm | 13 | ||||
| -rw-r--r-- | lib/Travel/Status/MOTIS/Trip.pm | 2 |
3 files changed, 10 insertions, 7 deletions
diff --git a/lib/Travel/Status/MOTIS.pm b/lib/Travel/Status/MOTIS.pm index 7559d8f..e6d0d03 100644 --- a/lib/Travel/Status/MOTIS.pm +++ b/lib/Travel/Status/MOTIS.pm @@ -83,7 +83,7 @@ sub new { ); } elsif ( my $trip_id = $conf{trip_id} ) { - $request_url->path('api/v1/trip'); + $request_url->path('api/v2/trip'); $request_url->query_form( tripId => $trip_id, ); diff --git a/lib/Travel/Status/MOTIS/Polyline.pm b/lib/Travel/Status/MOTIS/Polyline.pm index ea46526..4bf5cde 100644 --- a/lib/Travel/Status/MOTIS/Polyline.pm +++ b/lib/Travel/Status/MOTIS/Polyline.pm @@ -23,7 +23,10 @@ our $VERSION = '0.01'; # <http://unitstep.net/blog/2008/08/02/decoding-google-maps-encoded-polylines-using-php/> # to perl sub decode_polyline { - my ($encoded) = @_; + my ( $input ) = @_; + + my $encoded = $input->{points}; + my $precision = $input->{precision}; my $length = length $encoded; my $index = 0; @@ -80,14 +83,14 @@ sub decode_polyline { } # The actual latitude and longitude values were multiplied by - # 1e5 before encoding so that they could be converted to a 32-bit - # integer representation. (With a decimal accuracy of 7 places) + # 1e$precision before encoding so that they could be converted to a 32-bit + # integer representation. (With a decimal accuracy of $precision places) # Convert back to original values. push( @points, { - lat => $lat * 1e-7, - lon => $lon * 1e-7 + lat => $lat * (10 ** -$precision), + lon => $lon * (10 ** -$precision), } ); } diff --git a/lib/Travel/Status/MOTIS/Trip.pm b/lib/Travel/Status/MOTIS/Trip.pm index f9e14b4..42e75b8 100644 --- a/lib/Travel/Status/MOTIS/Trip.pm +++ b/lib/Travel/Status/MOTIS/Trip.pm @@ -53,7 +53,7 @@ sub new { raw_stopovers => [ $json->{from}, @{ $json->{intermediateStops} }, $json->{to} ], - raw_polyline => $json->{legGeometry}->{points}, + raw_polyline => $json->{legGeometry}, }; $ref->{scheduled_departure} = DateTime::Format::ISO8601->parse_datetime( |
