run.sh 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/bin/sh
  2. cd "$(dirname "$0")"
  3. GDAL_DIR="/usr/bin"
  4. "$GDAL_DIR/gdaltransform" --version >/dev/null || { echo "I need gdal-bin" && exit 1 ; }
  5. "$GDAL_DIR/gdal_translate" --version >/dev/null || { echo "I need gdal-bin" && exit 1 ; }
  6. "$GDAL_DIR/gdalwarp" --version >/dev/null || { echo "I need gdal-bin" && exit 1 ; }
  7. "$GDAL_DIR/gdal2tiles.py" --version >/dev/null || { echo "I need python-gdal" && exit 1 ; }
  8. WWW_BASE_URL="http://maps.dev.mro.name/dav/west"
  9. GOOGLE_API_KEY="AIzaSyAvoB86uoFONxyj3OxDmjJmBkluR4SsAz0"
  10. # DATUM_OSM="EPSG:3857" # WGS84 mercator/UTM
  11. DATUM_AUT="EPSG:4805"
  12. DATUM_OSM="EPSG:4326" # WGS84 lat/lon
  13. jpg="AV-KarteAllgaeuerLechtalerAlpen-2,1-1906.jpg"
  14. date +%FT%T%z
  15. # transform points from Datum OSM to Datum Austria
  16. src="$jpg.points"
  17. points_aut="$jpg.points.aut"
  18. head -n 1 "$src" > "$points_aut"
  19. tail -n +2 "$src" | tr ',' ' ' | while read -r lon lat x y on comment
  20. do
  21. comment="$comment http://www.openstreetmap.org/?mlat=$lat&mlon=$lon#map=18/$lat/$lon&layers=C"
  22. echo $lon $lat | "$GDAL_DIR/gdaltransform" -s_srs "$DATUM_OSM" -t_srs "$DATUM_AUT" | while read -r a_lon a_lat ele
  23. do
  24. echo "$a_lon,$a_lat,$x,$y,$on,$comment"
  25. done
  26. done >> "$points_aut"
  27. date +%FT%T%z
  28. # download map
  29. curl --output "$jpg" --time-cond "$jpg" --remote-time --url "$(cat "$jpg".url)"
  30. date +%FT%T%z
  31. # gdal_translate
  32. "$GDAL_DIR/gdal_translate" -a_srs "$DATUM_AUT" $(ruby points_to_gcp.rb < "$points_aut") "$jpg" "$jpg.trans.tif"
  33. date +%FT%T%z
  34. # gdal_warp
  35. "$GDAL_DIR/gdalwarp" -multi -t_srs "$DATUM_OSM" -tps -r lanczos -dstnodata 0 -ot Byte "$jpg.trans.tif" "$jpg.warp.tif"
  36. convert "$jpg.warp.tif" "$jpg.warp.png"
  37. date +%FT%T%z
  38. # gdal2tiles
  39. gdal2tiles.py --force-kml --url="$WWW_BASE_URL" --googlekey="$GOOGLE_API_KEY" --webviewer=all --title="Allgaeuer Alpen, Westliche Haelfte" --copyright="Leo Aegerter, 1907" --zoom=9-18 --resampling=bilinear --s_srs="$DATUM_OSM" --profile=mercator "$jpg.warp.tif" "tiles"
  40. date +%FT%T%z