#!/usr/bin/env bash

# Script to go through all our maps and run the mesh simplification script on
# them all.
# It downloads all the maps specified in 'submaps' below, runs the mesh_simplify
# script on them, and re-upload them with the '-simplified' suffix appended.
# 
# This was a one of script that I ran when I introduced mesh simplification.

set -eou pipefail

local_root_dir=/media/bigdata/meshing
s3_root_dir=s3://zoox-clams/imageries_clams

submaps="commercial/2017-02-17 dutch_goose/2017-02-22 embarcadero/2017-02-11 menlopark/2017-02-24 slac/2017-04-01"

for submap in $submaps
do
  if [ ! -d ${local_root_dir}/${submap}-simplified -a -d ${local_root_dir}/${submap} ]; then
    cp -a ${local_root_dir}/${submap} ${local_root_dir}/${submap}-simplified
  fi
  aws s3 sync ${s3_root_dir}/${submap} ${local_root_dir}/${submap}-simplified --delete
  mybrun //mapping/scripts:mesh_simplify ${local_root_dir}/${submap}-simplified/Tiles-10S-25-10 --profile sdf
  aws s3 sync --profile clams ${local_root_dir}/${submap}-simplified \
    ${s3_root_dir}/${submap}-simplified
done

(
cd ${ZOOX_WORKSPACE_ROOT}
experimental/brice/assemble_submaps.sh
)

