Routing.pm

filter: Statementstmt 60.5% 23 / 38 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 70.0% 7 / 10 Podpod 50.0% 1 / 2 totaltotal 62.0% 31 / 50 CC 1 SCAR 2.6
CC
1
Cov
61%
_build__driver_object
2.0
query
2.0
route
2.0
CRAP 1.3
« Routing/Driver/OSRM/Query.pm ↑ Summary Routing/Driver/Gosmore/Route.pm »
1 package Geo::Routing;
2 2 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 $Geo::Routing::AUTHORITY = 'cpan:AVAR';
4 }
5 2 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 $Geo::Routing::VERSION = '0.11';
7 }
8 2 ▶use Any::Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use Any::Moose '::Util::TypeConstraints';
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use warnings FATAL => "all";
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use Class::Load qw(load_class);
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 =encoding utf8
15  
16 =head1 NAME
17  
18 Geo::Routing - Interface to the L<gosmore(1)> and L<OSRM|http://routed.sourceforge.net/> 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 2 enum GeoRoutingDrivers => qw(
36 OSRM
37 Gosmore
38 );
39  
40 2 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 2 has driver_args => (
54 is => 'ro',
55 isa => 'HashRef',
56 );
57  
58 2 has _driver_object => (
59 is => 'rw',
60 lazy_build => 1,
61 );
62  
63 0 ▶sub _build__driver_object {
Subroutine _build__driver_object: not called CC=1 SCAR=6.9
64 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<attributes|/ATTRIBUTES> you've passed
81 in. Takes a L<Geo::Gosmore::Query> object with your query, returns a
82 L<Geo::Gosmore::Route> object.
83  
84 =cut
85  
86 0 ▶sub query {
Subroutine query: not called CC=1 SCAR=6.9
Pod undocumented
87 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 0 ▶sub route {
Subroutine route: not called CC=1 SCAR=6.9
Pod documented
100 0 my ($self, $query) = @_;
101  
102 0 my $route = $self->_driver_object->route($query);
103  
104 0 return $route;
105 }
106  
107 2 1;
108  
109 =head1 LICENSE AND COPYRIGHT
110  
111 Copyright 2011 Ævar Arnfjörð Bjarmason <avar@cpan.org>
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 2 1;
119  
« Routing/Driver/OSRM/Query.pm ↑ Summary Routing/Driver/Gosmore/Route.pm »