Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. gps-distance
  2. ============
  3. [![NPM](https://nodei.co/npm/gps-distance.png)](https://nodei.co/npm/gps-distance/)
  4. A node module for performing distance calculations between GPS coordinates
  5. Installation
  6. ------------
  7. ```
  8. npm install gps-distance
  9. ```
  10. Examples
  11. ========
  12. `gps-distance` supports two syntaxes for convenience. You can measure just between two points and supply in your GPS coordinates as direct arguments to distance in the form `(source_lat, source_lon, destination_lat, destination_lon)`, or you can use an array of points each in `[lat,lon]` format. See the examples below.
  13. Point to Point
  14. --------------
  15. ```javascript
  16. var distance = require('gps-distance');
  17. // Measure between two points:
  18. var result = distance(45.527517, -122.718766, 45.373373, -121.693604);
  19. // result is 81.78450202539503
  20. ```
  21. Array of GPS points
  22. -------------------
  23. ```javascript
  24. // Measure a list of GPS points along a path:
  25. var path = [
  26. [45.527517, -122.718766],
  27. [45.373373, -121.693604],
  28. [45.527517, -122.718766]
  29. ];
  30. var result2 = distance(path);
  31. // result2 is 163.56900405079006
  32. ```
  33. Measuring Distance From a .GPX File
  34. -----------------------------------
  35. To compute the distance travelled in a tracked GPX file, use `gps-distance` with the `gpx-stream` module ( http://npmjs.org/package/gpx-stream/ ).
  36. ```javascript
  37. var GPXstream = require('gpx-stream');
  38. var distance = require('gps-distance');
  39. var points = new GPXstream();
  40. var source = fs.createReadStream('./marathon.gpx');
  41. var path = [];
  42. source.pipe(points);
  43. points.on('readable', function() {
  44. var point;
  45. while(point = points.read()) {
  46. path.push([point.lat, point.lon]);
  47. }
  48. });
  49. points.on('end', function() {
  50. console.log('Distance travelled: ' + distance(path) + ' km');
  51. });
  52. ```
  53. Notes
  54. -----
  55. Distances are returned in kilometers and computed using the Haversine formula.