README.md 2.53 KB
Newer Older
Dorian's avatar
Dorian committed
1
# Potelet / Paaltje / Bollard
Dorian's avatar
Dorian committed
2

Dorian's avatar
Dorian committed
3
4
5
6
7
8
Creating a printed object of the potelets incidents of the [fixmystreet.brussels](http://fixmystreet.brussels) app, for [MAMA](http://mama.brussels).

Information on the API can be found here:
  * https://data.gov.be/fr/dataset/01593a26-ed57-498e-bec0-13011a75a773
  * https://api.brussels/store/apis/info?name=fixmystreet&version=1.0.0&provider=admin

Dorian's avatar
Dorian committed
9
## Extraction
Dorian's avatar
Dorian committed
10

11
```
Dorian's avatar
Dorian committed
12
cd script
13
14
python3 extract.py
```
Dorian's avatar
Dorian committed
15

Dorian's avatar
Dorian committed
16
17
18
19
20
21
22
23
24
25
This will extract all the potelets incidents by using the fixmystreet API and put them in a local sqlite db ```data/potelets.db```.
If the db already exist it will search for updates from the fixmystreet API and write them in the db.

Note:
  * extracting all the potelets and write them in the db with the python script **takes approximatelly 3h**.
  * if an incidents **has changed of category**, the update script is not able to see it (as the responses of the API only gives infos on the ones that are still in the category - potelets)

To look at db in the command line:
  * ```sudo apt install sqlite3```
  * ```cd data```
Dorian's avatar
Dorian committed
26
  * ```sqlite3```
27
  * ```.open potelets.db```
Dorian's avatar
Dorian committed
28
29
  * ```.header on```
  * ```.mode column```
Dorian's avatar
Dorian committed
30
  * ```select * from potelets;```
Dorian's avatar
Dorian committed
31

Dorian's avatar
Dorian committed
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
Or use [sqlite DB browser](https://sqlitebrowser.org/).

## Clusterization

```
cd script
python3 geo.py
python3 cluster.py
```

The geo script read all incidents from the sql database and add a new coordinate to them that is the standard geojson latitude longitude (as fixmystreet uses another one: EPSG:31370).
It also generates a geojson file with all the potelets incidents that you can easily plot, on [geojson.io](https://geojson.io) for example. You have to run this script first in order to run cluster.py.

The cluster script ead all incidents from the sql database, and groups incidents that are nearby each others into clusters.
It generates a new geojson file with a different marker color for every cluster.
It also write the cluster id into the sql database.
Dorian's avatar
Dorian committed
48

Dorian's avatar
Dorian committed
49
## Layout
Dorian's avatar
Dorian committed
50
51

```
Dorian's avatar
Dorian committed
52
cd script
Dorian's avatar
Dorian committed
53
54
55
python3 layout.py
```

Dorian's avatar
Dorian committed
56
This will generate the HTML file, by filling the ```layout/template/template.html``` with the data from the ```data/potelets.db```.
Dorian's avatar
Dorian committed
57
58
The layout uses **paged.js** for pagination, which need to be on a server in order to work.
Open the server in a web browser and you can get your .pdf from here.
Dorian's avatar
Dorian committed
59
Note that you have to rerun this python script every time you make a change to the template, then the server should update automatically.
Dorian's avatar
Dorian committed
60

Dorian's avatar
Dorian committed
61
To avoid ultra big .pdf we can resample the images down with ```resample-pdf.sh``` with this command
Dorian's avatar
Dorian committed
62
63
64
```
./resample-pdf.sh [dpi] [$pdffile]
```