Giter VIP home page Giter VIP logo

lowres-rgeo's Introduction

lowres-rgeo

lowres-rgeo is a low-resolution reverse geocoding library for Node.JS. By low-resolution, we mean that it considers each city in the world as a point, and it looks up the nearest point in its database; this makes it only suitable for use in situations where exact results are not necessary. As an example, consider this: for many locations in downtown Manhattan, the nearest city in our database is actually Weehawken, NJ, which is across the river but in a different state.

We use this library for reverse geocoding on http://forecast.io/ when you click and drag the pin on the globe. The interface is sufficiently imprecise that the error caused by our assumptions is negligible, and using this library saves us a lot of money that would have been brought upon us by geocoding API queries.

This database used in this library is not especially intelligent but works well for our purposes. The world's surface is evenly divided into 256x128 buckets, each represented by a gzipped JSON array containing the cities that are found in that bucket. At lookup time, we read the four nearest buckets, find the closest city within 25km, and return it. (Or return "Middle of Nowhere" if such a city cannot be found.)

The database used in this library was cobbled together from a wide variety of free sources. We've done some cursory checks on the data to ensure its sanity but, since we ourselves are not sane, we cannot make any guarantees.

Usage

var rgeo = require("lowres-rgeo");

rgeo(42.7235, -73.6931, function(err, city) {
  if(err)
    throw err;

  console.log(city); // => "Troy, NY"
});

License

To the extend possible by law, The Dark Sky Company, LLC has waived all copyright and related or neighboring rights to this library.

lowres-rgeo's People

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.