d.path.sh 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. #!/bin/sh
  2. ############################################################################
  3. #
  4. # MODULE: d.path_wrapper.sh
  5. # AUTHOR(S): Hamish Bowman (Otago University, New Zealand)
  6. # PURPOSE: Draw vector map to xmon before running d.path and pass opts
  7. # COPYRIGHT: (c) 2007 by Hamish Bowman, and the GRASS Development Team
  8. #
  9. # This program is free software under the GNU General Public
  10. # License (>=v2). Read the file COPYING that comes with GRASS
  11. # for details.
  12. #
  13. #############################################################################
  14. # Notes:
  15. # Created with "d.path --script" from GRASS 6.3-CVS 6 March 2007
  16. # Be sure menu entry runs guarantee_xmon first. for example:
  17. # "guarantee_xmon; d.path_wrapper.sh -b --ui"
  18. # d.path is interactive with the xmon, but does not need to run in a xterm
  19. #############################################################################
  20. #%Module
  21. #% description: Find shortest path for selected starting and ending node
  22. #% keywords: display, networking
  23. #%End
  24. #%Flag
  25. #% key: g
  26. #% description: Use geodesic calculation for longitude-latitude locations
  27. #%End
  28. #%Flag
  29. #% key: b
  30. #% description: Render bold lines
  31. #% guisection: Rendering
  32. #%End
  33. #%Option
  34. #% key: map
  35. #% type: string
  36. #% required: yes
  37. #% multiple: no
  38. #% key_desc: name
  39. #% description: Name of input vector map
  40. #% gisprompt: old,vector,vector
  41. #%End
  42. #%Option
  43. #% key: type
  44. #% type: string
  45. #% required: no
  46. #% multiple: yes
  47. #% options: line,boundary
  48. #% label: Type
  49. #% description: Arc type
  50. #% answer: line,boundary
  51. #%End
  52. #%Option
  53. #% key: coor
  54. #% type: string
  55. #% required: no
  56. #% multiple: no
  57. #% key_desc: x1,y1,x2,y2
  58. #% description: Starting and ending coordinates
  59. #%End
  60. #%Option
  61. #% key: alayer
  62. #% type: integer
  63. #% required: no
  64. #% multiple: no
  65. #% label: Layer number
  66. #% description: Arc layer
  67. #% answer: 1
  68. #%End
  69. #%Option
  70. #% key: nlayer
  71. #% type: integer
  72. #% required: no
  73. #% multiple: no
  74. #% label: Layer number
  75. #% description: Node layer
  76. #% answer: 2
  77. #%End
  78. #%Option
  79. #% key: afcol
  80. #% type: string
  81. #% required: no
  82. #% multiple: no
  83. #% description: Arc forward/both direction(s) cost column
  84. #%End
  85. #%Option
  86. #% key: abcol
  87. #% type: string
  88. #% required: no
  89. #% multiple: no
  90. #% description: Arc backward direction cost column
  91. #%End
  92. #%Option
  93. #% key: ncol
  94. #% type: string
  95. #% required: no
  96. #% multiple: no
  97. #% description: Node cost column
  98. #%End
  99. #%Option
  100. #% key: color
  101. #% type: string
  102. #% required: no
  103. #% multiple: no
  104. #% description: Original line color
  105. #% answer: black
  106. #% gisprompt: color,grass,color
  107. #% guisection: Rendering
  108. #%End
  109. #%Option
  110. #% key: hcolor
  111. #% type: string
  112. #% required: no
  113. #% multiple: no
  114. #% description: Highlight color
  115. #% answer: red
  116. #% gisprompt: color,grass,color
  117. #% guisection: Rendering
  118. #%End
  119. #%Option
  120. #% key: bgcolor
  121. #% type: string
  122. #% required: no
  123. #% multiple: no
  124. #% description: Background color
  125. #% answer: white
  126. #% gisprompt: color,grass,color
  127. #% guisection: Rendering
  128. #%End
  129. if [ -z "$GISBASE" ] ; then
  130. echo "You must be in GRASS GIS to run this program." 1>&2
  131. exit 1
  132. fi
  133. if [ "$1" != "@ARGS_PARSED@" ] ; then
  134. exec g.parser "$0" "$@"
  135. fi
  136. d.vect map="$GIS_OPT_MAP" color="$GIS_OPT_COLOR"
  137. if [ "$GIS_FLAG_G" -eq 1 ] ; then
  138. flag_g="-g"
  139. else
  140. flag_g=""
  141. fi
  142. if [ "$GIS_FLAG_B" -eq 1 ] ; then
  143. flag_b="-b"
  144. else
  145. flag_b=""
  146. fi
  147. if [ -n "$GIS_OPT_COOR" ] ; then
  148. opt_coor="coor=$GIS_OPT_COOR"
  149. else
  150. opt_coor=""
  151. fi
  152. if [ -n "$GIS_OPT_AFCOL" ] ; then
  153. opt_afcol="afcol=$GIS_OPT_AFCOL"
  154. else
  155. opt_afcol=""
  156. fi
  157. if [ -n "$GIS_OPT_ABCOL" ] ; then
  158. opt_abcol="abcol=$GIS_OPT_ABCOL"
  159. else
  160. opt_abcol=""
  161. fi
  162. if [ -n "$GIS_OPT_NCOL" ] ; then
  163. opt_ncol="ncol=$GIS_OPT_NCOL"
  164. else
  165. opt_ncol=""
  166. fi
  167. exec d.path $flag_g $flag_b \
  168. map="$GIS_OPT_MAP" \
  169. type="$GIS_OPT_TYPE" \
  170. $opt_coor \
  171. alayer="$GIS_OPT_ALAYER" \
  172. nlayer="$GIS_OPT_NLAYER" \
  173. $opt_afcol $opt_abcol $opt_ncol \
  174. color="$GIS_OPT_COLOR" \
  175. hcolor="$GIS_OPT_HCOLOR" \
  176. bgcolor="$GIS_OPT_BGCOLOR"