GIS::Distance::Formula::GeoEllipsoid - Geo::Ellipsoid distance calculations.


GIS-Distance documentation Contained in the GIS-Distance distribution.

Index


Code Index:

NAME

Top

GIS::Distance::Formula::GeoEllipsoid - Geo::Ellipsoid distance calculations.

SYNOPSIS

Top

  my $gis = GIS::Distance->new();

  $gis->formula( 'GeoEllipsoid', { ellipsoid => 'WGS84' } );

DESCRIPTION

Top

This module is a wrapper around Geo::Ellipsoid for GIS::Distance.

Normally this module is not used directly. Instead GIS::Distance is used which in turn interfaces with the various formula classes.

FORMULA

Top

See the documentation for Geo::Ellipsoid.

ATTRIBUTES

Top

ellipsoid

  $calc->ellipsoid( 'AIRY' );

Set and retrieve the ellipsoid object. If a string is passed then it will be coerced in to an object.

METHODS

Top

distance

This method is called by GIS::Distance's distance() method.

SEE ALSO

Top

GIS::Distanc

Geo::Ellipsoid

AUTHOR

Top

Aran Clary Deltac <bluefeet@cpan.org>

LICENSE

Top

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


GIS-Distance documentation Contained in the GIS-Distance distribution.
package GIS::Distance::Formula::GeoEllipsoid;

use Any::Moose;
use namespace::autoclean;

with 'GIS::Distance::Formula';

use Any::Moose '::Util::TypeConstraints';
use Class::Measure::Length qw( length );
use Geo::Ellipsoid;

subtype 'GeoEllipsoid'
    => as 'Object'
    => where { $_->isa('Geo::Ellipsoid') };

coerce 'GeoEllipsoid'
    => from 'Str'
        => via {
            my $type = $_;
            return Geo::Ellipsoid->new(
                units => 'degrees',
                ( $type ? (ellipsoid=>$type) : () ),
            );
        };

has 'ellipsoid' => (
    is      => 'rw',
    isa     => 'GeoEllipsoid',
    default => '',
    coerce  => 1,
);

sub distance {
    my $self = shift;

    return length(
        $self->ellipsoid->range( @_ ),
        'm'
    );
}

__PACKAGE__->meta->make_immutable;

1;
__END__