A LineString is a geometry of connected line segments in geographic space.
| Name | Type | Description |
|---|---|---|
opt_latLngAlts |
Array.<number> |
optional
An optional array of latitude, longitude and altitude triples to initialize the LineString with. |
Throws:
-
in case of invalid lat, lng, alt values
Examples
Polygon on the map
Polyline on the map
Extends
Methods
-
H.geo.LineString.fromFlexiblePolyline (encodedPolyline)H.geo.LineString static
-
Decodes the specified Flexible Polyline and converts it to the
LineString.Name Type Description encodedPolylinestring Throws:
-
-
If the specified data has an invalid encoding.
- Type
- Error
-
-
-
If the third dimension type is other then
ABSENTorALTITUDE.
-
Returns:
Type Description H.geo.LineString -
-
H.geo.LineString.fromLatLngArray (latLngs)H.geo.LineString static
-
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, ...].Name Type Description latLngsArray.<number> the array of lat, lng value.
Throws:
-
throws an error in case the latLngs array has an odd length
Returns:
Type Description H.geo.LineString The LineString containing the lat, lng values -
-
To obtain whether a leg (formed by the given two longitudes) crosses the International Date Line.
Name Type Description lng1H.geo.Longitude The start longitude of the leg
lng2H.geo.Longitude The end longitude of the leg
Returns:
Type Description boolean -
A utility method to iterate over the points of a line string.
Name Type Description eachFnfunction(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_startnumber optional The point's start index (inclusive) to iterate from, defaults to
0.opt_endnumber optional The point's end index (exclusive) to iterate to, defaults to
Infinity.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); -
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.
Name Type Description other* The geometry to check against
Returns:
Type Description boolean trueif the two geometries are equal, otherwisefalse -
extractPoint (pointIndex, opt_out)H.geo.Point
-
This method extracts a
H.geo.Pointfrom 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.Name Type Description pointIndexnumber the virtual point index in the LineString
opt_outH.geo.Point optional an optional point object to store the lat, lng, alt values
Returns:
Type Description H.geo.Point Returns either the 'opt_out' point object or a new point object. -
getBoundingBox ()H.geo.Rect inherited overrides
-
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:
Type Description H.geo.Rect the bounding rectangle of the geometry or nullif the bounding rectangle can't be computed (e.g. for a geometry without coordinates) -
To obtain the number of times that this LineString cross the International Date Line.
Name Type Description opt_asClosedboolean 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:
Type Description 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:
Type Description Array.<number> Returns the raw lat, lng, alt values of this LineString -
This method return the number of points stored in this LineString.
Returns:
Type Description number The number of points in this LineString -
This method inserts one set of lat, lng, alt values into the LineString at the specified index.
Name Type Description indexnumber the index at which to add the element
latH.geo.Latitude the latitude to insert
lngH.geo.Longitude the longitude to insert
altH.geo.Altitude the altitude to insert
-
This method inserts the lat, lng, alt values of a
H.geo.Pointinto the list at the specified index.Name Type Description pointIndexnumber geoPointH.geo.IPoint -
This method pushes a lat, lng, alt to the end of this LineString.
Name Type Description latH.geo.Latitude lngH.geo.Longitude altH.geo.Altitude | undefined Throws:
-
-
in case of invalid lat, lng, alt values
-
-
-
in case of invalid lat, lng, alt values
-
-
-
This method pushes the lat, lng, alt values of a
H.geo.Pointto the end of this LineString.Name Type Description geoPointH.geo.IPoint Throws:
-
in case of invalid geoPoint argument
-
-
This method removes one set of lat, lng, alt values from the LineString at the specified index.
Name Type Description indexnumber -
This method removes one set of lat, lng, alt values from this LineString at the virtual point index specified.
Name Type Description pointIndexnumber the virtual point index
-
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.
Name Type Description indexnumber The index at which to splice
opt_nRemovenumber optional The number of lat, lng, alt values to remove
opt_latLngAltsArray.<number> optional The lat, lng, alt values to add
Throws:
-
in case of invalid opt_latLngAlts argument
Returns:
Type Description Array.<number> An array of removed elements -
-
To obtain a Flexible Polyline encoded representation of the geometry.
Name Type Default Description precisionnumber 5 optional How many decimal digits of precision to store the values, default is
5.Returns:
Type Description string the resulting encoded string. -
toGeoJSON ()Object inherited
-
To obtain a GeoJSON representation of the given geometry.
Returns:
Type Description Object A GeoJSON Geometry object representing the given geometry. -
toString () inherited
-
To obtain a Well-Known-Text (WKT) representation of the geometry.