API made to query a dataset of US accidents
bash ./install.sh PATH_TO_CSV_FILE
Installation will import the csv data on "accidents" collection under "accidents" db
You should also create a .env
file with the corresponding server configuration. See .env.example
for an example.
node index.js
This will start the API server on port 3000
Returns all the accidents that happened between two dates.
Parameters:
- startDate: the start date (for example, '2019-03-10')
- endDate: the end date (for example, '2019-03-11')
- limit: used to limit the returned documents.
Returns the accidents within a certain area.
Parameters:
- longitude: a longitude (for example, '-84.058723')
- latitude: a latitude (for example, '39.865147')
- radius: a radius (in km)
- limit: used to limit the returned documents
Returns the most dangerous points within a certain area.
Parameters:
- longitude: a longitude (for example, '-84.058723')
- latitude: a latitude (for example, '39.865147')
- radius: a radius (in km)
- limit: used to limit the returned documents
Returns the average distance of all the accidents, between their start point and end point.
Returns the most common weather conditions.
Returns the most common location data.
Returns the most common terrain conditions.
We had to modify the Mongo collection schema by adding two geo points to all the accidents. Some of them already had an end point, but in those cases where they don't, we used the start point.
We used both the start and the end point to determine if an accident happened in a certain area.