nodes-csv-gzip.sh 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #!/bin/bash
  2. ARG_1=`echo $QUERY_STRING | awk -F [=,\&] '{ print $1; }'`
  3. ARG_2=`echo $QUERY_STRING | awk -F [=,\&] '{ print $2; }'`
  4. ARG_3=`echo $QUERY_STRING | awk -F [=,\&] '{ print $3; }'`
  5. ARG_4=`echo $QUERY_STRING | awk -F [=,\&] '{ print $4; }'`
  6. ARG_5=`echo $QUERY_STRING | awk -F [=,\&] '{ print $5; }'`
  7. ARG_6=`echo $QUERY_STRING | awk -F [=,\&] '{ print $6; }'`
  8. ARG_7=`echo $QUERY_STRING | awk -F [=,\&] '{ print $7; }'`
  9. ARG_8=`echo $QUERY_STRING | awk -F [=,\&] '{ print $8; }'`
  10. echo -e "\
  11. <osm-script timeout=\"180\" element-limit=\"10000000\"> \
  12. \
  13. <id-query type=\"relation\" ref=\"$ARG_1\"/> \
  14. <print mode=\"body\"/> \
  15. \
  16. </osm-script> \
  17. " >/tmp/nodes_csv_rel_req
  18. REQUEST_METHOD=
  19. /home/roland/osm-3s/cgi-bin/interpreter </tmp/nodes_csv_rel_req >/tmp/nodes_csv_rel_result.1
  20. RESPONSE_TYPE=`head -n 1 </tmp/nodes_csv_rel_result.1`
  21. if [[ $RESPONSE_TYPE != "Content-type: application/osm3s" ]]; then
  22. {
  23. cat </tmp/nodes_csv_rel_result.1
  24. exit 0
  25. };
  26. fi
  27. dd if=/tmp/nodes_csv_rel_result.1 of=/tmp/nodes_csv_rel_result.2 bs=1 skip=56
  28. gunzip </tmp/nodes_csv_rel_result.2 | ../bin/memberlist >/tmp/nodes_rel_csv_result.3
  29. mkdir /tmp/nodes_csv_rels
  30. while read -u 3 REL; do
  31. {
  32. echo -e "\
  33. <osm-script timeout=\"180\" element-limit=\"10000000\"> \
  34. \
  35. <union> \
  36. <id-query type=\"relation\" ref=\"$REL\"/> \
  37. <recurse type=\"relation-node\"/> \
  38. </union> \
  39. <print mode=\"body\"/> \
  40. \
  41. </osm-script> \
  42. " >/tmp/nodes_csv_req
  43. REQUEST_METHOD=
  44. /home/roland/osm-3s/cgi-bin/interpreter </tmp/nodes_csv_req >/tmp/nodes_csv_result.1
  45. RESPONSE_TYPE=`head -n 1 </tmp/nodes_csv_result.1`
  46. if [[ $RESPONSE_TYPE != "Content-type: application/osm3s" ]]; then
  47. {
  48. cat </tmp/nodes_csv_result.1
  49. exit 0
  50. };
  51. fi
  52. dd if=/tmp/nodes_csv_result.1 of=/tmp/nodes_csv_result.2 bs=1 skip=56
  53. if [[ $ARG_2 == "forward" ]]; then
  54. {
  55. gunzip </tmp/nodes_csv_result.2 | ../bin/nodes-csv-lat-lon-name --forward >/tmp/nodes_csv_rels/$REL
  56. };
  57. fi
  58. if [[ $ARG_2 == "backward" ]]; then
  59. {
  60. gunzip </tmp/nodes_csv_result.2 | ../bin/nodes-csv-lat-lon-name --backward >/tmp/nodes_csv_rels/$REL
  61. };
  62. fi
  63. if [[ $ARG_2 == "all" ]]; then
  64. {
  65. gunzip </tmp/nodes_csv_result.2 | ../bin/nodes-csv-lat-lon-name >/tmp/nodes_csv_rels/$REL
  66. };
  67. fi
  68. };
  69. done 3</tmp/nodes_rel_csv_result.3
  70. echo "Content-Type: application/gzip"
  71. echo
  72. cd /tmp/
  73. tar cf - nodes_csv_rels/ | gzip
  74. rm /tmp/nodes_csv_req/*
  75. rmdir /tmp/nodes_csv_req