Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

turf-along

Package Overview
Dependencies
Maintainers
7
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

turf-along - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

2

bench.js

@@ -41,3 +41,3 @@ var along = require('./');

var suite = new Benchmark.Suite('turf-distance');
var suite = new Benchmark.Suite('turf-along');
suite

@@ -44,0 +44,0 @@ .add('turf-along',function () {

@@ -7,47 +7,23 @@ var distance = require('turf-distance');

/**
Returns a point at a specified distance along a line.
@module turf/along
@param {LineString} Line to move along
@param {Number} Distance to move
@param {String} [units=miles] can be degrees, radians, miles, or kilometers
@return {Point} Point along the line at X distance
@example
var line = {
"type": "Feature",
"properties": {},
"geometry": {
"type": "LineString",
"coordinates": [
[
-77.0316696166992,
38.878605901789236
],
[
-77.02960968017578,
38.88194668656296
],
[
-77.02033996582031,
38.88408470638821
],
[
-77.02566146850586,
38.885821800123196
],
[
-77.02188491821289,
38.88956308852534
],
[
-77.01982498168944,
38.89236892551996
]
]
}
}
var along = turf.along(line, 1, 'miles');
//=along
*/
* Takes a {@link LineString} feature and returns a {@link Point} feature at a specified distance along a line.
*
* @module turf/along
* @param {LineString} line a LineString feature
* @param {Number} distance distance along the line
* @param {String} [units=miles] can be degrees, radians, miles, or kilometers
* @return {Point} Point along the line at `distance` distance
* @example
* var line = turf.linestring([
* [-77.031669, 38.878605],
* [-77.029609, 38.881946],
* [-77.020339, 38.884084],
* [-77.025661, 38.885821],
* [-77.021884, 38.889563],
* [-77.019824, 38.892368]
* ]);
*
* var along = turf.along(line, 1, 'miles');
*
* //=along
*/
module.exports = function (line, dist, units) {

@@ -60,4 +36,5 @@ var coords;

var travelled = 0;
for(var i = 0; i < coords.length - 1; i++) {
if(travelled >= dist) {
for(var i = 0; i < coords.length; i++) {
if (dist >= travelled && i === coords.length - 1) break;
else if(travelled >= dist) {
var overshot = dist - travelled;

@@ -76,2 +53,2 @@ if(!overshot) return point(coords[i]);

return point(coords[coords.length - 1]);
}
}
{
"name": "turf-along",
"version": "1.0.0",
"version": "1.0.1",
"description": "",
"main": "index.js",
"scripts": {
"test": "node test.js"
"test": "node test.js",
"doc": "dox -r < index.js | doxme --readme > README.md"
},

@@ -29,10 +30,12 @@ "repository": {

"tape": "^3.4.0",
"turf-featurecollection": "^1.0.0"
"turf-featurecollection": "^1.0.0",
"dox": "^0.6.1",
"doxme": "^1.4.2"
},
"dependencies": {
"turf-bearing": "^1.0.0",
"turf-destination": "^1.0.0",
"turf-destination": "^1.2.0",
"turf-distance": "^1.0.0",
"turf-point": "^1.2.1"
"turf-point": "^2.0.0"
}
}

@@ -1,30 +0,25 @@

turf-along
---
[![Build Status](https://travis-ci.org/Turfjs/turf-along.svg?branch=master)](https://travis-ci.org/Turfjs/turf-along)
# turf-along
[![build status](https://secure.travis-ci.org/Turfjs/turf-along.png)](http://travis-ci.org/Turfjs/turf-along)
### `turf.along(Line, Distance, [units=miles])`
Returns a point at a specified distance along a line.
###Install
```sh
npm install turf-along
```
### Parameters
###Parameters
| parameter | type | description |
| --------------- | ---------- | --------------------------------------------------------- |
| `Line` | LineString | to move along |
| `Distance` | Number | to move |
| `[units=miles]` | String | _optional:_ can be degrees, radians, miles, or kilometers |
|name|description|
|---|---|
|line|LineString feature or geometry|
|distance|distance to move|
|units|'miles', 'kilometers', 'degrees' or 'radians'|
###Usage
### Example
```js
along(line, distance, units)
```
###Example
```javascript
var line = {

@@ -64,3 +59,19 @@ "type": "Feature",

console.log(turf.along(line, 1, 'miles'));
var along = turf.along(line, 1, 'miles');
//=along
```
## Installation
Requires [nodejs](http://nodejs.org/).
```sh
$ npm install turf-along
```
## Tests
```sh
$ npm test
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc