compute-distance
Advanced tools
+2
-2
@@ -66,4 +66,4 @@ var sgeo = require('sgeo'); | ||
| filter: defaultFilter, | ||
| mapToGoogle: getCoordinates, | ||
| computeDistance: computeDistance | ||
| map: getCoordinates, | ||
| compute: computeDistance | ||
| }; |
+1
-1
| { | ||
| "name": "compute-distance", | ||
| "version": "0.0.3", | ||
| "version": "0.0.4", | ||
| "author": "Daniel Sauble", | ||
@@ -5,0 +5,0 @@ "description": "Find the distance represented by a set of points, filter if necessary", |
+12
-22
| Find the distance associated with an array of geospatial coordinates. | ||
| There are three methods associated with this library. Each takes an `options` | ||
| param, where you can pass your Google Maps API object (using [this | ||
| library](https://www.npmjs.com/package/google-maps), for example). | ||
| There are three methods associated with this library: | ||
| **filter(data, options)** | ||
| **filter(data)** | ||
@@ -21,5 +19,6 @@ A filter designed to smooth abberations from a GPS trace. It discards | ||
| **mapToGoogle(data, options)** | ||
| **map(data)** | ||
| Take an array of coordinates and convert them to google.maps.LatLng objects. | ||
| Take an array of coordinates and convert them to | ||
| [sgeo](https://www.npmjs.com/package/sgeo) objects. | ||
@@ -33,27 +32,18 @@ Each object in the array should have the following attributes set: | ||
| **computeDistance(data, options)** | ||
| **computeDistance(data)** | ||
| Take an array of `google.maps.LatLng` objects and compute the distance they | ||
| represent in meters. | ||
| Take an array of [sgeo](https://www.npmjs.com/package/sgeo) objects and compute | ||
| the distance they represent in meters. | ||
| ## Usage | ||
| This library depends on the Google Maps Javascript API, so be sure to include it | ||
| using the directions on [this page](https://developers.google.com/maps/documentation/javascript/). | ||
| To filter a set of data before computing distance, use the following code: | ||
| var Distance = require('compute-distance'); | ||
| var GoogleMapsLoader = require('google-maps'); | ||
| GoogleMapsLoader.KEY = 'your-api-key'; | ||
| GoogleMapsLoader.LIBRARIES = ['geometry']; | ||
| GoogleMapsLoader.load(function(google) { | ||
| var options = { google: google }; | ||
| var filtered = Distance.filter(data, options); // data is an array of coordinates | ||
| var points = Distance.mapToGoogle(filtered, options); | ||
| var distance = Distance.computeDistance(points, options); | ||
| }; | ||
| var filtered = Distance.filter(data); // data is an array of coordinates | ||
| var points = Distance.map(filtered); | ||
| var distance = Distance.computeDistance(points); | ||
| To compute distance on a raw dataset, without filtering, pass your raw data to | ||
| `mapToGoogle` directly, instead of passing it through `filter` first. | ||
| `map` directly, instead of passing it through `filter` first. |
+6
-6
@@ -67,4 +67,4 @@ (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
| filter: defaultFilter, | ||
| mapToGoogle: getCoordinates, | ||
| computeDistance: computeDistance | ||
| map: getCoordinates, | ||
| compute: computeDistance | ||
| }; | ||
@@ -753,7 +753,7 @@ | ||
| var raw = Distance.mapToGoogle(data); | ||
| var civilized = Distance.mapToGoogle(filtered); | ||
| var raw = Distance.map(data); | ||
| var civilized = Distance.map(filtered); | ||
| var rawDistance = Distance.computeDistance(raw); | ||
| var filteredDistance = Distance.computeDistance(civilized); | ||
| var rawDistance = Distance.compute(raw); | ||
| var filteredDistance = Distance.compute(civilized); | ||
@@ -760,0 +760,0 @@ assert.equal(rawDistance, 103.89499999999998, 'Passed!'); |
+4
-4
@@ -6,7 +6,7 @@ var Distance = require('../index'); | ||
| var raw = Distance.mapToGoogle(data); | ||
| var civilized = Distance.mapToGoogle(filtered); | ||
| var raw = Distance.map(data); | ||
| var civilized = Distance.map(filtered); | ||
| var rawDistance = Distance.computeDistance(raw); | ||
| var filteredDistance = Distance.computeDistance(civilized); | ||
| var rawDistance = Distance.compute(raw); | ||
| var filteredDistance = Distance.compute(civilized); | ||
@@ -13,0 +13,0 @@ assert.equal(rawDistance, 103.89499999999998, 'Passed!'); |
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
47043
-1.48%48
-17.24%