Skip to content

Instantly share code, notes, and snippets.

@jeanatcismet
Created April 17, 2019 12:03
Show Gist options
  • Save jeanatcismet/484feb5282b5593517f936a57198ce7a to your computer and use it in GitHub Desktop.
Save jeanatcismet/484feb5282b5593517f936a57198ce7a to your computer and use it in GitHub Desktop.
#!/bin/bash
WKT="POINT(368705.78 5679133.82)"
SEARCH_RESULT=$(curl -s -F "file=$WKT\";type=application/json" -uuser@WUNDA_BLAU:xxx -X POST http://localhost:8890/actions/WUNDA_BLAU.SchraegluftbilderForGeomSearch/tasks\?role\=all\&resultingInstanceType\=result | jq -r '.res')
NAME=Turm
for directionIndex in 0 1 2 3; do
INFO=$(echo $SEARCH_RESULT | jq -r '.['$directionIndex']')
DIRECTION=$(echo $INFO | jq -r '.direction')
POINT_X=$(echo $INFO | jq -r '.point.x')
POINT_Y=$(echo $INFO | jq -r '.point.y')
TIF=${NAME}_$DIRECTION.tif
wget $(echo $INFO | jq -r '.url') -O $TIF
echo $INFO
for i in 2 4 8; do
ZOOM_FACTOR=$i
IMAGE_WIDTH=$(identify -ping -format '%w' $TIF 2> /dev/null)
IMAGE_HEIGHT=$(identify -ping -format '%h' $TIF 2> /dev/null)
CENTER_X=$(($IMAGE_WIDTH * $POINT_X))
CENTER_Y=$(($IMAGE_HEIGHT * $POINT_Y))
CROP_WIDTH=$(($IMAGE_WIDTH / $ZOOM_FACTOR))
CROP_HEIGHT=$(($IMAGE_HEIGHT / $ZOOM_FACTOR))
CROP_X=$(($CENTER_X - (CROP_WIDTH / 2)))
CROP_Y=$(($CENTER_Y - (CROP_HEIGHT / 2)))
RESIZE_WIDTH=800
RESIZE_HEIGHT=$(($RESIZE_WIDTH * $IMAGE_HEIGHT / $IMAGE_WIDTH))
echo convert -interpolate bicubic -crop ${CROP_WIDTH}x${CROP_HEIGHT}+${CROP_X}+${CROP_Y} -resize ${RESIZE_WIDTH}x${RESIZE_HEIGHT} $TIF ${NAME}_${DIRECTION}_zoom${ZOOM_FACTOR}.png
convert -interpolate bicubic -crop ${CROP_WIDTH}x${CROP_HEIGHT}+${CROP_X}+${CROP_Y} -resize ${RESIZE_WIDTH}x${RESIZE_HEIGHT} $TIF ${NAME}_${DIRECTION}_zoom${ZOOM_FACTOR}.png 2> /dev/null
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment