GeoKey extension for Air Quality functionality.
geokey-airquality requires:
- Python version 2.7
- GeoKey version 1.6 or greater
Install the geokey-airquality from PyPI:
pip install geokey-airquality
Or from cloned repository:
cd geokey-airquality
pip install -e .
Add the package to installed apps:
INSTALLED_APPS += (
...
'geokey_airquality',
)
Migrate the models into the database:
python manage.py migrate geokey_airquality
Copy static files:
python manage.py collectstatic
Setup a Cron job for checking measurements that due to finish by running:
crontab -e
And adding:
15 0 * * * python local_settings/manage.py check_measurements
You're now ready to go!
Update the geokey-airquality from PyPI:
pip install -U geokey-airquality
Migrate the models into the database:
python manage.py migrate geokey_airquality
Copy static files:
python manage.py collectstatic
Clone the repository:
git clone git@github.com:ExCiteS/geokey-airquality.git
Install the extension for development:
cd geokey-airquality
pip install -e .
Add the package to installed apps:
INSTALLED_APPS += (
...
'geokey_airquality',
)
Migrate the models into the database:
python manage.py migrate geokey_airquality
Copy static files:
python manage.py collectstatic
When database structure has changed, make migrations file (migrate after that to alter local database):
python manage.py makemigrations geokey_airquality
Run tests:
python manage.py test geokey_airquality
Check code coverage:
coverage run --source=geokey_airquality manage.py test geokey_airquality
coverage report -m --omit=*/tests/*,*/migrations/*
Sign the request with the OAuth access token to authenticate a user.
Sends a CSV sheet via email:
GET /api/airquality/sheet/
Get added projects:
GET /api/airquality/projects/
Response:
[
{
"id": 12,
"name": "Air Quality in London"
}
]
Get personal added locations:
GET /api/airquality/locations/
Response:
[
{
"id": 115,
"type": "Feature",
"geometry": {
// GeoJSON point
},
"name": "South Bank",
"created": "2015-09-15T09:40:01.747Z",
"properties": {
"height": 2 // height from ground
"distance": 3.5 // distance from road,
"characteristics": null // site characteristics
},
"measurements": [
// a list of measurements
]
}
]
Add new location
POST /api/airquality/locations/
Request body:
{
"type": "Feature",
"geometry": {
// GeoJSON point
},
"name": "My new location",
"properties": {
"height": 4.2,
"distance": 7
}
}
Response:
{
"id": 117,
"type": "Feature",
"geometry": {
// GeoJSON point
},
"name": "My new location",
"created": "2015-09-22T07:22:08.147Z",
"properties": {
"height": 4.2,
"distance": 7,
"characteristics": null
},
"measurements": []
}
Update your location:
PATCH /api/airquality/locations/:location_id/
Request body:
{
"type": "Feature",
"geometry": {
// GeoJSON point
},
"name": "My updated location",
"properties": {
"height": 4.2,
"distance": 12
}
}
Response:
{
"id": 117,
"type": "Feature",
"geometry": {
// GeoJSON point
},
"name": "My updated location",
"created": "2015-09-22T07:22:08.147Z",
"properties": {
"height": 4.2,
"distance": 12,
"characteristics": null
},
"measurements": []
}
Delete your location:
DELETE /api/airquality/locations/:location_id/
Add new measurement to your location
POST /api/airquality/locations/:location_id/measurements/
Request body:
{
"barcode": 145023
"called": "2015-12-22T07:08:08.121Z",
"started": "2015-12-23T09:12:02.247Z"
}
Response:
{
"id": 115,
"barcode": "145023",
"started": "2015-12-23T09:12:02.247Z",
"finished": null,
"properties": {
"results": null, // measurement results
"additional_details": null // additional details (per measurement)
}
}
Update your measurement:
PATCH /api/airquality/locations/:location_id/measurements/:measurement_id/
Request body:
{
"barcode": 145023,
"called": "2015-12-23T09:22:01.147Z",
"finished": "2015-12-23T09:22:01.147Z",
"project": "45",
"properties": {
"results": 64.78,
"additional_details": null
}
}
If "finished" is being described, "called" should be also present to calculate actual time difference. Otherwise current time will be used.
If measurement has "started", "finished" and "results" collected, it is still saved until "project" is being attached to measurement. When attached, a new contribution gets created, also current measurement is removed completely.
Response (when no project):
{
"id": 154,
"barcode": "451001",
"started": "2015-11-29T12:01:04.178Z",
"finished": "2015-12-23T09:22:01.147Z",
"properties": {
"results": 64.78,
"additional_details": null
}
}
Delete your measurement:
DELETE /api/airquality/locations/:location_id/measurements/:measurement_id/