Quick Navigator

 Search Site Miscellaneous Server Agreement Year 2038 Credits

# Manual Reference Pages  -  GEO::LINE (3)

.ds Aq ’

### NAME

Geo::Line - a sequence of connected points

### INHERITANCE

```

Geo::Line
is a Geo::Shape

Geo::Line
is a Math::Polygon

```

### SYNOPSIS

```

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);

```

### DESCRIPTION

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

Extends DESCRIPTION in Math::Polygon.

Extends DESCRIPTION in Geo::Shape.

### METHODS

Extends METHODS in Math::Polygon.

Extends METHODS in Geo::Shape.

#### Constructors

Extends Constructors in Math::Polygon.

Extends Constructors in Geo::Shape.
Geo::Line-><B>bboxFromStringB>(\$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, n7d1234";

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-><B>filledB>(\$points, %options)
Geo::Line-><B>filledB>(\$points, %options) The \$points form a ring() and the filled is part of the geometrical shape.
\$obj-><B>lineB>(\$points, %options)
Geo::Line-><B>lineB>(\$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-><B>newB>([%options])
Geo::Line-><B>newB>([%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.
points => ARRAY-OF-POINTS|ARRAY-OF-COORDINATES 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.

example:

```

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

```
\$obj-><B>ringB>(\$points, %options)
Geo::Line-><B>ringB>(\$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-><B>ringFromStringB>(\$string, [\$projection]) Calls bboxFromString() and then produces a ring object from than. Don’t forget the eval when you call this method.

#### Attributes

Extends Attributes in Math::Polygon.

Extends Attributes in Geo::Shape.
\$obj-><B>geopointB>(\$index, [\$index, ..]) Returns the Geo::Point for the point with the specified \$index or indices.
\$obj-><B>geopointsB>() 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.

\$obj-><B>isFilledB>() Returns a true value is the internals of the ring of points are declared to belong to the shape.
\$obj-><B>isRingB>() Returns a true value if the sequence of points are a ring or filled: the first point is the last.
\$obj-><B>nrPointsB>() Inherited, see Attributes in Math::Polygon
\$obj-><B>orderB>() Inherited, see Attributes in Math::Polygon
\$obj-><B>pointB>(\$index, [\$index,...]) Inherited, see Attributes in Math::Polygon
\$obj-><B>pointsB>() Inherited, see Attributes in Math::Polygon
\$obj-><B>projB>() Inherited, see Attributes in Geo::Shape
\$obj-><B>proj4B>() Inherited, see Attributes in Geo::Shape

#### Projections

Extends Projections in Geo::Shape.
\$obj-><B>inB>(<\$label|’utm’>) Inherited, see Projections in Geo::Shape
\$obj-><B>projectOnB>(\$nick, @points) Inherited, see Projections in Geo::Shape

#### Geometry

Extends Geometry in Math::Polygon.

Extends Geometry in Geo::Shape.
\$obj-><B>areaB>() Returns the area enclosed by the polygon. Only useful when the points are in some orthogonal projection.
\$obj-><B>bboxB>() The bounding box coordinates. These are more useful for rings than for open line pieces.
\$obj-><B>bboxCenterB>() Inherited, see Geometry in Geo::Shape
\$obj-><B>bboxRingB>([\$xmin, \$ymin, \$xmax, \$ymax, [\$proj]])
Geo::Line-><B>bboxRingB>([\$xmin, \$ymin, \$xmax, \$ymax, [\$proj]]) Inherited, see Geometry in Geo::Shape
\$obj-><B>beautifyB>(%options) Inherited, see Geometry in Math::Polygon
\$obj-><B>centroidB>() Inherited, see Geometry in Math::Polygon
\$obj-><B>clipB>(<\$xmin,\$xmax,\$ymin,\$ymax>|\$object) 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.

\$obj-><B>clockwiseB>() Inherited, see Geometry in Math::Polygon
\$obj-><B>containsB>(\$point) Inherited, see Geometry in Math::Polygon
\$obj-><B>counterClockwiseB>() Inherited, see Geometry in Math::Polygon
\$obj-><B>distanceB>(\$object, [\$unit]) Inherited, see Geometry in Geo::Shape
\$obj-><B>equalB>(<\$other | ARRAY,[\$tolerance]> | \$points) Inherited, see Geometry in Math::Polygon
\$obj-><B>isClockwiseB>() Inherited, see Geometry in Math::Polygon
\$obj-><B>isClosedB>() Inherited, see Geometry in Math::Polygon
\$obj-><B>lengthB>() The length of the line, only useful in a orthogonal coordinate system (projection). See also perimeter().
\$obj-><B>perimeterB>() 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()
\$obj-><B>sameB>(<\$other | ARRAY,[\$tolerance]> | \$points) Inherited, see Geometry in Math::Polygon
\$obj-><B>startMinXYB>() Inherited, see Geometry in Math::Polygon

#### Transformations

Extends Transformations in Math::Polygon.
\$obj-><B>gridB>(%options) Inherited, see Transformations in Math::Polygon
\$obj-><B>mirrorB>(%options) Inherited, see Transformations in Math::Polygon
\$obj-><B>moveB>(%options) Inherited, see Transformations in Math::Polygon
\$obj-><B>resizeB>(%options) Inherited, see Transformations in Math::Polygon
\$obj-><B>rotateB>(%options) Inherited, see Transformations in Math::Polygon
\$obj-><B>simplifyB>(%options) Inherited, see Transformations in Math::Polygon

#### Clipping

Extends Clipping in Math::Polygon.
\$obj-><B>fillClip1B>(\$box) Inherited, see Clipping in Math::Polygon
\$obj-><B>lineClipB>(\$box) Inherited, see Clipping in Math::Polygon

#### Display

Extends Display in Math::Polygon.

Extends Display in Geo::Shape.
\$obj-><B>deg2dmB>(\$degrees, \$pos, \$neg)
Geo::Line-><B>deg2dmB>(\$degrees, \$pos, \$neg) Inherited, see Display in Geo::Shape
\$obj-><B>deg2dmsB>(\$degrees, \$pos, \$neg)
Geo::Line-><B>deg2dmsB>(\$degrees, \$pos, \$neg) Inherited, see Display in Geo::Shape
\$obj-><B>dms2degB>(\$dms)
Geo::Line-><B>dms2degB>(\$dms) Inherited, see Display in Geo::Shape
\$obj-><B>stringB>() Inherited, see Display in Math::Polygon
\$obj-><B>toStringB>([\$projection]) Returns a string representation of the line, which is also used for stringification. The old method named string is deprecated.

### DIAGNOSTICS

 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.96, built on January 21, 2014. Website: http://perl.overmeer.net/geo/ 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 geo-perl@list.hut.fi">http://geo-perl@list.hut.fi