Ignore:
Timestamp:
Sep 17, 2006, 5:26:28 PM (15 years ago)
Author:
nick
Message:

Support doing Helmert Transforms as required, using the MySociety? Helmert transform library, if installed. References #89

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/t/28_wgs84_coords.t

    r792 r870  
    55use Test::More;
    66
    7 plan tests => 2;
     7plan tests => 4;
    88
    99# Clear out the database from any previous runs.
     
    1818my $guide = OpenGuides->new( config => $config );
    1919
    20 my ($longitude, $latitude) = (0, 0);
     20my ($longitude, $latitude) = (10, 12);
    2121
    2222my ($wgs_long, $wgs_lat) = OpenGuides::Utils->get_wgs84_coords(
     
    2929is( $wgs_lat, $latitude,
    3030    "get_wgs84_coords returns the original latitude when force_wgs84 is on");
     31
     32
     33# Now claim to be in the UK
     34eval{ require Geo::HelmertTransform; };
     35my $have_helmert = $@ ? 0 : 1;
     36SKIP : {
     37    skip "Geo::HelmertTransform not installed - can't do transforms", 2
     38        unless $have_helmert;
     39
     40    $config->force_wgs84(0);
     41    $config->geo_handler(1);
     42
     43    # Set our location to be somewhere known
     44       ($longitude,$latitude)  = (-1.258200,51.754349);
     45    my ($wgs84_lon,$wgs84_lat) = (-1.259687,51.754813);
     46
     47    ($wgs_long, $wgs_lat) = OpenGuides::Utils->get_wgs84_coords(
     48                                                     longitude => $longitude,
     49                                                     latitude => $latitude,
     50                                                     config => $config);
     51
     52    # Round to 5 dp
     53    my $fivedp = 1 * 1000 * 100;
     54    $wgs_long = int($wgs_long * $fivedp)/$fivedp;
     55    $wgs_lat  = int($wgs_lat  * $fivedp)/$fivedp;
     56    $wgs84_lon = int($wgs84_lon * $fivedp)/$fivedp;
     57    $wgs84_lat = int($wgs84_lat * $fivedp)/$fivedp;
     58
     59    is( $wgs_long, $wgs84_lon,
     60        "get_wgs84_coords does Airy1830 -> WGS84 convertion properly");
     61    is( $wgs_lat, $wgs84_lat,
     62        "get_wgs84_coords does Airy1830 -> WGS84 convertion properly");
     63}
Note: See TracChangeset for help on using the changeset viewer.