#!/usr/bin/env bash
set -e

# Test script for generating tiles for Lummen and region (e.g. including Hasselt)
export SOURCE=osmfr
export AREA=europe/belgium/flanders
export BBOX=4.964926,50.882471,5.411252,51.071236
# Which zooms to generate in   make generate-tiles
export MIN_ZOOM=0
export MAX_ZOOM=16

# Update the .env to match
sed -i "s/MIN_ZOOM=.*/MIN_ZOOM=${MIN_ZOOM}/" .env
sed -i "s/MAX_ZOOM=.*/MAX_ZOOM=${MAX_ZOOM}/" .env
sed -i "s/BBOX=.*/BBOX=${BBOX}/" .env


# Setup
make clean
make DC_OPTS=--rm

# Start from a clean db
make start-db
make destroy-db
make import-data
# ALTERNATIVE would be this
#make start-db-preloaded

# Download
make download-${SOURCE} area="${AREA}"

# Import
make import-osm
make import-borders
make import-wikidata
make import-sql
make analyze-db

# (This potentially screws stuff up?!)
#rm -rf data/${AREA}.dc-config.yml
#make generate-dc-config

# Generate
make generate-tiles

make stop-db