Geo::Coordinates::Converter::Point - the coordinates object


Geo-Coordinates-Converter documentation Contained in the Geo-Coordinates-Converter distribution.

Index


Code Index:

NAME

Top

Geo::Coordinates::Converter::Point - the coordinates object

SYNOPSIS

Top

    use strict;
    use warnings;

    use Geo::Coordinates::Converter::Point;

    my $point = Geo::Coordinates::Converter::Point->new({
        lat    => '35.65580',
        lng    => '139.65580',
        datum  => 'wgs84',
        format => 'degree',
    });

    my $point = Geo::Coordinates::Converter::Point->new({
        lat    => '35.39.24.00',
        lng    => '139.40.15.05',
        datum  => 'wgs84',
        format => 'dms',
    });

    my $clone = $point->clone;

    my $new_point = $point->converter( degree => 'wgs84' );




DESCRIPTION

Top

accessor of data concerning coordinates. data is not processed at all.

METHODS

Top

new

constructor

lat

accessor of latitude

latitude

alias of lat

lng

accessor of longitude

longitude

alias of lng

datum

accessor of datum. default is wgs84.

format

accessor of coordinates format

clone

clone object

converter

wrapper of Geo::Coordinates::Converter->convert.

    my $new_point = $point->converter(degree => 'wgs84');

the method same code is under.

    my $new_point = Geo::Coordinates::Converter->new(
        point => $point,
    )->convert(degree => 'wgs84');

AUTHOR

Top

Kazuhiro Osawa <yappo {at} shibuya {dot} pl>

LICENSE

Top

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


Geo-Coordinates-Converter documentation Contained in the Geo-Coordinates-Converter distribution.

package Geo::Coordinates::Converter::Point;
use strict;
use warnings;
use Class::Accessor::Lite (
    rw => [qw/ lat lng datum format height /],
);

use Geo::Coordinates::Converter;

# back compatibility
sub mk_accessors {
    my($class, @args) = @_;
    Class::Accessor::Lite->mk_accessors(@_);
}
sub mk_ro_accessors {
    my($class, @args) = @_;
    Class::Accessor::Lite->mk_ro_accessors(@_);
}
sub mk_wo_accessors {
    my($class, @args) = @_;
    Class::Accessor::Lite->mk_wo_accessors(@_);
}

use Storable ();

*latitude  = \&lat;
*longitude = \&lng;

sub new {
    my($class, $args) = @_;
    $args = +{} unless defined $args;
    my $self = bless { %{ $args } }, $class;
    $self->{lat} ||= $self->{latitude} || '0.000000';
    $self->{lng} ||= $self->{longitude} || '0.000000';
    $self->{height} ||= 0;
    $self->{datum} ||= 'wgs84';
    $self;
}

sub clone {
    my $self = shift;
    my $clone = Storable::dclone($self);
    $clone;
}

sub converter {
    my $self = shift;
    Geo::Coordinates::Converter->new(
        point => $self,
    )->convert( @_ );
}

1;

__END__