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

geo-lib

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

geo-lib

A Node.js module with useful geo functions. Made with performance in mind.

  • 0.1.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
235
decreased by-15.47%
Maintainers
1
Weekly downloads
 
Created
Source

Geo-lib module for fast calculations of distance, speed and heading

Build Status Coverage Status

The start of my new geo-lib module. This Node.js module is built with performance and speed as priority one.

Why did I start this module? I need a module that is able to do millions of calculations every minute. This module is going to be developed according to these demands. I'll always be looking out for de-optimization inside the V8 engine.

Howto get started using this module

$ npm install geo-lib --save

Then use it in your code.

To find the distance between 2 geo points:

let geoLib = require('geo-lib');
let result = geoLib.distance({
    p1: { lat: 70.3369224, lon: 30.3411273 },
    p2: { lat: 59.8939528, lon: 10.6450348 }
});
// result = {
//   distance: 1468.28,
//   unit: 'km',
//   method: 'haversine'
// }

Or even in a simpler way:

let geoLib = require('geo-lib');
let result = geoLib.distance([
    [70.3369224, 30.3411273],
    [59.8939528, 10.6450348]
]);
// result = {
//   distance: 1468.28,
//   unit: 'km',
//   method: 'haversine'
// }

To find the distance and speed between 2 geo points:

let geoLib = require('geo-lib');
let result = geoLib.distance({
    p1: { lat: 70.3369224, lon: 30.3411273 },
    p2: { lat: 59.8939528, lon: 10.6450348 },
    timeUsed: 86400 * 5
});
// result = {
//   distance: 1468.28,
//   method: 'haversine',
//   speedKph: 12.24,
//   speedMph: 7.61,
//   speedMpk: '5:54',
//   timeUsedInSeconds: 432000,
//   unit: 'km'
// }

To check if a point is inside a polygon:

let geoLib = require('geo-lib');
let result = geoLib.pointIsInsidePoly([
    [70.403203, 31.055603],
    [70.364476, 31.089935],
    [70.361707, 31.107788],
    [70.363091, 31.132507],
    [70.367244, 31.140747],
    [70.375087, 31.154480],
    [70.379699, 31.172333],
    [70.387536, 31.179199],
    [70.397214, 31.164093],
    [70.403203, 31.129761],
    [70.405506, 31.100922],
    [70.405506, 31.062469],
    [70.403663, 31.056976]
], [70.374164, 31.117401]);
// result = true                               

Howto to get started with contributions

$ git clone git@github.com:5orenso/geo-lib.git
$ cd geo-lib/
$ npm install

Start developing. Remember to start watching your files:

$ grunt watch

Howto contribute

$ git clone git@github.com:5orenso/geo-lib.git

Do your magic and create a pull request.

Howto report issues

Use the Issue tracker

Howto update CHANGELOG.md

$ bash ./changelog.sh

Howto upgrade modules

$ npm install -g npm-check-updates
$ ncu -u
$ npm install --save --no-optional

HOWTO upgrade dev environment

$ npm install buster --save-dev
$ npm install buster-istanbul --save-dev
$ npm install grunt --save-dev
$ npm install grunt-buster --save-dev
$ npm install grunt-contrib-jshint --save-dev
$ npm install grunt-contrib-nodeunit --save-dev
$ npm install grunt-contrib-watch --save-dev
$ npm install grunt-coveralls --save-dev
$ npm install grunt-jscs --save-dev
$ npm install grunt-nodemon --save-dev
$ npm install grunt-shell --save-dev
$ npm install grunt-jsdoc --save-dev

More about the author

FAQs

Package last updated on 19 Jun 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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