-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
48 lines (40 loc) · 1.3 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
# Database settings
TEST_DIR = t
DB_USER = devel
DB_HOST = 127.0.0.1
DB_DBNAME = make_test
PG_PROVE_FLAGS = -v
DB_SCHEMA = osm_brasil
DB_URI = db:pg://$(DB_USER)@$(DB_HOST)/$(DB_DBNAME)
# Osmosis settings
DATA_DIR = /tmp/var/data
OSM_FILE = osm_data.osm
OSM_TASK_BUFF = --buffer bufferCapacity=10000
OSM_TASK_WRITE = --write-pgsql-dump-0.6 \
enableBboxBuilder=true enableLinestringBuilder=true \
nodeLocationStoreType=CompactTempFile \
directory=$(DATA_DIR)
OSM_FLAG = -v 100
OSM_TASK_READ = --read-xml file=$(OSM_FILE)
OSMOSIS_FLAGS = $(OSM_FLAG) $(OSM_TASK_READ) $(OSM_TASK_WRITE)
LOAD_FILE = $(PWD)/script/load_data.sql
OSM_BBOX = "-45.091,-23.448,-45.066,-23.423"
OSM_API = "https://api.openstreetmap.org/api/0.6/map?bbox="
.PHONY: revert deploy test all
all: deploy load test
deploy:
createdb -U $(DB_USER) -h $(DB_HOST) $(DB_DBNAME) || true
sqitch deploy $(DB_URI) --to-change bbox
osm_data.osm:
wget -O $(OSM_FILE) $(OSM_API)$(OSM_BBOX)
load: $(OSM_FILE) $(LOAD_FILE)
mkdir -p $(DATA_DIR)
osmosis $(OSMOSIS_FLAGS)
cd $(DATA_DIR) && psql -U $(DB_USER) -h $(DB_HOST) -d $(DB_DBNAME) -f $(LOAD_FILE)
sqitch deploy $(DB_URI)
test: deploy
pg_prove $(PG_PROVE_FLAGS) -U $(DB_USER) -h $(DB_HOST) -d $(DB_DBNAME) $(TEST_DIR)/*
revert:
sqitch revert -y $(DB_URI)
rm -rf $(OSM_FILE)
rm -rf $(DATA_DIR)