Changeset 171


Ignore:
Timestamp:
Jun 13, 2004, 2:42:46 PM (17 years ago)
Author:
kake
Message:

->distance takes latlong

Location:
cgi-wiki-plugin-locator-uk/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • cgi-wiki-plugin-locator-uk/trunk/Changes

    r168 r171  
     10.09    13 June 2004
     2        ->distance now accepts "from_lat" and "from_long" arguments;
     3          use these in combination with "to_node".
     4          Internally everything is still done in terms of OS X and Y.
     5
    160.08    12 June 2004
    27        ->find_within_distance now accepts "lat" and "long" arguments.
  • cgi-wiki-plugin-locator-uk/trunk/lib/CGI/Wiki/Plugin/Locator/UK.pm

    r168 r171  
    44
    55use vars qw( $VERSION @ISA );
    6 $VERSION = '0.08';
     6$VERSION = '0.09';
    77
    88use Carp qw( croak );
     
    104104                                    unit      => "metres" );
    105105
     106  # Or specify the point via latitude and longitude.
     107  my $distance = $locator->distance(from_lat  => 51.53,
     108                                    from_long => -0.1,
     109                                    to_node   => "Duke of Cambridge",
     110                                    unit      => "metres" );
     111
    106112Defaults to kilometres if C<unit> is not supplied or is not recognised.
    107113Recognised units at the moment: C<metres>, C<kilometres>.
     
    127133    } elsif ( $args{from_os_x} and $args{from_os_y} ) {
    128134        @from = @args{ qw( from_os_x from_os_y ) };
     135    } elsif ( $args{from_lat} and $args{from_long} ) {
     136        my $point = Geography::NationalGrid::GB->new(
     137                                                 Latitude  => $args{from_lat},
     138                                                 Longitude => $args{from_long},
     139                                                    );
     140        @from = ( $point->easting, $point->northing );
    129141    }
    130142
  • cgi-wiki-plugin-locator-uk/trunk/t/04_lat_long.t

    r169 r171  
    33use CGI::Wiki::TestConfig::Utilities;
    44use vars qw( $num_loop_tests );
    5 BEGIN { $num_loop_tests = 1; }
     5BEGIN { $num_loop_tests = 2; }
    66use Test::More tests =>
    77  (0 + $num_loop_tests * $CGI::Wiki::TestConfig::Utilities::num_stores);
     
    5151                 "->find_within_distance works with start point as latlong" );
    5252
     53      my $dist = $locator->distance( from_lat  => 51.524975,
     54                                     from_long => -0.116250,
     55                                     to_node   => "Calthorpe Arms",
     56                                     unit      => "metres" );
     57      ok( $dist < 400 && $dist > 0, "->distance works with latlong" );
     58
    5359    } # end of SKIP
    5460}
Note: See TracChangeset for help on using the changeset viewer.