-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
110 lines (86 loc) · 6.07 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
all:
DATABASE_URL=postgresql://bikeccidents:bikeccidents@localhost/bikeccidents
TABULA=tabula-1.0.2-jar-with-dependencies.jar
ROADS_SHP=geo/berlin-latest.shp/gis.osm_roads_free_1.shp
data/accidents_points_%.geojson: csvs/%.csv geo/berlin_streets.geojson geo/polizeidirektionen.geojson
mkdir -p data
python generate.py accident_points --engine $(DATABASE_URL) --years $* > $@
data/accidents_streets_%.geojson: csvs/%.csv geo/berlin_streets.geojson geo/polizeidirektionen.geojson
mkdir -p data
python generate.py accident_streets --engine $(DATABASE_URL) --years $* > $@
data/accidents_%.geojson: csvs/%.csv geo/berlin_streets.geojson geo/polizeidirektionen.geojson
mkdir -p data
python generate.py accidents --engine $(DATABASE_URL) --years $* > $@
data/accidents_list_%.csv: csvs/%.csv geo/berlin_streets.geojson geo/polizeidirektionen.geojson
mkdir -p data
python generate.py accident_list --engine $(DATABASE_URL) --years $* > $@
tabula-1.0.2-jar-with-dependencies.jar:
wget "https://github.com/tabulapdf/tabula-java/releases/download/v1.0.2/tabula-1.0.2-jar-with-dependencies.jar"
$(ROADS_SHP):
mkdir -p geo
wget -O geo/berlin-latest.shp.zip "http://download.geofabrik.de/europe/germany/berlin-latest-free.shp.zip"
unzip -d geo/berlin-latest.shp geo/berlin-latest.shp.zip
pdfs/radfahrer%.pdf:
sh download.sh
geo/berlin_streets.geojson: $(ROADS_SHP)
python collect_streets.py $(ROADS_SHP) > $@
geo/polizeidirektionen.geojson:
ogr2ogr -t_srs EPSG:4326 -s_srs EPSG:25833 -f "geoJSON" $@ WFS:"http://fbinter.stadt-berlin.de/fb/wfs/geometry/senstadt/re_abschnitt" fis:re_abschnitt
csvs/2018_raw.csv: pdfs/radfahrer2018.pdf $(TABULA)
mkdir -p csvs
java -jar ./$(TABULA) -p 35-47,49-61,63-75,77-89,91-103,105-119 -a 74,56,811,550 -c 98,130,496 -o $@ pdfs/radfahrer2018.pdf
csvs/2017_raw.csv: pdfs/radfahrer2017.pdf $(TABULA)
mkdir -p csvs
java -jar ./$(TABULA) -p 35-45,47-57,59-70,72-83,85-96,98-111 -a 74,56,811,550 -c 98,130,496 -o $@ pdfs/radfahrer2017.pdf
csvs/2016_raw.csv: pdfs/radfahrer2016.pdf $(TABULA)
mkdir -p csvs
java -jar ./$(TABULA) -p 35-46,48-59,61-72,74-85,87-99,101-112 -a 74,56,811,550 -c 98,130,505 -o $@ pdfs/radfahrer2016.pdf
csvs/2015_raw.csv: pdfs/radfahrer2015.pdf $(TABULA)
mkdir -p csvs
java -jar ./$(TABULA) -p 34-105 -a 50,83,811,550 -c 103,135,503 -o $@ pdfs/radfahrer2015.pdf
csvs/2014_raw.csv: pdfs/radfahrer2014.pdf $(TABULA)
mkdir -p csvs
java -jar ./$(TABULA) -p 34-102 -a 50,83,811,550 -c 108,134,500 -o $@ pdfs/radfahrer2014.pdf
csvs/2013_raw.csv: pdfs/radfahrer2013.pdf $(TABULA)
java -jar ./$(TABULA) -p 34-101 -a 50,83,811,550 -c 116,143,500 -o $@ pdfs/radfahrer2013.pdf
csvs/2012_raw.csv: pdfs/radfahrer2012.pdf $(TABULA)
java -jar ./$(TABULA) -p 34-103 -a 50,83,811,550 -c 132,165,475 -o $@ pdfs/radfahrer2012.pdf
csvs/2011_raw.csv: pdfs/radfahrer2011.pdf $(TABULA)
java -jar ./$(TABULA) -p 34-102 -a 50,83,811,550 -c 130,190,497 -o $@ pdfs/radfahrer2011.pdf
csvs/2010_raw.csv: pdfs/radfahrer2010.pdf $(TABULA)
java -jar ./$(TABULA) -p 34-46 -a 50,83,811,550 -c 145,204,497 -o csvs/2010_raw_1.csv pdfs/radfahrer2010.pdf
java -jar ./$(TABULA) -p 47-57 -a 50,83,811,550 -c 127,188,497 -o csvs/2010_raw_2.csv pdfs/radfahrer2010.pdf
java -jar ./$(TABULA) -p 48-102 -a 50,83,811,550 -c 115,176,488 -o csvs/2010_raw_3.csv pdfs/radfahrer2010.pdf
cat csvs/2010_raw_1.csv csvs/2010_raw_2.csv csvs/2010_raw_3.csv > $@
rm csvs/2010_raw_*.csv
csvs/2009_raw.csv: pdfs/radfahrer2009.pdf $(TABULA)
java -jar ./$(TABULA) -p 34-47 -a 50,83,811,550 -c 146,205,483 -o csvs/2009_raw_1.csv pdfs/radfahrer2009.pdf
java -jar ./$(TABULA) -p 48-60 -a 50,83,811,550 -c 130,189,487 -o csvs/2009_raw_2.csv pdfs/radfahrer2009.pdf
java -jar ./$(TABULA) -p 61-71 -a 50,83,811,550 -c 115,176,480 -o csvs/2009_raw_3.csv pdfs/radfahrer2009.pdf
java -jar ./$(TABULA) -p 72-83 -a 50,83,811,550 -c 115,176,493 -o csvs/2009_raw_4.csv pdfs/radfahrer2009.pdf
java -jar ./$(TABULA) -p 84-108 -a 50,83,811,550 -c 115,175,500 -o csvs/2009_raw_5.csv pdfs/radfahrer2009.pdf
cat csvs/2009_raw_*.csv > $@
rm csvs/2009_raw_*.csv
csvs/2008_raw.csv: pdfs/radfahrer2008.pdf $(TABULA)
java -jar ./$(TABULA) -p 34-50 -a 50,83,811,550 -c 130,187,498 -o csvs/2008_raw_1.csv pdfs/radfahrer2008.pdf
perl -pi -e 's/,,OSTSEESTR,/,,OSTSEESTR,1/g' csvs/2008_raw_1.csv
java -jar ./$(TABULA) -p 51-65 -a 50,83,811,550 -c 118,178,497 -o csvs/2008_raw_2.csv pdfs/radfahrer2008.pdf
java -jar ./$(TABULA) -p 66-80 -a 50,83,811,550 -c 140,200,484 -o csvs/2008_raw_3.csv pdfs/radfahrer2008.pdf
perl -pi -e 's|,,"JULIE-WOLFTHORN-STR. / AM NORDBAHNHOF / ",|,,"JULIE-WOLFTHORN-STR. / AM NORDBAHNHOF / ",1|g' csvs/2008_raw_3.csv
perl -pi -e 's|"",,"AM LUSTGARTEN / KARL-LIEBKNECHT-STR. / ",|"",,"AM LUSTGARTEN / KARL-LIEBKNECHT-STR. / ",1|g' csvs/2008_raw_3.csv
perl -pi -e 's|"",,"JANNOWITZBRÜCKE / ALEXANDERSTR. / ",|"",,"JANNOWITZBRÜCKE / ALEXANDERSTR. / ",1|g' csvs/2008_raw_3.csv
perl -pi -e 's|"",,"FENNSTR. / REINICKENDORFER STR. / SCHÖNWALDER ",|"",,"FENNSTR. / REINICKENDORFER STR. / SCHÖNWALDER ",1|g' csvs/2008_raw_3.csv
java -jar ./$(TABULA) -p 81-97 -a 50,83,811,550 -c 157,215,479 -o csvs/2008_raw_4.csv pdfs/radfahrer2008.pdf
java -jar ./$(TABULA) -p 98-112 -a 50,83,811,550 -c 130,190,482 -o csvs/2008_raw_5.csv pdfs/radfahrer2008.pdf
java -jar ./$(TABULA) -p 113-130 -a 50,83,811,550 -c 142,208,475 -o csvs/2008_raw_6.csv pdfs/radfahrer2008.pdf
cat csvs/2008_raw_*.csv > $@
rm csvs/2008_raw_*.csv
csvs/2007_raw.csv: pdfs/radfahrer2007.pdf $(TABULA)
java -jar ./$(TABULA) -p 35-117 -a 50,83,811,550 -c 129,184,500 -n -o csvs/2007_raw.csv pdfs/radfahrer2007.pdf
java -jar ./$(TABULA) -p 35-111 -a 50,83,811,550 -c 122,184,498 -n -o csvs/2006_raw.csv pdfs/radfahrer2006.pdf
java -jar ./$(TABULA) -p 35-102 -a 50,83,811,550 -g -c 60,110,184,500 -n -o csvs/2005_raw.csv pdfs/radfahrer2005.pdf
java -jar ./$(TABULA) -p 35-110 -a 50,83,811,550 -c 115,180,500 -n -o csvs/2004_raw.csv pdfs/radfahrer2004.pdf
csvs/2003_raw.csv: pdfs/radfahrer2003.pdf $(TABULA)
java -jar ./$(TABULA) -p 35-103 -a 50,83,811,550 -c 115,180,500 -n -o csvs/2003_raw.csv pdfs/radfahrer2003.pdf
csvs/%.csv: csvs/%_raw.csv
python parser.py "$*" < "csvs/$*_raw.csv" > $@