Countries GeoJson data processor
Node script extracting data from different sources in order to build the data set required for the World Geography Game v1 project.
Code available on GitHub
Background
This project was driven by the need to get data for the first version of the World Geography Game project.
The sources available did not provide a data set fitting the game requirements. The goal was to combines these data sets:
Approach
The design was kept simple, a simple node script to read and extract the data from the sources. The data sets should to be cloned before running the script.
The script receives the path for the targeted data in each sources as well as the output path.
Example:
node . --geoJson ../geojson-regions/countries/50m/all.geojson \
--countries ../countries/countries.json \
--flags ../countries/data/ \
--output dist \
--outputFlags dist/flags
geoJson
: Path to the file in the geojson-regions repository providing a collection of features 50m precision is used in the example above, but any should workcountries
: Path to the file in the countries repository providing the list of country dataflags
: Path to the flags directory in the countries repositoryoutput
: Path to the directory where to store the output dataoutputFlags
: Path to the directory where to store the flags
Implementation
CLI & JS API
The project is mainly planned for CLI usage, however the process.argv
is reduced to an Object mapping the key values. The resulting object is passed to the JS API (which can also be called directly).
Flow based
Each step of the flow is a module in src/steps
which is designed in a I/O fashion, making testing easy.
The steps are called serially using Async/waterfall
Testing
As described above, each step is a function receiving the result from the previous step. The tests written are using Mocha + Chai BDD, which also have a good integration with WebStorm.
Credits
Special thanks to Ash Kyd - GeoJson regions and Mohammed Le Doze - Countries for their projects gathering the countries data.
As well as: