npm

Need private packages and team management tools?Check out npm Orgs. »

find-nearest-cities

1.0.0 • Public • Published

find-nearest-cities

Searches the nearest cities, using geokdbush. Data taken from cities1000 at geonames.org

build status npm version ISC-licensed

Installing

npm install find-nearest-cities

Usage

const nearestStations = require('find-nearest-cities')
 
const latitude = 52.509647;
const longitude = 13.375944;
 
const cities = nearestCities(latitude, longitude);
 
// [{
//    id: '2822224',
//    name: 'Tiergarten',
//    asciiname: 'Tiergarten Bezirk',
//    alternativeNames: ['Berlin-Tiergarten',
//       'Tirgarten',
//       'Tyrgartehn',
//       'di er jia teng',
//       'Тиргартен',
//       'Тыргартэн',
//       'טירגארטן',
//       '蒂尔加滕'
//    ],
//    lat: 52.51667,
//    lon: 13.36667,
//    featureClass: 'P',
//    featureCode: 'PPLX',
//    country: 'DE',
//    altCountry: '',
//    adminCode: '16',
//    countrySubdivision: '00',
//    municipality: '11000',
//    municipalitySubdivision: '11000000',
//    population: 12328,
//    dem: '36',
//    tz: 'Europe/Berlin',
//    lastModified: '2012-06-09',
//    distance: 1281
// }]
 

API

nearestCities(longitude, latitude[, maxDistance, maxResults])

Returns an array of the closest points from a given location in order of increasing distance.

  • longitude: query point longitude.
  • latitude: query point latitude.
  • maxDistance: (optional) maximum distance in meters to search within (Infinity by default).
  • maxResults: (optional) maximum number of points to return (5 by default).

Contributing

If you have a question, found a bug or want to propose a feature, have a look at the issues page.

Data License

The Dataset is published under Creative Commons Attribution 4.0 International by geonames.org.

install

npm i find-nearest-cities

Downloadsweekly downloads

4

version

1.0.0

license

ISC

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability