Coder Social home page Coder Social logo

where's Introduction

Geographical utilities for Node.js Build Status Coverage Status

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

Some features

Start by importing where:

const where = require('where');

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

const malmi = new where.Point(60.254558, 25.042828);
const 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):

const geocoder = new where.Geocoder;
geocoder.toPoint({
  display_name: 'Helsinki',
  country: 'fi'
})
  .then((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)
  .then((location) => {
    location.address.road; // Malminkaari
    location.address.city; // Helsinki
  });

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

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

Installation

$ npm install where --save

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.

Changes

  • 0.4.2 (February 16 2023)
    • Release to update dependencies due to security issues
  • 0.4.1 (August 19 2020)
    • distanceTo method now returns distances rounded to one meter accuracy instead of 100 meter accuracy
  • 0.4.0 (October 01 2019)
    • Removed legacy NodeXT support
  • 0.3.2 (October 01 2019)
  • 0.3.1 (November 03 2018)
    • Switched from request to the fetch library for browser compat
  • 0.3.0 (October 16 2017)
    • Switched asynchronous geocoding methods to return a promise instead of using a callback

where's People

Contributors

bergie avatar danyshaanan avatar dependabot[bot] avatar greenkeeper[bot] avatar greenkeeperio-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

where's Issues

What units is `distanceTo` returning?

In the readme, this example is given:

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

malmi.distanceTo(vantaa); // 8.2

Is this number in kilometers (it seems as though it is, but I'm not sure)? In any case, I think it'd probably be good to document this. I'll gladly submit a PR documenting this, if it's a hassle for you to do so.

Thanks for making this package, by the way! It's very useful.

An in-range update of mocha is breaking the build 🚨

Version 3.4.1 of mocha just got published.

Branch Build failing 🚨
Dependency mocha
Current Version 3.4.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As mocha is “only” a devDependency of this project it might not break production or downstream projects, but “only” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this 💪

Status Details
  • continuous-integration/travis-ci/push The Travis CI build failed Details

Release Notes Ohai CRLF...

Fixed a publishing mishap with git's autocrlf settings.

Commits

The new version differs by 3 commits0.

false

See the full diff

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

Version 10 of node.js has been released

Version 10 of Node.js (code name Dubnium) has been released! 🎊

To see what happens to your code in Node.js 10, Greenkeeper has created a branch with the following changes:

  • Added the new Node.js version to your .travis.yml
  • The new Node.js version is in-range for the engines in 1 of your package.json files, so that was left alone

If you’re interested in upgrading this repo to Node.js 10, you can open a PR with these changes. Please note that this issue is just intended as a friendly reminder and the PR as a possible starting point for getting your code running on Node.js 10.

More information on this issue

Greenkeeper has checked the engines key in any package.json file, the .nvmrc file, and the .travis.yml file, if present.

  • engines was only updated if it defined a single version, not a range.
  • .nvmrc was updated to Node.js 10
  • .travis.yml was only changed if there was a root-level node_js that didn’t already include Node.js 10, such as node or lts/*. In this case, the new version was appended to the list. We didn’t touch job or matrix configurations because these tend to be quite specific and complex, and it’s difficult to infer what the intentions were.

For many simpler .travis.yml configurations, this PR should suffice as-is, but depending on what you’re doing it may require additional work or may not be applicable at all. We’re also aware that you may have good reasons to not update to Node.js 10, which is why this was sent as an issue and not a pull request. Feel free to delete it without comment, I’m a humble robot and won’t feel rejected 🤖


FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

2 possible issues

  1. looks like it requires "request" but not installing it as a dependency (?)
  2. when calling geocoder with bad coordinates, the callback doesn't get anything in the error, but instead the location looks like {"error":"Unable to geocode"}

An in-range update of request is breaking the build 🚨

☝️ Greenkeeper’s updated Terms of Service will come into effect on April 6th, 2018.

Version 2.84.0 of request was just published.

Branch Build failing 🚨
Dependency request
Current Version 2.83.0
Type dependency

This version is covered by your current version range and after updating it in your project the build failed.

request is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.

Status Details
  • continuous-integration/travis-ci/push The Travis CI build failed Details

Commits

The new version differs by 6 commits.

  • d77c839 Update changelog
  • 4b46a13 2.84.0
  • 0b807c6 Merge pull request #2793 from dvishniakov/2792-oauth_body_hash
  • cfd2307 Update hawk to 7.0.7 (#2880)
  • efeaf00 Fixed calculation of oauth_body_hash, issue #2792
  • 253c5e5 2.83.1

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Installing from npm does not provide any .js files

I think this used to work, and now it doesn't:

$ npm install where
$ node
> require('where')

/Users/ulyssecarion/tmp/foobar/node_modules/where/src/Point.coffee:1
s, require, module, __filename, __dirname) { toRadians = (degrees) -> degrees
                                                                    ^
... ^C

And looking inside the source, I think only the .coffee files are included.

$ tree node_modules/where/src/
node_modules/where/src/
├── BBox.coffee
├── Geocoder.coffee
└── Point.coffee

0 directories, 3 files

Sorry if this is an obvious problem, but whereas before I could do npm install where, now this no longer works. :-/

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.