File Coverage

blib/lib/Travel/Status/DE/HAFAS/Location.pm
Criterion Covered Total %
statement 16 20 80.0
branch n/a
condition n/a
subroutine 5 6 83.3
pod 1 2 50.0
total 22 28 78.5


line stmt bran cond sub pod time code
1             package Travel::Status::DE::HAFAS::Location;
2              
3 5     5   50 use strict;
  5         13  
  5         188  
4 5     5   23 use warnings;
  5         10  
  5         251  
5 5     5   108 use 5.014;
  5         25  
6              
7 5     5   46 use parent 'Class::Accessor';
  5         8  
  5         35  
8              
9             our $VERSION = '6.25';
10              
11             Travel::Status::DE::HAFAS::Location->mk_ro_accessors(
12             qw(lid type name eva state lat lon distance_m weight));
13              
14             sub new {
15 184     184 1 490 my ( $obj, %opt ) = @_;
16              
17 184         311 my $loc = $opt{loc};
18              
19             my $ref = {
20             lid => $loc->{lid},
21             type => $loc->{type},
22             name => $loc->{name},
23             eva => 0 + $loc->{extId},
24             state => $loc->{state},
25             lat => $loc->{crd}{y} * 1e-6,
26             lon => $loc->{crd}{x} * 1e-6,
27              
28             # only for geosearch requests
29             weight => $loc->{wt},
30             distance_m => $loc->{dist},
31 184         1765 };
32              
33 184         440 bless( $ref, $obj );
34              
35 184         587 return $ref;
36             }
37              
38             sub TO_JSON {
39 0     0 0   my ($self) = @_;
40              
41 0           my $ret = { %{$self} };
  0            
42              
43 0           return $ret;
44             }
45              
46             1;
47              
48             __END__
49              
50             =head1 NAME
51              
52             Travel::Status::DE::HAFAS::Location - A single public transit location
53              
54             =head1 SYNOPSIS
55              
56             printf("Destination: %s (%8d)\n", $location->name, $location->eva);
57              
58             =head1 VERSION
59              
60             version 6.25
61              
62             =head1 DESCRIPTION
63              
64             Travel::Status::DE::HAFAS::Location describes a HAFAS location that belongs to
65             a stop (e.g. on a journey's route) or has been returned as part of a
66             locationSearch or geoSearch request.
67              
68             =head1 METHODS
69              
70             =head2 ACCESSORS
71              
72             =over
73              
74             =item $location->name
75              
76             Location name, e.g. "Essen Hbf" or "Unter den Linden/B75, Tostedt".
77              
78             =item $location->eva
79              
80             EVA ID, e.g. 8000080.
81              
82             =item $location->lat
83              
84             Location latitude (WGS-84)
85              
86             =item $location->lon
87              
88             Location longitude (WGS-84)
89              
90             =item $location->distance_m (geoSearch)
91              
92             Distance in meters between the requested coordinates and this location.
93              
94             =item $location->weight (geoSearch, locationSearch)
95              
96             Weight / Relevance / Importance of this location using an unknown metric.
97             Higher values indicate more relevant locations.
98              
99             =back
100              
101             =head1 DIAGNOSTICS
102              
103             None.
104              
105             =head1 DEPENDENCIES
106              
107             =over
108              
109             =item Class::Accessor(3pm)
110              
111             =back
112              
113             =head1 BUGS AND LIMITATIONS
114              
115             None known.
116              
117             =head1 SEE ALSO
118              
119             Travel::Routing::DE::HAFAS(3pm).
120              
121             =head1 AUTHOR
122              
123             Copyright (C) 2023 by Birte Kristina Friesel E<lt>derf@finalrewind.orgE<gt>
124              
125             =head1 LICENSE
126              
127             This module is licensed under the same terms as Perl itself.