| 1 | package Geo::Coordinates; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | |||
| 6 | |||
| 7 | our $VERSION = '0.01'; | ||
| 8 | |||
| 9 | =head1 NAME | ||
| 10 | |||
| 11 | Geo::Coordinates - Basic class for geographical coordinates | ||
| 12 | |||
| 13 | =head1 SYNOPSIS | ||
| 14 | |||
| 15 | use Geo::Coordinates; | ||
| 16 | my $place = new Geo::Coordinates; | ||
| 17 | $place->latitude(59.78); | ||
| 18 | $place->longitude(10.12); | ||
| 19 | |||
| 20 | =head1 DESCRIPTION | ||
| 21 | |||
| 22 | B<IT IS A BAD IDEA TO USE THIS CLASS> in its present form! The Geo stuff is undergoing some elaborate revision, see http://wiki.bluedevbox.com/newgeo/new.htm | ||
| 23 | but there was some demand for L<Astro::SolarParallax>, so I needed to get it out the door. Anyway...: | ||
| 24 | |||
| 25 | This is a simple Object Oriented implementation of geographical coordinates, latitude and longitude. It is meant to be just a basic class, and won't do a lot on it's own. Basically, it is just a convenient container and abstraction layer. Hey, it's OO! | ||
| 26 | |||
| 27 | =over | ||
| 28 | |||
| 29 | =item new() | ||
| 30 | |||
| 31 | The constructor of this class. Nothing special. | ||
| 32 | |||
| 33 | =cut | ||
| 34 | |||
| 35 | sub new { | ||
| 36 | my $proto = shift; | ||
| 37 | my $class = ref($proto) || $proto; | ||
| 38 | my $self = { | ||
| 39 | LAT => undef, | ||
| 40 | LONG => undef, | ||
| 41 | }; | ||
| 42 | bless ($self, $class); | ||
| 43 | return $self; | ||
| 44 | } | ||
| 45 | |||
| 46 | |||
| 47 | =item C<latitude()> | ||
| 48 | |||
| 49 | A method to set or retrieve the latitude. To set the latitude, supply a decimal degree argument. | ||
| 50 | |||
| 51 | =cut | ||
| 52 | |||
| 53 | sub latitude { | ||
| 54 | my $self = shift; | ||
| 55 | if (@_) { $self->{LAT} = shift } | ||
| 56 | return $self->{LAT}; | ||
| 57 | } | ||
| 58 | |||
| 59 | =item C<longitude()> | ||
| 60 | |||
| 61 | As C<latitude()>, but instead sets or retrieves the longitude. | ||
| 62 | |||
| 63 | =cut | ||
| 64 | |||
| 65 | sub longitude { | ||
| 66 | my $self = shift; | ||
| 67 | if (@_) { $self->{LONG} = shift } | ||
| 68 | return $self->{LONG}; | ||
| 69 | } | ||
| 70 | |||
| 71 | 1; | ||
| 72 | __END__ |