JSPM

all-the-cities-mongodb

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2
  • Score
    100M100P100Q39600F
  • License MIT

All the Cities data import ready for MongoDB

Package Exports

  • all-the-cities-mongodb

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 (all-the-cities-mongodb) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

all-the-cities

All the 138,398 cities of the world with a population of at least 1000 inhabitants, in a big JSON array that is ready to be imported in MongoDB for geoSpatialSearch.

Derived from the cities-with-1000 npm package, which in turn came from geonames.org data.

Installation

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

npm install all-the-cities-mongodb --save

Usage

const cities = require("all-the-cities-mongodb")

cities.filter(city => {
  return city.name.match('Albuquerque')
})

// [{
//   name: 'Albuquerque',
//   country: 'US',
//   altCountry: '',
//   muni: '',
//   muniSub: '',
//   featureClass: 'P',
//   featureCode: 'PPLA2',
//   adminCode: 'NM',
//   population: 545852,
//   lat: 35.08449,
//   lon: -106.65114
// }, {
//   name: 'Los Ranchos de Albuquerque',
//   country: 'US',
//   altCountry: '',
//   muni: '',
//   muniSub: '',
//   featureClass: 'P',
//   featureCode: 'PPL',
//   adminCode: 'NM',
//   population: 6024,
//   lat: 35.16199,
//   lon: -106.6428
// }]

Fields available to import

id - Id of the city (same in openWeatherMap)
name
altName
country
featureCode
adminCode
population
loc: { type: 'Point', coordinates: [0, 0] }

for **GEO JSON data**, a particular format is needed in MongoDB Schema as written in loc field above

Tests

npm install
npm test

Dependencies

None

Dev Dependencies

  • cities-with-1000: lat/lon, names of cities with over 1000 people
  • tape: tap-producing test harness for node and browsers
  • split2: split a Text Stream into a Line Stream, using Stream 3
  • through2: A tiny wrapper around Node streams2 Transform to avoid explicit subclassing noise

License

MIT