ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent-GPSD/GPSD.pm
(Generate patch)

Comparing AnyEvent-GPSD/GPSD.pm (file contents):
Revision 1.6 by root, Fri Jul 25 13:26:06 2008 UTC vs.
Revision 1.7 by root, Sat Jul 26 05:34:58 2008 UTC

56The host to connect to, default is C<locahost>. 56The host to connect to, default is C<locahost>.
57 57
58=item port => $port 58=item port => $port
59 59
60The port to connect to, default is C<2947>. 60The port to connect to, default is C<2947>.
61
62=item min_speed => $speed_in_m_per_s
63
64Sets the mininum speed (default: 0) that is considered real for the
65purposes of replay compression or estimate. Speeds below this value will
66be considered 0.
61 67
62=item on_error => $cb->($gps) 68=item on_error => $cb->($gps)
63 69
64Called on every connection or protocol failure, reason is in C<$!> 70Called on every connection or protocol failure, reason is in C<$!>
65(protocl errors are signalled via EBADMSG). Can be used to bail out if you 71(protocl errors are signalled via EBADMSG). Can be used to bail out if you
342} 348}
343 349
344=item ($lat, $lon) = $gps->estimate ([$max_seconds]) 350=item ($lat, $lon) = $gps->estimate ([$max_seconds])
345 351
346This returns an estimate of the current position based on the last fix and 352This returns an estimate of the current position based on the last fix and
347the time passed since then. Useful for interactive applications where you 353the time passed since then.
348want more frequent updates, but not very useful to store, as the next fix 354
349might well be totally off. 355Useful for interactive applications where you want more frequent updates,
356but not very useful to store, as the next fix might well be totally
357off. For example, when displaying a real-time map, you could simply call
358C<estimate> ten times a second and update the cursor or map position, but
359you should use C<on_fix> to actually gather data to plot the course itself.
350 360
351If the fix is older then C<$max_seconds> (default: C<1.9> times the update 361If the fix is older then C<$max_seconds> (default: C<1.9> times the update
352interval, i.e. usually C<1.9> seconds) or if no fix is available, returns 362interval, i.e. usually C<1.9> seconds) or if no fix is available, returns
353the empty list. 363the empty list.
354 364
366 376
367 my $diff = AnyEvent->time - $fix->{time}; 377 my $diff = AnyEvent->time - $fix->{time};
368 378
369 $diff <= $max or return; 379 $diff <= $max or return;
370 380
371 if ($fix->{speed} > $fix->{serr}) { 381 if ($fix->{speed} >= $self->{min_speed}) {
372 my ($lat, $lon) = $geo->forward ($fix->{lat}, $fix->{lon}, $fix->{bearing}, $fix->{speed} * $diff); 382 my ($lat, $lon) = $geo->forward ($fix->{lat}, $fix->{lon}, $fix->{bearing}, $fix->{speed} * $diff);
373 ($lat, $lon) 383 ($lat, $lon)
374 384
375 } else { 385 } else {
376 # if we likely have zero speed, return the point itself 386 # if we likely have zero speed, return the point itself
421 431
422Please note that replaying a log will change configuration options that 432Please note that replaying a log will change configuration options that
423will not be restored, so it's best not to reuse a gpsd object after a 433will not be restored, so it's best not to reuse a gpsd object after a
424replay. 434replay.
425 435
436The C<AnyEvent::GPSD> distribution comes with an example log
437(F<eg/example.aegps>) that you can replay for testing or enjoyment
438purposes.
439
426The options include: 440The options include:
427 441
428=over 4 442=over 4
429 443
430=item compress => 1 444=item compress => 1
481 } 495 }
482 496
483 if ( 497 if (
484 $type eq "start" 498 $type eq "start"
485 or ($self->{compress} 499 or ($self->{compress}
486 and $self->{fix} && ($self->{fix}{mode} < 2 || $self->{fix}{speed} < 5)) 500 and $self->{fix} && ($self->{fix}{mode} < 2 || $self->{fix}{speed} < $self->{min_speed}))
487 ) { 501 ) {
488 $self->{replay_now} = $time; 502 $self->{replay_now} = $time;
489 } 503 }
490 504
491 $self->{replay_timer} = AnyEvent->timer (after => $time - $self->{replay_now}, cb => sub { 505 $self->{replay_timer} = AnyEvent->timer (after => $time - $self->{replay_now}, cb => sub {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines