-
Notifications
You must be signed in to change notification settings - Fork 1
/
generator.sh
executable file
·39 lines (34 loc) · 1.15 KB
/
generator.sh
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
#!/usr/bin/env bash
set -e
IFS=$'\n\t'
echo "system: Running $0"
echo "system: Creating tileset directory...$TILESET_DIR"
mkdir -p "$TILESET_DIR"
mkdir -p "$TMP_DIR"
echo "system: Removing old geojson files..."
rm -f "$TMP_DIR/$GEOJSON_OUTPUT_FILENAME" || true
echo "$TMP_DIR"
echo "$GEOJSON_OUTPUT_FILENAME"
# echo "$POSTGREST_API_URL"
echo "$POSTGRES_MATERIALIZE_VIEW_NAME"
# echo "ts-node: Creating geojson file from api request..."
# npx ts-node --esm "$WORKDIR"/geojson-generator/index.ts
ogr2ogr \
-f GeoJSON "$TMP_DIR/$GEOJSON_OUTPUT_FILENAME" \
"PG:host='$POSTGRES_HOST' \
dbname='$POSTGRES_DB' \
user='$POSTGRES_USER' \
password='$POSTGRES_PASSWORD'" \
-sql "select * from $POSTGRES_MATERIALIZE_VIEW_NAME"
echo "tippecanoe: Creating tileset..."
tippecanoe \
-zg \
-o "$TMP_DIR/$TILESET_NAME" \
--force \
--drop-densest-as-needed \
--extend-zooms-if-still-dropping \
"$TMP_DIR/$GEOJSON_OUTPUT_FILENAME"
echo "system: Copying tileset to workdir directory..."
cp "$TMP_DIR"/"$TILESET_NAME" "$WORKDIR"
echo "system: Upload tileset to s3 bucket"
aws s3api put-object --bucket "$AWS_BUCKET" --key "$TILESET_NAME" --body "$TMP_DIR/$TILESET_NAME"