forked from openstreetmap-si/GursAddressesForOSM
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
95 lines (77 loc) · 2.96 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
unexport GOFLAGS
SHELL:=/bin/bash
DATAFOLDER = data/
DLFOLDER = $(DATAFOLDER)downloaded/
TMP = $(DATAFOLDER)temp/
TS = $$(cat $(TMP)timestamp.txt)
TSYYYY = $$(cat $(TMP)timestamp.txt | cut -b 1-4)
all: download reproject geojson conflate reconflate reconflate summary
.PHONY: download
download:
mkdir -p $(TMP) || true
./getSource.sh $(DLFOLDER) $(TMP)
.PHONY: reproject
reproject:
#reproject from d96 to epsg4326
rm -rf $(TMP)HS-epsg4326
ogr2ogr -progress -t_srs "EPSG:4326" $(TMP)HS-epsg4326 $(TMP)HS -nln HS-epsg4326
.PHONY: geojson
geojson:
mkdir -p $(DATAFOLDER)
go run gursShp2geoJson.go
# make a zip
sed "s/%YYYY-MM-DD%/$(TS)/g" data-LICENSE-template.md > $(DATAFOLDER)LICENSE.md
#zip -9 -q -r $(DATAFOLDER)slovenia-housenumbers-$(TS).zip $(DATAFOLDER)slovenia/* $(DATAFOLDER)LICENSE.md
.PHONY: clean
clean:
rm -r $(TMP)
#rm -r $(DLFOLDER)
#rm -r $(DATAFOLDER)
rm -rf venv
.PHONY: test
test:
go test -v -cover -race -coverprofile=coverage.txt -covermode=atomic
.PHONY: benchNoData
benchNoData:
go test -v -short -cover -race -coverprofile=coverage.txt -covermode=atomic -bench=.
.PHONY: bench
bench:
go test -cover -race -coverprofile=coverage.txt -covermode=atomic -bench=.
requirements: requirements.txt.out
# install requirements if requirements.txt.out is missing or older than requirements.txt
requirements.txt.out: venv requirements.txt
# install the requirements into virtual environments and record the action to requirements.txt.out
source venv/bin/activate && pip install -r requirements.txt | tee requirements.txt.out
.PHONY: conflate
conflate: requirements
source venv/bin/activate; \
for gursGeoJson in $$(find data/slovenia -name '*-gurs.geojson' | sort); \
do \
DIRNAME=$$(dirname $$gursGeoJson); \
BASENAME=$$(basename $$gursGeoJson -gurs.geojson); \
echo "***** Conflating: $$DIRNAME/$$BASENAME *****"; \
conflate -i $$gursGeoJson -v -c $$DIRNAME/$$BASENAME-preview.geojson -o $$DIRNAME/$$BASENAME.osm gursAddressesConflationProfile.py --verbose 2>&1 | tee $$DIRNAME/$$BASENAME-conflate-log.txt; \
sleep 0.3s ;\
done
.PHONY: reconflate
reconflate: requirements
#fgrep --include \*-conflate-log.txt -lri "Failed to download data from Overpass API" data/slovenia/
#or log missing!
source venv/bin/activate; \
for badLog in $$(fgrep --include \*-conflate-log.txt -lri "Failed to download data from Overpass API" data/slovenia/ | sort); \
do \
echo "***** Conflating: $$badLog *****"; \
DIRNAME=$$(dirname $$badLog); \
BASENAME=$$(basename $$badLog -conflate-log.txt); \
echo "***** Conflating: $$DIRNAME/$$BASENAME *****"; \
conflate -i "$$DIRNAME/$$BASENAME-gurs.geojson" -v -c $$DIRNAME/$$BASENAME-preview.geojson -o $$DIRNAME/$$BASENAME.osm gursAddressesConflationProfile.py --verbose 2>&1 | tee $$DIRNAME/$$BASENAME-conflate-log.txt; \
sleep 0.3s ;\
done
.PHONY: summary
summary:
cp OSM_Slovenia_Logo.ico $(DATAFOLDER)/slovenia/favicon.ico
./summarize.sh
venv:
# basic setup
pip install virtualenv
virtualenv -p `which python3` venv