nearby-big-cities
v1.0.0
Published
Give me your coordinates and I'll tell you where the nearest cities (and their country) of at least 15000 people are. Uses k-nearest-neighbour algorithm, so it's fast. Works offline. Directly based on git+https://github.com/zeke/nearby-cities.git
Downloads
8
Maintainers
Readme
nearby-big-cities
Give me your coordinates and I'll tell you where the nearest cities (and their country) of at least 15000 people are. Uses k-nearest-neighbour algorithm, so it's fast. Works offline. Directly based on git+https://github.com/zeke/nearby-cities.git
Installation
npm install nearby-big-cities --save
Usage
const assert = require('assert')
const nearbyCities = require("nearby-big-cities")
const query = {latitude: 34.4362755, longitude: -119.705086}
const cities = nearbyCities(query)
;[ 'Santa Barbara',
'Goleta',
'Isla Vista',
'Ventura'
].forEach((item, index) => assert.equal(cities[index].name, item))
assert.deepEqual(cities[0],
{
name: 'Santa Barbara',
country: 'US',
muni: '',
population: 88410,
lat: 34.42083,
lon: -119.69819
})
Tests
npm install
npm test
Dependencies
- sphere-knn: search for k nearest neighbors on a sphere
Dev Dependencies
- mocha: simple, flexible, fun test framework
- split2: split a Text Stream into a Line Stream, using Stream 3
- standard: JavaScript Standard Style
- through2: A tiny wrapper around Node streams2 Transform to avoid explicit subclassing noise
License
MIT