Skip to content
Snippets Groups Projects
Stop.pm 1.94 KiB
package Travel::Status::DE::HAFAS::Stop;

# vim:foldmethod=marker

use strict;
use warnings;
use 5.014;

use parent 'Class::Accessor';

our $VERSION = '4.09';

Travel::Status::DE::HAFAS::Stop->mk_ro_accessors(
	qw(eva name lat lon distance_m weight));

# {{{ Constructor

sub new {
	my ( $obj, %opt ) = @_;

	my $loc = $opt{loc};
	my $ref = {
		eva        => 0 + $loc->{extId},
		name       => $loc->{name},
		lat        => $loc->{crd}{x} * 1e-6,
		lon        => $loc->{crd}{y} * 1e-6,
		weight     => $loc->{wt},
		distance_m => $loc->{dist},
	};

	bless( $ref, $obj );

	return $ref;
}

# }}}

1;

__END__

=head1 NAME

Travel::Status::DE::HAFAS::Stop - Information about a HAFAS stop.

=head1 SYNOPSIS

	# in geoSearch mode
	for my $stop ($status->results) {
		printf(
			"%5.1f km  %8d  %s\n",
			$result->distance_m * 1e-3,
			$result->eva, $result->name
		);
	}

=head1 VERSION

version 4.09

=head1 DESCRIPTION

Travel::Status::DE::HAFAS::Stop describes a HAFAS stop. It may be part of a
journey or part of a geoSearch request.

geoSearch-specific accessors are annotated with "(geoSearch)" and return
undef for non-geoSearch stops.

=head1 METHODS