Giter VIP home page Giter VIP logo

node-geopoint's Introduction

Geographic Point

GeoPoint represents a geographic point for node.js and the browser, and provides distance between points and radius bounding box calculations.

Installation

npm install geopoint 

Usage

var GeoPoint = require('geopoint'),
    statueOfLiberty = new GeoPoint(40.689604, -74.04455);

Constructor options

  • latitude: Latitude
  • longitude: Longitude
  • inRadians: true if the latitude and longitude are in radians, defaults to false

Methods

  • .latitude(inRadians): Return the point's latitude. By default, the latitude is in degrees, unless inRadians is true
  • .longitude(inRadians): Return the point's longitude. By default, the longitude is in degrees, unless inRadians is true
  • .distanceTo(point, inKilometers): Calculate the distance to another GeoPoint instance. By default, the distance is calculated in miles, unless inKilometers is true
  • .boundingCoordinates(distance, radius, inKilometers): Calculates the bounding coordinates of distance from the point and returns an array with the SW and NE points of the bounding box . If radius is not provided, the radius of the Earth will be used. The distance is calculated in miles unless inKilometers is true
  • .isInBoundingBox(boundingBox): Returns boolean value if the point's latitude and longitude are within the boundingBox passed. Bounding box is an array with the SW and NE points of the bounding box as returned by .boundingCoordinates method.

Static Methods

  • GeoPoint.degreesToRadians(value): Converts value in degrees to radians
  • GeoPoint.radiansToDegrees(value): Converts value in radians to degrees
  • GeoPoint.milesToKilometers(value): Converts value in miles to kilometers
  • GeoPoint.kilometersToMiles(value): Converts value in kilometers to miles

Browser Support

The GeoPoint constructor is exposed via window.GeoPoint.

Running Tests

Cachetree tests require Mocha and can be run with either npm test. You can specify Mocha options, such as the reporter, by adding a mocha.opts file, which is ignored by git, to the test directory.

Credits

This library is derived from the code presented in Finding Points Within a Distance of a Latitude/Longitude Using Bounding Coordinates by Jan Philip Matuschek.

node-geopoint's People

Contributors

davidwood avatar talha-asad avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.