X-Git-Url: https://git.openstreetmap.org./chef.git/blobdiff_plain/d698ffb172b5c7f7703680f91a518f20ad0dcc1b..a75d9db67025eeb4db19abdb36a6a870a6ea0dc4:/cookbooks/imagery/files/default/osstvw_make_diffs diff --git a/cookbooks/imagery/files/default/osstvw_make_diffs b/cookbooks/imagery/files/default/osstvw_make_diffs index f4da6dffc..636c6f334 100644 --- a/cookbooks/imagery/files/default/osstvw_make_diffs +++ b/cookbooks/imagery/files/default/osstvw_make_diffs @@ -30,8 +30,8 @@ for (( i=0; i<${OSSV_EDITIONS_LENGTH}; i++ )); do if [ ! -f "${FILE_1}" ]; then FILE_1="${OSSV_EDITIONS_TMP}/blue.png" fi - # Skip existing files - if [ ! -f "${OSSV_DIFF_NAME}/${FILE}" ]; then + # Skip existing files or excluded files + if [ ! -f "${OSSV_DIFF_NAME}/${FILE}" ] && [ ! -f "${OSSV_DIFF_NAME}/${FILE}.skip" ]; then echo Creating diff ${OSSV_EDITIONS[$i]} ${OSSV_EDITIONS[$o]} "${FILE_1}" "${OSSV_DIFF_NAME}/${FILE}" # Background compare + gdalcopyproj ((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}" ) & @@ -44,6 +44,33 @@ for (( i=0; i<${OSSV_EDITIONS_LENGTH}; i++ )); do done fi done < <(find "${OSSV_EDITIONS[$o]}" -maxdepth 1 -name '*.tif' -printf '%f\0') + + # Wait for background jobs to finish + wait + + echo "Removing empty diffs" + # TIF cleanup loop for images which have no diff + while IFS= read -r -d $'\0' FILE; do + ( FILE_COLOURS=$(identify -quiet -format '%k' "${OSSV_DIFF_NAME}/${FILE}") + if [ "$FILE_COLOURS" -lt "2" ]; then + rm -f "${OSSV_DIFF_NAME}/${FILE}" + touch "${OSSV_DIFF_NAME}/${FILE}.skip" + fi ) & + + # Check how many background processes and wait if exceed + running=($(jobs -rp)) + while [ ${#running[@]} -ge 16 ] ; do + sleep 1 # this is not optimal, but you can't use wait here + running=($(jobs -rp)) + done + done < <(find "${OSSV_DIFF_NAME}" -maxdepth 1 -name '*.tif' -size -180000c -printf '%f\0') + # Wait for background jobs to finish + wait + if [ ! -f "ossv-${OSSV_DIFF_NAME}-combined.vrt" ]; then + gdalbuildvrt -resolution highest -hidenodata "ossv-${OSSV_DIFF_NAME}-combined.vrt" ${OSSV_DIFF_NAME}/*.tif + fi fi done done +echo Now create external overview layers +echo eg: gdaladdo --config GDAL_CACHEMAX=16000 -ro --config COMPRESS DEFLATE --config COMPRESS_OVERVIEW DEFLATE --config ZLEVEL 9 --config BIGTIFF_OVERVIEW IF_SAFER --config GDAL_TIFF_OVR_BLOCKSIZE 512 -r average ossv-2016-04-combined.vrt 4 16 64 256 1024 4096