=head1 NAME

Geo::Shape - base class for 2-dimensional points on the earth surface

=head1 INHERITANCE

 Geo::Shape is extended by
   Geo::Line
   Geo::Point
   Geo::Space
   Geo::Surface

=head1 SYNOPSIS

 use Geo::Shape;

 my $p1 = Geo::Point->new(lat => 2.17, ...);
 my $p2 = Geo::Point->latlong(2.17, 3.14);   # wgs84 is default

 my $p3 = $p1->in('wgs84');                  # conversion
 my $p4 = $p1->in('utm');                    # conversion

=head1 DESCRIPTION

Base class for the many geo-spatial objects defined by the GeoPoint
distribution.

=head1 METHODS

=head2 Constructors

Geo::Shape-E<gt>B<new>(OPTIONS)

=over 4

Create a new object.

 Option--Default
 proj    <see Geo::Proj::defaultProjection()

. proj => LABEL

=back

=head2 Attributes

$obj-E<gt>B<proj>

=over 4

Returns the nick of the projection used by the component.

=back

=head2 Projections

$obj-E<gt>B<in>(LABEL|'utm')

=over 4

The coordinates of this point in a certain projection, refered to with
the LABEL.  The projection is defined with L<new()|Geo::Shape/"Constructors">.  When simply
'utm' is provided, the best UTM zone is selected.

In LIST context, the coordinates are returned.  In SCALAR context,
a new object is returned.

example: 

  my $gp       = Geo::Point->latlong(1,2);

  # implicit conversion to wgs84, if not already in latlong
  my ($lat, $long) = $pr->latlong;

  # will select an utm zone for you
  my $p_utm    = $gp->in('utm');
  my ($x, $y)  = $p_utm->xy;
  my $label    = $p_utm->proj;
  my ($datum, $zone) = $label =~ m/^utm-(\w+)-(\d+)$/;

=back

$obj-E<gt>B<projectOn>(NICK, POINTS)

=over 4

The POINTS are ARRAYS with each an X and Y coordinate of a single
point in space.  A list of transformed POINTS is returned, which is empty
if no change is needed.  The return list is preceeded by a projection
NICK which is the result, usually the same as the provided NICK, but in
some cases (for instance UTM) it may be different.

=back

=head2 Geometry

$obj-E<gt>B<area>

=over 4

Returns the area covered by the geo structure. Points will return zero.

=back

$obj-E<gt>B<bbox>

=over 4

Returns the bounding box of the object as four coordinates, respectively
xmin, ymin, xmax, ymax.  The values are expressed in the coordinate
system of the object.

=back

$obj-E<gt>B<bboxCenter>

=over 4

Returns a L<Geo::Point|Geo::Point> which represent the middle of the object.  It is
the center of the bounding box.  The values is cached, once computed.

Be warned that the central point in one projection system may be quite
different from the central point in some other projectionsystem .

=back

$obj-E<gt>B<bboxRing>([XMIN, YMIN, XMAX, YMAX, [PROJ]])

Geo::Shape-E<gt>B<bboxRing>([XMIN, YMIN, XMAX, YMAX, [PROJ]])

=over 4

Returns a L<Geo::Line|Geo::Line> which describes the outer bounds of the
object called upon, counter-clockwise and left-bottom first.  As class
method, you need to specify the limits and the PROJection.

=back

$obj-E<gt>B<distance>(OBJECT, [UNIT])

=over 4

Calculate the distance between this object and some other object.
For many combinations of objects this is not supported or only
partially supported.

This calculation is performed with L<Geo::Distance> in accurate mode.
The default UNIT is kilometers.  Other units are provided in the manual
page of L<Geo::Distance>.  As extra unit, C<degrees> and C<radians> are
added as well as the C<km> alias for kilometer.

=back

$obj-E<gt>B<equal>(OBJECT, [TOLERANCE])

=over 4

Same object, maybe defined as different object, maybe in a different
coordinate system.  When the coordinate systems are equivalent, no
conversions are done.  Otherwise, the second OBJECT is converted into
the coordinate system of the callee.

=back

$obj-E<gt>B<perimeter>

=over 4

Returns the length of the outer border of the object's components.  For
points, this returns zero.

=back

$obj-E<gt>B<sameAs>(OTHER, TOLERANCE)

=over 4

See L<equal()|Geo::Shape/"Geometry">.  This method expects the OTHER object to have the same
projection as the object at hand.

=back

=head2 Display

$obj-E<gt>B<deg2dm>(DEGREES, POS, NEG)

Geo::Shape-E<gt>B<deg2dm>(DEGREES, POS, NEG)

=over 4

Like L<deg2dms()|Geo::Shape/"Display"> but without showing seconds.

example: 

 print $point->deg2dm(0.12, 'e', 'w');
 print Geo::Shape->deg2dm(0.12, 'e', 'w');

=back

$obj-E<gt>B<deg2dms>(DEGREES, POS, NEG)

Geo::Shape-E<gt>B<deg2dms>(DEGREES, POS, NEG)

=over 4

example: 

 print $point->deg2dms(0.12, 'e', 'w');
 print Geo::Shape->deg2dms(0.12, 'e', 'w');

=back

$obj-E<gt>B<dms2deg>(DMS)

Geo::Shape-E<gt>B<dms2deg>(DMS)

=over 4

Accepts for instance 3d12'24.123, 3d12"E, 3.12314w, n2.14, s3d12",
-12d34, and returns floating point degrees.

=back

=head1 DIAGNOSTICS

Error: distance calculation not implemented between a $kind and a $kind

=over 4

Only a subset of all objects can be used in the distance calculation.
The limitation is purely caused by lack of time to implement this.

=back

Error: in() not implemented for a $class

=over 4

=back

=head1 SEE ALSO

This module is part of Geo-Point distribution version 0.08,
built on March 31, 2008. Website: F<http://perl.overmeer.net/geo/>

=head1 LICENSE

Copyrights 2005-2008 by Mark Overmeer. For other contributors see ChangeLog.

This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
See F<http://www.perl.com/perl/misc/Artistic.html>

