summaryrefslogtreecommitdiff
path: root/localosmfeature2pdf
blob: 64a89e0aa997082f7b8387bea0e1ff9b347b9e7b (plain)
  1. #!/bin/sh
  2. #
  3. # Copyright © 2014 Jonas Smedegaard <dr@jones.dk>
  4. # Description: resolve GeoJSON from OSM node, way and relation objects.
  5. #
  6. # This program is free software; you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation; either version 3, or (at your option)
  9. # any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful, but
  12. # WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. # General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. #
  19. # Depends: gdal-bin perl-modules
  20. set -eu
  21. # type must be either polygons, lines or points
  22. type="$1"
  23. feature="$2"
  24. outstem="${3:-$(basename "$feature")}"
  25. case "$feature" in
  26. node/*)
  27. url="http://www.openstreetmap.org/api/0.6/$feature"
  28. ;;
  29. *)
  30. url="http://www.openstreetmap.org/api/0.6/$feature/full"
  31. ;;
  32. esac
  33. case "$type" in
  34. polygons)
  35. ogr2ogr -t_srs EPSG:3857 -f PDF \
  36. "$outstem.pdf" /vsicurl_streaming/"$url" \
  37. --config OSM_USE_CUSTOM_INDEXING NO \
  38. -nlt PROMOTE_TO_MULTI multipolygons
  39. ;;
  40. lines)
  41. ogr2ogr -t_srs EPSG:3857 -f PDF \
  42. "$outstem.pdf" /vsicurl_streaming/"$url" \
  43. --config OSM_USE_CUSTOM_INDEXING NO \
  44. -nlt PROMOTE_TO_MULTI multilinestrings
  45. ;;
  46. points)
  47. ogr2ogr -t_srs EPSG:3857 -f PDF \
  48. "$outstem.pdf" /vsicurl_streaming/"$url" \
  49. --config OSM_USE_CUSTOM_INDEXING NO \
  50. points \
  51. ;;
  52. esac