rels-extended.sh 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/bin/bash
  2. BUF=$QUERY_STRING\&
  3. SKETCH_PARAMS=
  4. BRIM_PARAMS=
  5. while [[ -n $BUF ]]; do
  6. {
  7. KEY=`echo $BUF | awk '{ print substr($0,0,match($0,"=")); }'`
  8. BUF=`echo $BUF | awk '{ print substr($0,match($0,"=")+1); }'`
  9. VALUE=`echo $BUF | awk '{ print substr($0,0,match($0,"\&")); }'`
  10. BUF=`echo $BUF | awk '{ print substr($0,match($0,"\&")+1); }'`
  11. if [[ $KEY == "id" && -n $VALUE ]]; then
  12. {
  13. REF=$VALUE
  14. };
  15. fi
  16. };
  17. done
  18. BASEDIR=`mktemp -d`
  19. echo -e "\
  20. data=<osm-script timeout=\"180\" element-limit=\"10000000\"> \
  21. \
  22. <union into=\"full\"> \
  23. <id-query type=\"relation\" ref=\"$REF\" into=\"rels\"/> \
  24. <recurse type=\"relation-way\" from=\"rels\"/> \
  25. <recurse type=\"way-node\"/> \
  26. <recurse type=\"relation-node\" from=\"rels\"/> \
  27. </union> \
  28. <union> \
  29. <recurse type=\"node-relation\" from=\"full\"/> \
  30. <recurse type=\"way-relation\" from=\"full\"/> \
  31. <recurse type=\"relation-backwards\" from=\"full\"/> \
  32. </union> \
  33. <print mode=\"ids_only\"/> \
  34. \
  35. </osm-script>
  36. " >$BASEDIR/request.1
  37. if [[ -z $REF ]]; then
  38. {
  39. echo "Content-Type: text/plain; charset=utf-8"
  40. echo
  41. echo "Please use an URL like ..?id=[id_of_relation]"
  42. exit 0
  43. };
  44. fi
  45. REQUEST_METHOD=
  46. /home/roland/osm-3s/cgi-bin/interpreter <$BASEDIR/request.1