#!/usr/local/bin/perl -w
 use strict;
 use YAML qw( Load Dump );
 use Geo::Distance;

 my $tour    = Load( join "", <> );
 my @markers = ();

 my $geo = Geo::Distance->new();
 my $last_pt;

 for my $point ( @{ $tour } ) {

   if( $last_pt ) {

     my $k = $geo->distance("meter",
       $last_pt->{lon}, $last_pt->{lat},
       $point->{lon}, $point->{lat} );

     push @markers, $point;

     my $time_diff =
      $point->{ time } - $last_pt->{ time };

     if( $k > 1_000 ) {
       @markers = ();
       $last_pt = $point;
       next;
     }

     my $speed = 1.0 * $k / $time_diff;
     if( $speed > 5 ) {
       last;
     }
   }

   $last_pt = $point;
 }

 print Dump( \@markers );