This repo contains all the code used for the demo presented by Group A of UNIPA (UniversitĂ degli Studi di Palermo) for "Samsung Innovation Campus 2021 Smart Things Edition" in Palermo. Eventually 3 of the 4 members of Group A (atmoeyes) won the edition.
Below are developement notes.
URI | Method | Description |
---|---|---|
/ | GET | Live Map page |
URI | Method | Description |
---|---|---|
/data/aqi | GET | Returns GeoJSON aqi data layer |
/data/aqi/send | POST | Send sensor data to aqi data layer (CURRENTLY UNPROTECTED) |
Value | Lon | Lat |
---|---|---|
Int | Float | Float |
Tool: Edit GeoJSON Data
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"aqi": 7
},
"geometry": {
"type": "Point",
"coordinates": [-30, 10]
}
},
...
}
Specify project specific parameters in .atmoeyes
{
"backendUrl": "https://emanuelemessina.altervista.org/uni/ssmic2021/atmoeyes/backend"
}
- Calls to
/backend
are redirected tokernel.php
via.htaccess
RewriteRule. kernel.php
- calls db, calls router./db.php
- initializes db connection, declares db methods./router/router.php
- declares route matching methods, callsroutes.php
./router/routes.php
- setsapplication/json
response header, calls declared routes, which are then parsed by the router. If no match is found, 404 is thrown.- When a match is found, execution is passed to the matched route controller.
$input_schema = [
"id" => "int",
"value" => "int"
];
$qq = new QuickQuery('json-input', $input_schema);
$validated_data = $qq->getValidatedData();
$response = $qq->update(
'data', // table
['value'], // fields to update
[ // where clause
'id' => $validated_data['id']
]);
echo json_encode($response);
Validation is automatically done and all errors are reported in the response.
Table names are already prefixed with 'atmoeyes_'
.
get('/data/aqi/$optional_get_param', 'aqi-data.php');
- Controller files are placed under
/controllers
. - Optional GET parameters are accessible in the controller via $parameters array.