3 GDALCOPYPROJ="/usr/share/doc/python-gdal/examples/gdalcopyproj.py"
5 # Expected directory names: 2010-04, 2010-11, ... 2016-04
6 OSSV_EDITIONS=($(ls -d 201*|sort -n))
7 OSSV_EDITIONS_LENGTH=${#OSSV_EDITIONS[@]}
9 OSSV_EDITIONS_TMP=$(mktemp -d --suffix=osstvw_edit)
11 rm -rf "${OSSV_EDITIONS_TMP}"
15 # Create OSSTVW ocean blue to compare new files against
16 convert -size 5000x5000 xc:'#e6f6ff' -depth 8 ${OSSV_EDITIONS_TMP}/blue.png
18 # Outer loop (compare from)
19 for (( i=0; i<${OSSV_EDITIONS_LENGTH}; i++ )); do
20 # Inner loop (compare to)
21 for (( o=${i}; o<${OSSV_EDITIONS_LENGTH}; o++ )); do
22 # Skip when outer == inner edition
23 if [ "$i" != "$o" ]; then
24 OSSV_DIFF_NAME="diff-${OSSV_EDITIONS[$i]}-${OSSV_EDITIONS[$o]}"
25 mkdir -p "${OSSV_DIFF_NAME}"
26 # TIF file loop for edition - see end of loop for find
27 while IFS= read -r -d $'\0' FILE; do
28 FILE_1="${OSSV_EDITIONS[$i]}/${FILE}"
29 FILE_2="${OSSV_EDITIONS[$o]}/${FILE}"
30 if [ ! -f "${FILE_1}" ]; then
31 FILE_1="${OSSV_EDITIONS_TMP}/blue.png"
34 if [ ! -f "${OSSV_DIFF_NAME}/${FILE}" ]; then
35 echo Creating diff ${OSSV_EDITIONS[$i]} ${OSSV_EDITIONS[$o]} "${FILE_1}" "${OSSV_DIFF_NAME}/${FILE}"
36 # Background compare + gdalcopyproj
37 ((compare -quiet "${FILE_1}" "${FILE_2}" -compose Src -highlight-color Red -lowlight-color 'rgba(255,255,255,0)' -define tiff:tile-geometry=512x512 "${OSSV_DIFF_NAME}/${FILE}" || true) && python ${GDALCOPYPROJ} "${FILE_2}" "${OSSV_DIFF_NAME}/${FILE}" ) &
39 # Check how many background processes and wait if exceed
41 while [ ${#running[@]} -ge 16 ] ; do
42 sleep 1 # this is not optimal, but you can't use wait here
46 done < <(find "${OSSV_EDITIONS[$o]}" -maxdepth 1 -name '*.tif' -printf '%f\0')