JSPM

nearby-cities

1.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 83
  • Score
    100M100P100Q74511F
  • License MIT

Give me your coordinates and I'll tell you where the nearest cities are. Works offline.

Package Exports

  • nearby-cities

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (nearby-cities) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

nearby-cities

Give me your coordinates and I'll tell you where the nearest cities are. Works offline.

Installation

Download node at nodejs.org and install it, if you haven't already.

npm install nearby-cities --save

Usage

const nearbyCities = require("nearby-cities")
const query = {latitude: 34.4362755, longitude: -119.705086}
const cities = nearbyCities(query)

assert.equal(cities[0].name, 'Mission Canyon')
assert.equal(cities[1].name, 'Santa Barbara')
assert.equal(cities[2].name, 'Montecito')
assert.equal(cities[3].name, 'Summerland')
assert.equal(cities[4].name, 'Goleta')

console.log(cities[0])

/*
{
  name: "Mission Canyon",
  country: "US",
  featureClass: "P",
  featureCode: "PPL",
  adminCode: "CA",
  population: 2381,
  lat: 34.45083,
  lon: -119.71291
}
*/

Tests

npm install
npm test

Dependencies

  • all-the-cities: All the 138,398 cities of the world with a population of at least 1000 inhabitants, in a big JSON array
  • kdbush: a spatial index for 2D points
  • geokdbush: a geographic extension for kdbush

Dev Dependencies

  • mocha: simple, flexible, fun test framework
  • standard-format: attempts to reformat javascript to comply with feross/standard style

License

MIT

Generated by package-json-to-readme