View on
Mark Overmeer > Geo-Point-0.94 > Geo::Line



Annotate this POD


Open  1
View/Report Bugs
Module Version: 0.94   Source   Latest Release: Geo-Point-0.96


Geo::Line - a sequence of connected points


   is a Geo::Shape

   is a Math::Polygon


 my $line  = Geo::Line->new(points => [$p1, $p2]);
 my $line  = Geo::Line->line($p1, $p2);

 my $ring  = Geo::Line->ring($p1, $p2, $p3, $p1);
 my $ring  = Geo::Line->ring($p1, $p2, $p3);

 my $plane = Geo::Line->filled($p1, $p2, $p3, $p1);
 my $plane = Geo::Line->filled($p1, $p2, $p3);


A 2-dimensional sequence of connected points. The points will be forced to use the same projection.



Geo::Line->bboxFromString(STRING, {PROJECTION])

Create a square from the STRING. The coordinates can be separated by a comma (preferrably), or blanks. When the coordinates end on NSEW, the order does not matter, otherwise lat-long or xy order is presumed.

This routine is very smart. It understands PROJLABEL: <4 coordinates in any order, but with NSEW> ...

example: bbox from string

 my $x = '5n 2n 3e e12';       # coordinates in any order
 my $x = '5e , 2n, 3n, e12';   # coordinates in any order
 my $x = '2.12-23.1E, N1-4';   # stretches
 my $x = 'wgs84: 2-5e, 1-8n';  # starts with projection
 my $x = 'wgs84: e2d12' -3d, n1, n7d12'34"';

 my ($xmin, $ymin, $xmax, $ymax, $proj)
    = Geo::Line->bboxFromString($x);

 my $p = Geo::Line->ringFromString($x);

 # When parsing user applications, you probably want:
 my $p = eval { Geo::Line->bboxFromString($x) };
 warn $@ if $@;
$obj->filled(POINTS, OPTIONS)
Geo::Line->filled(POINTS, OPTIONS)

The POINTS form a ring() and the filled is part of the geometrical shape.

$obj->line(POINTS, OPTIONS)
Geo::Line->line(POINTS, OPTIONS)

construct a line, which will probably not have the same begin and end point. The POINTS are passed as new(points), and the other OPTIONS are passed to new() as well.

$obj->new([OPTIONS], [POINTS], [OPTIONS])
Geo::Line->new([OPTIONS], [POINTS], [OPTIONS])

When called as instance method, the projection, ring, and filled attributes are taken from the initiator, like a clone with modification.

 -Option   --Defined in     --Default
  bbox       Math::Polygon    undef
  clockwise  Math::Polygon    undef
  filled                      <false>
  points                      <data>
  proj       Geo::Shape       see Geo::Proj::defaultProjection()
  ring                        <false>
bbox => ARRAY
clockwise => BOOLEAN
filled => BOOLEAN

Implies ring. The filled of the ring is included in the geometrical shape.


With this option, you can specify either Geo::Point objects, or coordinate pairs which will get transformed into such objects. WARNING: in that case, the coordinates must be in xy order.

proj => LABEL
ring => BOOLEAN

The first point is the last point. When specified, you have to make sure that this is the case. If ring() is used to create this object, that routine will check/repair it for you.


 my $point = Geo::Point->xy(1, 2);
 my $line  = Geo::Line->new
   ( points => [$point, [3,4], [5,6], $point]
   , ring   => 1
$obj->ring(POINTS, OPTIONS)
Geo::Line->ring(POINTS, OPTIONS)

The first and last point will be made the same: if not yet, than a reference to the first point is appended to the list. A "ring" does not cover the internal.

Geo::Line->ringFromString(STRING, [PROJECTION])

Calls bboxFromString() and then produces a ring object from than. Don't forget the eval when you call this method.


$obj->geopoint(INDEX, [INDEX, ..])

Returns the Geo::Point for the point with the specified INDEX or indices.


In LIST context, this returns all points as separate scalars: each is a Geo::Point with projection information. In SCALAR context, a reference to the coordinates is returned.

With points(), you get arrays with XY coordinates returned, but without the projection information. That will be much faster, but not sufficient for some uses.


Returns a true value is the internals of the ring of points are declared to belong to the shape.


Returns a true value if the sequence of points are a ring or filled: the first point is the last.


See "Attributes" in Math::Polygon


See "Attributes" in Math::Polygon

$obj->point(INDEX, [INDEX, ...])

See "Attributes" in Math::Polygon


See "Attributes" in Math::Polygon


See "Attributes" in Geo::Shape


See "Attributes" in Geo::Shape



See "Projections" in Geo::Shape

$obj->projectOn(NICK, POINTS)

See "Projections" in Geo::Shape



Returns the area enclosed by the polygon. Only useful when the points are in some orthogonal projection.


The bounding box coordinates. These are more useful for rings than for open line pieces.


See "Geometry" in Geo::Shape

$obj->bboxRing([XMIN, YMIN, XMAX, YMAX, [PROJ]])
Geo::Line->bboxRing([XMIN, YMIN, XMAX, YMAX, [PROJ]])

See "Geometry" in Geo::Shape


See "Geometry" in Math::Polygon


See "Geometry" in Math::Polygon


Clip the shape to the bounding box of OBJECT, or the boxing parameters specified. A list of Geo::Line objects is returned if anything is inside the object.

On the moment Math::Polygon::lineClip() and Math::Polygon::fillClip1() are used to do the job. In the future, that may change.


See "Geometry" in Math::Polygon


See "Geometry" in Math::Polygon


See "Geometry" in Math::Polygon

$obj->distance(OBJECT, [UNIT])

See "Geometry" in Geo::Shape


See "Geometry" in Math::Polygon


See "Geometry" in Math::Polygon


See "Geometry" in Math::Polygon


The length of the line, only useful in a orthogonal coordinate system (projection). See also perimeter().


The length of the line on the ring. A check is performed that the ring is closed, but further this returns the result of length()


See "Geometry" in Math::Polygon


See "Geometry" in Math::Polygon



See "Transformations" in Math::Polygon


See "Transformations" in Math::Polygon


See "Transformations" in Math::Polygon


See "Transformations" in Math::Polygon


See "Transformations" in Math::Polygon


See "Transformations" in Math::Polygon



See "Clipping" in Math::Polygon


See "Clipping" in Math::Polygon


$obj->deg2dm(DEGREES, POS, NEG)
Geo::Line->deg2dm(DEGREES, POS, NEG)

See "Display" in Geo::Shape

$obj->deg2dms(DEGREES, POS, NEG)
Geo::Line->deg2dms(DEGREES, POS, NEG)

See "Display" in Geo::Shape


See "Display" in Geo::Shape


Returns a string representation of the line, which is also used for stringification.



overload: '""' (stringification)()

See "OVERLOAD" in Geo::Shape

overload: 'bool' (truth value)()

See "OVERLOAD" in Geo::Shape


Error: area requires a ring of points

If you think you have a ring of points (a polygon), than do specify that when that object is instantiated (ring() or new(ring)).

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

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.

Error: in() not implemented for a $class
Error: perimeter requires a ring of points


This module is part of Geo-Point distribution version 0.94, built on December 21, 2012. Website: All modules in this suite: "Geo::Point", "Geo::Proj4", "Geo::WKT", "Math::Polygon", "Geo::GML", "Geo::ISO19139", "Geo::EOP", "Geo::Format::Envisat", and "Geo::Format::Landsat".

Please post questions or ideas to the mailinglist at


Copyrights 2005-2012 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

syntax highlighting: