line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Geo::Routing; |
2
|
|
|
|
|
|
|
BEGIN { |
3
|
1
|
|
|
1
|
|
1344
|
$Geo::Routing::AUTHORITY = 'cpan:AVAR'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
BEGIN { |
6
|
1
|
|
|
1
|
|
17
|
$Geo::Routing::VERSION = '0.11'; |
7
|
|
|
|
|
|
|
} |
8
|
1
|
|
|
1
|
|
9
|
use Any::Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
10
|
|
9
|
1
|
|
|
1
|
|
7100
|
use Any::Moose '::Util::TypeConstraints'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
5
|
|
10
|
1
|
|
|
1
|
|
893
|
use warnings FATAL => "all"; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
43
|
|
11
|
1
|
|
|
1
|
|
7
|
use Data::Dumper; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
84
|
|
12
|
1
|
|
|
1
|
|
1955
|
use Class::Load qw(load_class); |
|
1
|
|
|
|
|
40210
|
|
|
1
|
|
|
|
|
297
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=encoding utf8 |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 NAME |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
Geo::Routing - Interface to the L and L routing libraries |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 DESCRIPTION |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
This is experimental software with an unstable API. It'll be better |
23
|
|
|
|
|
|
|
soon, but for now don't trust anything here. |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=cut |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head2 driver |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
What driver should we be using to do the routing? |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=cut |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
enum GeoRoutingDrivers => qw( |
36
|
|
|
|
|
|
|
OSRM |
37
|
|
|
|
|
|
|
Gosmore |
38
|
|
|
|
|
|
|
); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
has driver => ( |
41
|
|
|
|
|
|
|
is => 'ro', |
42
|
|
|
|
|
|
|
isa => 'GeoRoutingDrivers', |
43
|
|
|
|
|
|
|
required => 1, |
44
|
|
|
|
|
|
|
documentation => '', |
45
|
|
|
|
|
|
|
); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head2 driver_args |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
ArrayRef of arguments to pass to the driver. |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=cut |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
has driver_args => ( |
54
|
|
|
|
|
|
|
is => 'ro', |
55
|
|
|
|
|
|
|
isa => 'HashRef', |
56
|
|
|
|
|
|
|
); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
has _driver_object => ( |
59
|
|
|
|
|
|
|
is => 'rw', |
60
|
|
|
|
|
|
|
lazy_build => 1, |
61
|
|
|
|
|
|
|
); |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub _build__driver_object { |
64
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
65
|
|
|
|
|
|
|
|
66
|
0
|
|
|
|
|
|
my $driver = $self->driver; |
67
|
0
|
|
|
|
|
|
my $module = "Geo::Routing::Driver::$driver"; |
68
|
0
|
|
|
|
|
|
load_class($module); |
69
|
0
|
|
|
|
|
|
my $driver_object = $module->new($self->driver_args); |
70
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
|
return $driver_object; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 METHODS |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=cut |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head2 route |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Find a route based on the L you've passed |
81
|
|
|
|
|
|
|
in. Takes a L object with your query, returns a |
82
|
|
|
|
|
|
|
L object. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=cut |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub query { |
87
|
0
|
|
|
0
|
0
|
|
my ($self, %query) = @_; |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
# TODO: Make this lazy |
90
|
0
|
|
|
|
|
|
my $driver = $self->driver; |
91
|
0
|
|
|
|
|
|
my $module = "Geo::Routing::Driver::${driver}::Query"; |
92
|
0
|
|
|
|
|
|
load_class($module); |
93
|
|
|
|
|
|
|
|
94
|
0
|
|
|
|
|
|
my $query_object = $module->new(%query); |
95
|
|
|
|
|
|
|
|
96
|
0
|
|
|
|
|
|
return $query_object; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub route { |
100
|
0
|
|
|
0
|
1
|
|
my ($self, $query) = @_; |
101
|
|
|
|
|
|
|
|
102
|
0
|
|
|
|
|
|
my $route = $self->_driver_object->route($query); |
103
|
|
|
|
|
|
|
|
104
|
0
|
|
|
|
|
|
return $route; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
1; |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Copyright 2011 Ævar Arnfjörð Bjarmason |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
This program is free software, you can redistribute it and/or modify |
114
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=cut |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
1; |
119
|
|
|
|
|
|
|
|