Maps API for JavaScript Developer's Guide

H.geo.LineString

Class Summary

Extends: H.geo.AbstractGeometry

A LineString is a geometry of connected line segments in geographic space.

[ For full details, see the Class Details ]

Method Summary

Table 1. Methods
Methods

pushLatLngAlt (lat, lng, alt)

This method pushes a lat, lng, alt to the end of this LineString.

spliceLatLngAlts (index, opt_nRemove, opt_latLngAlts) : {Array<number>}

This method splices the LineString at the provided index, removing the specified number of items at that index and inserting the lat, lng, alt array.

insertLatLngAlt (index, lat, lng, alt)

This method inserts one set of lat, lng, alt values into the LineString at the specified index.

removeLatLngAlt (index)

This method removes one set of lat, lng, alt values from the LineString at the specified index.

pushPoint (geoPoint)

This method pushes the lat, lng, alt values of a H.geo.Point to the end of this LineString.

insertPoint (pointIndex, geoPoint)

This method inserts the lat, lng, alt values of a H.geo.Point into the list at the specified index.

removePoint (pointIndex)

This method removes one set of lat, lng, alt values from this LineString at the virtual point index specified.

extractPoint (pointIndex, opt_out) : {H.geo.Point}

This method extracts a H.geo.Point from this LineString at the virtual point index. If the extracted point has an alt value, the LineString's altitude context will be supplied to the point.

eachLatLngAlt (eachFn, opt_start, opt_end)

A utility method to iterate over the points of a line string.

static isDBC (lng1, lng2) : {boolean}

To obtain whether a leg (formed by the given two longitudes) crosses the International Date Line.

getDBCs (opt_asClosed) : {number}

To obtain the number of times that this LineString cross the International Date Line.

getPointCount () : {number}

This method return the number of points stored in this LineString.

getLatLngAltArray () : {Array<number>}

Returns the vertices of the line segments as an array of alternating latitude, longitude and altitude coordinates. The returned array must be treated as read-only to not violate the integrity of the line-string.

getBounds () : {?H.geo.Rect}

This method returns the bounding box of this LineString.

static fromLatLngArray (latLngs) : {H.geo.LineString}

This method initializes a new LineString with an array of lat, lng values. Arrays are expected to have an even length with the format [lat, lng, lat, lng, ...].

equals (other) : {boolean}

Checks whether the geometry is equal to the geometry supplied by the caller. Two geometries are considered as equal if they represent the same geometry type and have equal coordinate values.

toString () : {!string}

To obtain a Well-Known-Text (WKT) representation of the geometry.

Class Description

A LineString is a geometry of connected line segments in geographic space.

Constructor Details

H.geo.LineString(opt_latLngAlts, opt_ctx)

Parameters:
 
opt_latLngAlts:
{Array<number>=} [optional]
 
An optional array of latitude, longitude and altitude triples to initialize the LineString with.
opt_ctx:
{H.geo.AltitudeContext=} [optional]
 
An optional altitude context for all altitudes contained in this LineString.
Throws:
 
{H.lang.InvalidArgumentError}
 
in case of invalid lat, lng, alt values

Method Details

pushLatLngAlt (lat, lng, alt)

This method pushes a lat, lng, alt to the end of this LineString.

Parameters:
 
lat:
{H.geo.Latitude}
 
lng:
{H.geo.Longitude}
 
alt:
{H.geo.Altitude}
 
Throws:
 
{H.lang.InvalidArgumentError}
 
in case of invalid lat, lng, alt values

spliceLatLngAlts (index, opt_nRemove, opt_latLngAlts) : {Array<number>}

This method splices the LineString at the provided index, removing the specified number of items at that index and inserting the lat, lng, alt array.

Parameters:
 
index:
{number}
 
The index at which to splice
opt_nRemove:
{number=} [optional]
 
The number of lat, lng, alt values to remove
opt_latLngAlts:
{Array<number>=} [optional]
 
The lat, lng, alt values to add
Returns:
 
{Array<number>}
An array of removed elements
Throws:
 
{H.lang.InvalidArgumentError}
 
in case of invalid opt_latLngAlts argument

insertLatLngAlt (index, lat, lng, alt)

This method inserts one set of lat, lng, alt values into the LineString at the specified index.

Parameters:
 
index:
{number}
 
the index at which to add the element
lat:
{H.geo.Latitude}
 
the latitude to insert
lng:
{H.geo.Longitude}
 
the longitude to insert
alt:
{H.geo.Altitude}
 
the altitude to insert

removeLatLngAlt (index)

This method removes one set of lat, lng, alt values from the LineString at the specified index.

Parameters:
 
index:
{number}
 

pushPoint (geoPoint)

This method pushes the lat, lng, alt values of a H.geo.Point to the end of this LineString.

Parameters:
 
geoPoint:
{H.geo.IPoint}
 
Throws:
 
{H.lang.InvalidArgumentError}
 
in case of invalid geoPoint argument

insertPoint (pointIndex, geoPoint)

This method inserts the lat, lng, alt values of a H.geo.Point into the list at the specified index.

Parameters:
 
pointIndex:
{number}
 
geoPoint:
{H.geo.IPoint}
 

removePoint (pointIndex)

This method removes one set of lat, lng, alt values from this LineString at the virtual point index specified.

Parameters:
 
pointIndex:
{number}
 
the virtual point index

extractPoint (pointIndex, opt_out) : {H.geo.Point}

This method extracts a H.geo.Point from this LineString at the virtual point index. If the extracted point has an alt value, the LineString's altitude context will be supplied to the point.

Parameters:
 
pointIndex:
{number}
 
the virtual point index in the LineString
opt_out:
{H.geo.Point=} [optional]
 
an optional point object to store the lat, lng, alt values
Returns:
 
{H.geo.Point}
Returns either the 'opt_out' point object or a new point object.

eachLatLngAlt (eachFn, opt_start, opt_end)

A utility method to iterate over the points of a line string.

Example

// Log the coordinates for certain points of the line string:
function eachFn(lat, lng, alt, idx) {
  console.log("point %i (%f, %f, %f)", idx, lat, lng, alt);
}
myLineString.eachLatLngAlt(eachFn, 1, 3);
Parameters:
 
eachFn:
{function(H.geo.Latitude, H.geo.Longitude, H.geo.Altitude, number)}
 
The function to invoke for every point. It gets the point's latitude, longitude, altitude and index as arguments.
opt_start:
{number=} [optional]
 
The point's start index (inclusive) to iterate from, defaults to 0.
opt_end:
{number=} [optional]
 
The point's end index (exclusive) to iterate to, defaults to Infinity.

static isDBC (lng1, lng2) : {boolean}

To obtain whether a leg (formed by the given two longitudes) crosses the International Date Line.

Parameters:
 
lng1:
{H.geo.Longitude}
 
The start longitude of the leg
lng2:
{H.geo.Longitude}
 
The end longitude of the leg
Returns:
 
{boolean}

getDBCs (opt_asClosed) : {number}

To obtain the number of times that this LineString cross the International Date Line.

Parameters:
 
opt_asClosed:
{boolean=} [optional]
 
Indicates whether the LineString is treated as closed (the LineString's last and first coordinates form the closing leg of a polygon). It defaults to false.
Returns:
 
{number}

getPointCount () : {number}

This method return the number of points stored in this LineString.

Returns:
 
{number}
The number of points in this LineString

getLatLngAltArray () : {Array<number>}

Returns the vertices of the line segments as an array of alternating latitude, longitude and altitude coordinates. The returned array must be treated as read-only to not violate the integrity of the line-string.

Returns:
 
{Array<number>}
Returns the raw lat, lng, alt values of this LineString

getBounds () : {?H.geo.Rect}

This method returns the bounding box of this LineString.

Note: The LineString is treated as an open path. If the bounding rectangle for a closed shape is required, the closing leg must be merged in an extra step.

Returns:
 
{?H.geo.Rect}
This LineString's bounding rectangle

static fromLatLngArray (latLngs) : {H.geo.LineString}

This method initializes a new LineString with an array of lat, lng values. Arrays are expected to have an even length with the format [lat, lng, lat, lng, ...].

Parameters:
 
latLngs:
{Array<number>}
 
the array of lat, lng value.
Returns:
 
{H.geo.LineString}
The LineString containing the lat, lng values
Throws:
 
{H.lang.InvalidArgumentError}
 
throws an error in case the latLngs array has an odd length

equals (other) : {boolean}

Checks whether the geometry is equal to the geometry supplied by the caller. Two geometries are considered as equal if they represent the same geometry type and have equal coordinate values.

Parameters:
 
other:
{*}
 
The geometry to check against
Returns:
 
{boolean}
true if the two geometries are equal, otherwise false

toString () : {!string}

To obtain a Well-Known-Text (WKT) representation of the geometry.

Returns:
 
{!string}
the resulting WKT string

You cannot use this account to purchase a commercial plan on Developer Portal, as it is already associated to plans with different payment methods.

To purchase a commercial plan on Developer Portal, please register for or sign in with a different HERE Account.

Something took longer than expected.

The project should be available soon under your projects page.

Sorry, our services are not available in this region.

Something seems to have gone wrong. Please try again later.

We've detected that your account is set to Australian Dollars (AUD).
Unfortunately, we do not offer checkouts in AUD anymore.
You can continue using your current plan as normal, but to subscribe to one of our new plans,
please register for a new HERE account or contact us for billing questions on selfservesupport@here.com.