So I understand that this isn't the traditional way to share code but seeing how there isn't anything on the stack about how to accomplish such a task - I figured I'd share.
To further explain, I looked everywhere for an easy to use Node.JS module to process geonames data into a mongo database. The select few projects I found turned out to be a bust. Perhaps people aren't sharing because it really is such a simple task. With that said, I still think it could be valuable to share what I have.
The following answer will show how to process geonames data from http://geonames.org into a usable object that can then be saved into a database or just used out right.
To further extend the above answer. I have included an example that uses the geonames Node.JS module from Github. ( https://github.com/bugs181/geonames )
Disclaimer: I am the author of the aforementioned github repo.
This example can also be found on the Github repo.
Output:
You may use strings for the latitude and longitude as well but you must convert them for the Mongo database. Use the
Number()
method to do this.For example: