Giter Site home page Giter Site logo

where's Introduction

Geographical utilities for Node.js Build Status

This library provides some basic utilities for building location-based applications.

Some features

Start by importing where:

var where = require('where');

Given two points, the Helsinki-Malmi and Helsinki-Vantaa airports:

var malmi = new where.Point(60.254558, 25.042828);
var vantaa = new where.Point(60.317222, 24.963333);

Calculating distances between points (in kilometers):

malmi.distanceTo(vantaa); // 8.2

Calculating bearing and direction from a point to another:

malmi.bearingTo(vantaa);   // 329
malmi.directionTo(vantaa); // NW

Pretty printing to human-readable coordinates:

malmi.toString(); // 60°15′16″N 25°2′34″E

Converting human-readable addresses to coordinates (geocoding, powered by OpenStreetMap Nominatim):

var geocoder = new where.Geocoder;
geocoder.toPoint({
  display_name: 'Helsinki',
  country: 'fi'
}, function (err, points) {
  points[0].lat; // 60.1666277
  points[0].lon; // 24.9435079 
});

Converting coordinates to human-readable addresses (reverse geocoding, powered by OpenStreetMap Nominatim):

geocoder.fromPoint(malmi, function (err, location) {
  location.address.road; // Malminkaari
  location.address.city; // Helsinki
});

Creating bounding boxes for a given radius (coming soon):

// 20km bounding box
var bbox = malmi.getBBox(20);
malmi.directionTo(bbox.sw); // SW

Installation

$ npm install where

Running tests

$ npm install --dev
$ npm test

Development

This library is provided under the MIT license. Contributions to the project are welcome on GitHub.

Initially this has been a Node.js port of my earlier PHP library.

where's People

Contributors

bergie avatar danyshaanan 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.