polyline

WebJar for polyline

License

License

BSD 3-Clause
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

polyline
Last Version

Last Version

0.2.0
Release Date

Release Date

Type

Type

jar
Description

Description

polyline
WebJar for polyline
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/mapbox/polyline

Download polyline

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/polyline/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>polyline</artifactId>
    <version>0.2.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/polyline/
implementation 'org.webjars.npm:polyline:0.2.0'
// https://jarcasting.com/artifacts/org.webjars.npm/polyline/
implementation ("org.webjars.npm:polyline:0.2.0")
'org.webjars.npm:polyline:jar:0.2.0'
<dependency org="org.webjars.npm" name="polyline" rev="0.2.0">
  <artifact name="polyline" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='polyline', version='0.2.0')
)
libraryDependencies += "org.webjars.npm" % "polyline" % "0.2.0"
[org.webjars.npm/polyline "0.2.0"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

Build Status codecov

polyline

A simple google-esque polyline implementation in Javascript. Compatible with nodejs (npm install @mapbox/polyline and the browser (copy src/polyline.js)).

Encodes from / decodes into [lat, lng] coordinate pairs. Use fromGeoJSON() to encode from GeoJSON objects, or toGeoJSON to decode to a GeoJSON LineString.

Installation

npm install @mapbox/polyline

Note that the old package polyline has been deprecated in favor of @mapbox/polyline (the old package remain but won't receive updates).

Example

var polyline = require('@mapbox/polyline');

// returns an array of lat, lon pairs
polyline.decode('_p~iF~ps|U_ulLnnqC_mqNvxq`@');

// returns an array of lat, lon pairs from polyline6 by passing a precision parameter
polyline.decode('cxl_cBqwvnS|Dy@ogFyxmAf`IsnA|CjFzCsHluD_k@hi@ljL', 6);

// returns a GeoJSON LineString feature
polyline.toGeoJSON('_p~iF~ps|U_ulLnnqC_mqNvxq`@');

// returns a string-encoded polyline (from coordinate ordered lat,lng)
polyline.encode([[38.5, -120.2], [40.7, -120.95], [43.252, -126.453]]);

// returns a string-encoded polyline from a GeoJSON LineString
polyline.fromGeoJSON({ "type": "Feature",
  "geometry": {
    "type": "LineString",
    "coordinates": [[-120.2, 38.5], [-120.95, 40.7], [-126.453, 43.252]]
  },
  "properties": {}
});

API Documentation

Command line

Install globally or run ./node_modules/.bin/polyline.

Send input via stdin and use --decode, --encode, --toGeoJSON, or --fromGeoJSON flags. If omitted will default to --decode.

Example :

cat file.json | ./bin/polyline.bin.js --fromGeoJSON > result.txt
org.webjars.npm

Mapbox

Mapbox is the location data platform for mobile and web applications. We're changing the way people move around cities and explore our world.

Versions

Version
0.2.0