- Install postgresql
- Install PostGIS (
sudo apt-get install postgresql-9.1-postgis
) - Create a PostGRES database
- Log in to the server using
sudo -u postgres psql
CREATE USER airq WITH PASSWORD 'password';
CREATE DATABASE airquality;
GRANT ALL PRIVILEGES ON DATABASE airquality TO airq;
- Load the PostGIS extension
sudo -u postgres createlang plpgsql airquality;
sudo -u postgres psql -d airquality -f /usr/share/postgresql/9.1/contrib/postgis-1.5/postgis.sql
sudo -u postgres psql -d airquality -f /usr/share/postgresql/9.1/contrib/postgis-1.5/spatial_ref_sys.sql
To connect from a remote machine setup an SSH tunnel:
ssh -L 3333:localhost:5432 [email protected]
Then you can tap into the database like so:
psql -h localhost -p 3333 airquality airq
API calls /measurements/stationID (optional limit) Get a list of measurements taken from a specific station. Limits at 1000 if one is not specified Returns stationInfo as an object and measurements as an array
/stationList Get a list of stations
/stationNear/lat/long (optional limit) Get a list of stations near a lat and long coordinate. Limits at 10 if none if specified
/last/limit Get a list of the last limit measurements