2.1.10 • Published 7 years ago

polyline-coordinates v2.1.10

Weekly downloads
63
License
MIT
Repository
github
Last release
7 years ago

Polyline

Build Status npm version codecov

Simple utility library for dealing with JSON polylines

Installation

To use with a module bundler like webpack:

npm install --save polyline-coordinates

Usage

const Polyline = require('polyline-coordinates');

// the polyline needs to be an array of [latitude, longitude] values
const polyline = Polyline.createLine([[34.028337, -118.259954], [37.773566, -122.412786]])

polyline.getLengthInMiles()
// 347.618 miles

polyline.getLengthInKm()
// 559.43555212 km

polyline.getPointCovering(0.5);
// [35.91355, 120.33155]

API

Polyline.createLine(geojson)

Creates a new polyline instance with the json representation of a polyline.

Polyline.getDistanceBetweenPoints(start, end)

Returns the distance in miles between two coordinates.

Polyline.getDistanceBetweenPointsKm(start, end)

Returns the distance in kilometers between two coordinates.

.getLengthInMiles()

Returns the total distance covered by the polyline in miles.

.getLengthInKm()

Returns the total distance covered by the polyline in kilometers.

.getPointCovering(percent)

Returns the coordinate of the point that covers the percentage of the polyline specified.

For example .getPointCovering(0.5) will return the coordinates of the point that is located in the middle of the polyline.

2.1.10

7 years ago

2.1.9

7 years ago

2.1.8

7 years ago

2.1.7

7 years ago

2.1.6

7 years ago

2.1.5

7 years ago

2.1.2

7 years ago

2.1.1

7 years ago

2.1.0

7 years ago

2.0.2

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.1.0

8 years ago

1.0.10

8 years ago

1.0.9

8 years ago

1.0.8

8 years ago

1.0.7

8 years ago

1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago