[GRASS-SVN] r55703 - grass-addons/grass6/raster/r.pastro

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Apr 11 07:40:12 PDT 2013


Author: robertomarzocchi
Date: 2013-04-11 07:40:11 -0700 (Thu, 11 Apr 2013)
New Revision: 55703

Added:
   grass-addons/grass6/raster/r.pastro/digit_input.sh
   grass-addons/grass6/raster/r.pastro/distanze.f90
   grass-addons/grass6/raster/r.pastro/grafico.p
   grass-addons/grass6/raster/r.pastro/install_r_pastro.sh
   grass-addons/grass6/raster/r.pastro/path_profile.py
   grass-addons/grass6/raster/r.pastro/path_profile.sh
   grass-addons/grass6/raster/r.pastro/pathgar.sh
   grass-addons/grass6/raster/r.pastro/point2path.sh
   grass-addons/grass6/raster/r.pastro/point2point.sh
   grass-addons/grass6/raster/r.pastro/profilo.f90
   grass-addons/grass6/raster/r.pastro/r.pastro
   grass-addons/grass6/raster/r.pastro/readme.txt
   grass-addons/grass6/raster/r.pastro/region_layout.sh
   grass-addons/grass6/raster/r.pastro/region_layout2.sh
   grass-addons/grass6/raster/r.pastro/region_zoom.sh
   grass-addons/grass6/raster/r.pastro/sheltgar.sh
   grass-addons/grass6/raster/r.pastro/space2tab.py
   grass-addons/grass6/raster/r.pastro/stragfinder.sh
   grass-addons/grass6/raster/r.pastro/uninstall_r_pastro.sh
   grass-addons/grass6/raster/r.pastro/velocity.py
Log:
pastro codes

Added: grass-addons/grass6/raster/r.pastro/digit_input.sh
===================================================================
--- grass-addons/grass6/raster/r.pastro/digit_input.sh	                        (rev 0)
+++ grass-addons/grass6/raster/r.pastro/digit_input.sh	2013-04-11 14:40:11 UTC (rev 55703)
@@ -0,0 +1,48 @@
+#!/bin/bash
+# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 
+# MODULE:  "digit_input.sh" per GRASS 6.4 (GRASS Shell Script)				
+#											
+# AUTHOR:	roberto marzocchi(roberto.marzocchi at gmail.com)				
+#											
+# PURPOSE: 		
+#	   Il presente modulo viene solitamente lanciato dallo script pastro.sh.	
+#											
+# This program is free software under the GNU General Public License (>=v2). 		
+# Read the file COPYING that comes with GRASS for details.				
+# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
+
+d.mon stop=x4 --quiet
+d.mon start=x4
+if (check_image=1); then
+	#v.digit -n map=$input bgcmd="d.shadedmap reliefmap=temp_shade drapemap=$dtm;d.vect map=$paths display=shape type=line layer=1 color=red fcolor=255:255:0 width=2 wscale=1 icon=basic/x size=5 llayer=1 lcolor=red bgcolor=none bcolor=none lsize=8 xref=left yref=center render=c;d.vect map=$shelters display=shape type=point layer=1 color=blue fcolor=255:255:0 rgb_column=GRASSRGB zcolor=terrain width=0 wscale=1 icon=basic/circle size=8 llayer=1 lcolor=red bgcolor=none bcolor=none lsize=8 xref=left yref=center render=c"	
+	d.shadedmap reliefmap=temp_shade drapemap=$dtm
+	d.vect map=$paths display=shape type=line layer=1 color=red fcolor=255:255:0 width=2 wscale=1 icon=basic/x size=5 llayer=1 lcolor=red bgcolor=none bcolor=none lsize=8 xref=left yref=center render=c
+	#if [! -z $shelters]
+	d.vect map=$shelters display=shape type=point layer=1 color=blue fcolor=255:255:0 rgb_column=GRASSRGB zcolor=terrain width=0 wscale=1 icon=basic/circle size=8 llayer=1 lcolor=red bgcolor=none bcolor=none lsize=8 xref=left yref=center render=c
+	#fi
+else
+	#v.digit -n map=$input bgcmd="d.rast map=$image;d.vect map=$paths display=shape type=line layer=1 color=red fcolor=255:255:0 width=2 wscale=1 icon=basic/x size=5 llayer=1 lcolor=red bgcolor=none bcolor=none lsize=8 xref=left yref=center render=c;d.vect map=$shelters display=shape type=point layer=1 color=blue fcolor=255:255:0 rgb_column=GRASSRGB zcolor=terrain width=0 wscale=1 icon=basic/circle size=8 llayer=1 lcolor=red bgcolor=none bcolor=none lsize=8 xref=left yref=center render=c"
+	d.rast map=$image
+	d.vect map=$paths display=shape type=line layer=1 color=red fcolor=255:255:0 width=2 wscale=1 icon=basic/x size=5 llayer=1 lcolor=red bgcolor=none bcolor=none lsize=8 xref=left yref=center render=c
+	#if [! -z $shelters]
+	d.vect map=$shelters display=shape type=point layer=1 color=blue fcolor=255:255:0 rgb_column=GRASSRGB zcolor=terrain width=0 wscale=1 icon=basic/circle size=8 llayer=1 lcolor=red bgcolor=none bcolor=none lsize=8 xref=left yref=center render=c
+	#fi		
+fi
+
+g.message -i "*******************************************************"
+g.message -i "....Digita un punto con il tasto sinistro del mouse...."
+g.message -i "...............Con il sinistro esci...................."
+g.message -i "_______________________________________________________"
+
+d.where --quiet >.tmp_coord.txt
+space2tab.py
+# sed 's/^[ \t]*//;s/[ \t]*$//;s/    /|/' .tmp_coord.txt > tmp_coord2.txt
+v.in.ascii input=tmp_coord2.txt output=digitato fs="|" x=1 y=2 --overwrite --quiet
+rm .tmp_coord.txt
+rm tmp_coord2.txt
+d.mon stop=x4
+
+
+exit 1 
+
+

Added: grass-addons/grass6/raster/r.pastro/distanze.f90
===================================================================
--- grass-addons/grass6/raster/r.pastro/distanze.f90	                        (rev 0)
+++ grass-addons/grass6/raster/r.pastro/distanze.f90	2013-04-11 14:40:11 UTC (rev 55703)
@@ -0,0 +1,59 @@
+program distanze
+implicit none
+
+integer::i,j,k
+real::a,dist
+real(kind=8),allocatable::prof(:,:),plot(:,:)
+
+open(10,FILE='./per_plot2',STATUS='OLD')
+open(11,FILE='./per_plot3',STATUS='OLD')
+open(12,FILE='./info_sentiero',STATUS='OLD')
+!open(13,FILE='./sentiero.txt',STATUS='OLD')
+
+k=0
+do
+   read(10,*,end=100)a
+   k=k+1
+end do
+100 allocate(prof(k,4))
+allocate(plot(k,4))
+rewind(10)
+do i=1,k
+   read(10,*)(prof(i,j),j=1,4)
+end do
+do i=1,k
+   plot(i,2)=prof(i,3)
+end do
+plot(1,1)=0
+do i=2,k
+   dist=sqrt((prof(i,1)-prof(i-1,1))**2+(prof(i,2)-prof(i-1,2))**2)
+   plot(i,1)=plot(i-1,1)+dist
+   plot(i,3)=(plot(i,2)-plot(i-1,2))/dist
+   ! colonna dove calcolo la velocita in km/h (aggiunta roberto, da mettere in python)
+   !plot(i,4)=3.6*dist/(prof(i,4)-prof(i-1,4))
+end do
+!file per grafico
+do i=1,k
+   write(11,*)(plot(i,j),j=1,2)
+end do
+
+!file per re-importazione in GRASSS con le velocita'
+!do i=1,k
+!   write(13,*)prof(i,1),prof(i,2),prof(i,3),plot(i,4)
+!end do
+
+! preparazione di un file informativo di output
+write(12,*)
+write(12,*)'---------------------------------------------'
+write(12,*)
+write(12,'(A17,I5,A14)')'  Tempo stimato: ',int(prof(k,4)/60),' minuti circa.'
+write(12,*)
+write(12,'(A22,F5.1,A9)')'  Lunghezza percorso: ',plot(k,1)/1000,' km circa.'
+write(12,*)
+write(12,'(A20,I4,A7)')'  Pendenza massima: ',int(max(abs(maxval(plot(:,3))),abs(minval(plot(:,3))))*100),'% circa.'
+write(12,*)
+write(12,*)'---------------------------------------------'
+write(12,*)
+close(12)
+
+end

Added: grass-addons/grass6/raster/r.pastro/grafico.p
===================================================================
--- grass-addons/grass6/raster/r.pastro/grafico.p	                        (rev 0)
+++ grass-addons/grass6/raster/r.pastro/grafico.p	2013-04-11 14:40:11 UTC (rev 55703)
@@ -0,0 +1,8 @@
+set grid
+set xlabel 'distanza'
+set ylabel 'H'
+set style line 2 lt 2 lw 2
+set terminal gif notransparent size 1200,300
+set nokey
+set output 'immagini/profilo_altimetrico.gif'
+plot 'per_plot3' using 1:2 with line ls 2

Added: grass-addons/grass6/raster/r.pastro/install_r_pastro.sh
===================================================================
--- grass-addons/grass6/raster/r.pastro/install_r_pastro.sh	                        (rev 0)
+++ grass-addons/grass6/raster/r.pastro/install_r_pastro.sh	2013-04-11 14:40:11 UTC (rev 55703)
@@ -0,0 +1,72 @@
+#!/bin/bash
+
+############################################################################
+#
+# MODULE:  	script to install "P.A.S.T.R.O." on GRASS 6.4 (GRASS Shell Script)											
+# AUTHOR:  	Andrea Cervetto (cervoz at hotmail.com)						
+#	   	Damiano Natali (damiano.natali at gmail.com)
+#		Tiziano Cosso (tiziano.cosso at gter.it)
+#		Roberto Marzocchi (roberto.marzocchi at gmail.com)										
+# PURPOSE: 	Utility di calcolo dell'accessibilità in ambito montano	 		
+# COPYRIGHT:	This program is free software under the 
+#		GNU General Public License (>=v2). 		
+# 		Read the file COPYING that comes with GRASS for details.			
+#
+############################################################################
+
+
+if  [ -z "$GISBASE" ]
+then
+	echo ""
+	echo "You must be in GRASS GIS to run this program"
+	echo ""
+	exit 1
+fi
+
+if [ -d "$GISBASE/etc/fortran_code" ]
+then
+ 	echo "The directory $GISBASE/etc/fortran_code already exists'"
+else 
+	echo "The directory $GISBASE/etc/fortran_code do not yet exists. Created!"	
+	mkdir "$GISBASE/etc"/fortran_code
+fi
+
+
+#compilo i codici fortan e li copio nella cartella opportuna
+gfortran-4.6 -o profilo_pastro profilo.f90
+gfortran-4.6 -o distanze_pastro distanze.f90
+sudo cp profilo_pastro "$GISBASE/etc/fortran_code"  
+sudo cp distanze_pastro "$GISBASE/etc/fortran_code" 
+rm profilo_pastro
+rm distanze_pastro 
+  
+#copio i vari scripts nella cartella degli scripts GRASS
+sudo cp r.pastro "$GISBASE/scripts"
+sudo cp sheltgar.sh "$GISBASE/scripts" 
+sudo cp pathgar.sh "$GISBASE/scripts" 
+sudo cp stragfinder.sh "$GISBASE/scripts" 
+sudo cp point2point.sh "$GISBASE/scripts" 
+sudo cp point2path.sh "$GISBASE/scripts"
+sudo cp path_profile.sh "$GISBASE/scripts" 
+sudo cp region_layout.sh  "$GISBASE/scripts" 
+sudo cp region_zoom.sh "$GISBASE/scripts" 
+sudo cp digit_input.sh "$GISBASE/scripts"
+sudo cp grafico.p "$GISBASE/scripts"
+sudo cp space2tab.py "$GISBASE/scripts"
+sudo cp velocity.py "$GISBASE/scripts"
+
+
+
+sudo chmod 777 "$GISBASE/scripts"/r.pastro
+sudo chmod 777 "$GISBASE/scripts"/sheltgar.sh 
+sudo chmod 777 "$GISBASE/scripts"/pathgar.sh 
+sudo chmod 777 "$GISBASE/scripts"/stragfinder.sh 
+sudo chmod 777 "$GISBASE/scripts"/point2point.sh 
+sudo chmod 777 "$GISBASE/scripts"/point2path.sh
+sudo chmod 777 "$GISBASE/scripts"/path_profile.sh 
+sudo chmod 777 "$GISBASE/scripts"/region_layout.sh  
+sudo chmod 777 "$GISBASE/scripts"/region_zoom.sh 
+sudo chmod 777 "$GISBASE/scripts"/digit_input.sh
+sudo chmod 777 "$GISBASE/scripts"/grafico.p
+sudo chmod 777 "$GISBASE/scripts"/space2tab.py
+sudo chmod 777 "$GISBASE/scripts"/velocity.py

Added: grass-addons/grass6/raster/r.pastro/path_profile.py
===================================================================
--- grass-addons/grass6/raster/r.pastro/path_profile.py	                        (rev 0)
+++ grass-addons/grass6/raster/r.pastro/path_profile.py	2013-04-11 14:40:11 UTC (rev 55703)
@@ -0,0 +1,179 @@
+#!/usr/bin/env python
+
+############################################################################
+#
+# MODULE:       path_profile.py
+# AUTHOR(S):	Damiano Natali (damiano.natali at gmail.com)					          #
+#	   	Roberto Marzocchi (roberto.marzocchi at gmail.com)
+#               Converted to Python by Roberto Marzocchi
+# PURPOSE:	Script che fornisce l'immagine del profilo altimetrico di un PERCORSO di tracciato 
+# COPYRIGHT:	(C) 2011 GTER 
+#		This program is free software under the GNU General Public
+#		License (>=v2). Read the file COPYING that comes with GRASS
+#		for details.
+#
+#############################################################################
+#
+
+##################################################
+# librerie chiamate da python
+import sys
+import os
+import string
+import time
+import shutil,re,glob
+import grass.script as grass
+
+space = re.compile(r'\s+')
+multiSpace = re.compile(r"\s\s+")
+##################################################
+
+
+# gli passo le variabili d'ambiente che attualmente sono definite da script di shell e non da script python!!! sara' da cambiare nella conversione definitiva a python!!!
+dtm=os.getenv('dtm')
+folder=os.getenv('folder')
+
+processid = "%.7f" % time.time()
+
+def main():
+	#r.mapcalc "tmp_profilo_dtm=if(!isnull(tmp_drainout),$dtm,null())"
+	grass.mapcalc("${out} = if(!isnull(${rast1}),${rast2},null())",
+                  out = tmp_profilo_dtm,
+                  rast1 = dtm,
+                  rast2 = tmp_walkout)
+        #r.mapcalc "tmp_profilo_costo=if(!isnull(tmp_drainout),tmp_walkout,null())"
+        grass.mapcalc("${out} = if(!isnull(${rast1}),${rast2},null())",
+                  out = tmp_profilo_costo,
+                  rast1 = tmp_drainout,
+                  rast2 = tmp_walkout)
+	#r.mapcalc "tmp_profilo_costo_min=if(!isnull(tmp_drainout),int(tmp_walkout_min),null())"  
+    	grass.mapcalc("${out} = if(!isnull(${rast1}),${rast2},null())",
+                  out = tmp_profilo_costo_min,
+                  rast1 = tmp_drainout,
+                  rast2 = tmp_walkout_min)
+    
+	grass.run_command('r.thin', input = tmp_profilo_costo_min, output=tmp_thinout2, iterations=200 , overwrite = True, quiet = True)
+    	
+  	grass.run_command('r.to.vect', flags='sv' ,input=tmp_thinout2, output = prova_sentiero_costo, feature = line, verwrite = True, quiet = True) 
+  	
+  	grass.run_command('g.remove', rast=tmp_thinout2, quiet = True)
+  	
+  	profilo_dtm=processid + "_profilo_dtm"
+  	costo_profilo=processid + "_costo_profilo"
+  	grass.run_command('r.out.xyz', input=tmp_profilo_dtm, output=folder/profilo_dtm, fs="  ", quiet = True)
+  	grass.run_command('r.out.xyz', input=tmp_profilo_costo, output=folder/costo_profilo, fs=" ", quiet = True) 
+
+
+	E=[]
+	N=[]
+	h=[]
+	costo=[]
+
+	for riga in file("profilo_dtm"):  
+		#print riga
+		line = riga
+		a = space.split(line.strip())
+		# print a
+		E.append(float(a[0]))
+		N.append(float(a[1]))
+		h.append(float(a[2]))
+	for riga in file("costo_profilo"):  
+		#print riga
+		line = riga
+		a = space.split(line.strip())
+		# print a
+		costo.append(float(a[2])) 
+
+	zipped=zip(costo,E,N,h)
+	zipped2=sorted(zipped, key=lambda zipped:zipped[0])   # sort by costo
+	costo1, E1, N1, h1 = zip(*zipped2)
+
+
+
+	# distanza tra i punti del profilo
+	dist=[]
+	dist_or=[]
+	dist_progr=[]
+	pendenza=[]
+
+	from math import sqrt
+	i=0
+	while i<len(E):
+		if i==0:
+			dist.append(0.0)
+			dist_progr.append(0.0)
+			dist_or.append(0.0)
+			pendenza.append(0.0)
+			i+=1
+			# print dist_progr
+		else: 
+			dist.append( sqrt( (E1[i]-E1[i-1])**2+ (N1[i]-N1[i-1])**2 + (h1[i]-h1[i-1])**2 ) )
+			dist_or.append( sqrt( (E1[i]-E1[i-1])**2+ (N1[i]-N1[i-1])**2 ) )
+			dist_progr.append(dist_progr[i-1] + dist[i])
+			pendenza.append( (h1[i]-h1[i-1])/dist_or[i] )
+			#print h1[1]
+			#print i,h1[i],h1[i-1],dist_or[i],pendenza[i]
+			if i==(len(E)-1):
+				dist_finale=dist_progr/1000.0 #distanza in km
+			i+=1
+
+	profilo_grafico=processid + "_profilo_grafico"
+
+	miofile = open(profilo_grafico,'w')
+	k=0
+	while k<len(E):
+		miofile.write("%.2f %.2f %.2f\n" % (round(dist_progr[k],2),round(h1[k],2),round(pendenza[k],2)))
+		#miofile.write("%.2f %.2f %.2f %.2f %.2f\n" % (round(dist[k],2),round(dist_progr[k],2),round(dist_or[k],2),round(h[k],2),round(pendenza[k],2)))
+		k+=1
+	miofile.close()	
+	
+	# cerco la massima pendenza (secondo me non e' il massimo--> discutere con tiziano)
+	pend= max(pendenza)*100
+	
+	####################################################################################
+	#export grafico profilo
+	grafico.gp=processid + "grafico.gp"
+	miofile2 = open(grafico.gp,'w')
+	
+	miofile2.write("set grid\n")
+	miofile2.write("set xlabel 'distanza'\n")
+	miofile2.write("set ylabel 'H'\n")
+	miofile2.write("set style line 2 lt 2 lw 2\n")
+	miofile2.write("set terminal gif notransparent size 1200,300\n")
+	miofile2.write("set nokey\n")
+	miofile2.write("set output 'profilo_altimetrico.gif'\n")
+	miofile2.write("plot '%s_profilo_grafico' using 1:2 with line ls 2\n" % processid)
+	
+	
+	os.getenv('gnuplot' 'miofile')   ###check
+	####################################################################################
+	# info sentiero
+	# export xml file con le informanzioni sul sentiero profilo
+	
+	# output informativo
+	grass.message("*****************************************************************")
+	grass.message("*             CARATTERISTICHE DEL SENTIERO TROVATO              *")
+	grass.message("*                                                               *")
+	grass.message("*    Tempo stimato: %d minuti circa                             *"%(M))
+	grass.message("*    Lunghezza percorso:%.1f km circa                           *"%dist_finale)
+	grass.message("*    Pendenza massima: %.0f%% circa                             *"%pend)
+	grass.message("*                                                               *") 	            
+	grass.message("*****************************************************************")
+	
+	
+	miofile3 = open(info_sentiero.xml,'w')
+	miofile3.write("<documentbody>\n")
+	miofile3.write("*****************************************************************\n")
+	miofile3.write("*             CARATTERISTICHE DEL SENTIERO TROVATO              *\n")
+	miofile3.write("*                                                               *\n")
+	miofile3.write("*    Tempo stimato: %d minuti circa                             *\n"%(M))
+	miofile3.write("*    Lunghezza percorso:%.1f km circa                           *\n"%dist_finale)
+	miofile3.write("*    Pendenza massima: %.0f%% circa                             *\n"%pend)
+	miofile3.write("*                                                               *\n") 	            
+	miofile3.write("*****************************************************************\n")
+	miofile3.write("</documentbody>")
+	
+	
+	
+    	# write cmd history:
+    	#grass.raster_history(output)

Added: grass-addons/grass6/raster/r.pastro/path_profile.sh
===================================================================
--- grass-addons/grass6/raster/r.pastro/path_profile.sh	                        (rev 0)
+++ grass-addons/grass6/raster/r.pastro/path_profile.sh	2013-04-11 14:40:11 UTC (rev 55703)
@@ -0,0 +1,87 @@
+#!/bin/bash
+
+# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
+# MODULE:  "PATH_PROFILE SH" per GRASS 6.4 (GRASS Shell Script)				          #
+#											          #
+# AUTHOR:  Damiano Natali (damiano.natali at gmail.com)					          #
+#	   Roberto Marzocchi (roberto.marzocchi at gmail.com)			          	  #
+# PURPOSE: Script che fornisce l'immagine del profilo altimetrico di un PERCORSO di tracciato     #
+#	   vettoriale imposto dall'utente							  #
+#											  	  #
+# This program is free software under the GNU General Public License (>=v2). 		  	  #
+# Read the file COPYING that comes with GRASS for details.				  	  #
+# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
+
+# ritagliamo il dtm e la mappa di costo sul PERCORSO del sentiero
+#echo 'profilo_dtm=if(!isnull(drainout),dtm10,null())' | r.mapcalc
+#echo 'profilo_costo=if(!isnull(drainout),walkout,null())' | r.mapcalc
+r.mapcalc "tmp_profilo_dtm=if(!isnull(tmp_drainout),$dtm,null())"
+r.mapcalc "tmp_profilo_costo=if(!isnull(tmp_drainout),tmp_walkout,null())"
+r.mapcalc "tmp_profilo_costo_min=if(!isnull(tmp_drainout),int(tmp_walkout_min),null())"
+
+#r.thin input=tmp_profilo_costo_min output=tmp_thinout2 iterations=200 --overwrite --quiet	
+#r.to.vect -s -v input=tmp_thinout2 output=prova_sentiero_costo feature=line --overwrite --quiet
+#g.remove rast=tmp_thinout2
+#v.out.ogr format=GML type=line input=prova_sentiero_costo dsn=$folder/costo.gml --quiet
+#g.remove vect=prova_sentiero_costo
+
+pref=`mcookie`  # magic cookie di 32-caratteri.
+
+# esportiamo il profilo altimetrico e di costo lungo il sentiero
+#g.region res=$res_calcolo
+r.out.xyz input=tmp_profilo_dtm output=$folder/profilo_dtm fs="|" --quiet
+r.out.xyz input=tmp_profilo_costo output=$folder/costo_profilo fs="|" --quiet
+#g.region -a res=$res_calcolo
+
+# prendiamo solamente la parte di file che ci interessa, ovvero la colonna col valore dei raster
+cat $folder/profilo_dtm | cut -d '|' -f 1 > $folder/profilo_N
+cat $folder/profilo_dtm | cut -d '|' -f 2 > $folder/profilo_E
+cat $folder/profilo_dtm | cut -d '|' -f 3 > $folder/profilo_h
+cat $folder/costo_profilo | cut -d '|' -f 3 > $folder/profilo_costo
+
+# troviamo il punto più alto del PERCORSO (secondo me non lo fa?????)
+
+# uniamo i due file in uno unico che abbini l'informazione altimetrica a quella di costo, attraverso un eseguibile in fortran compilato con gfortran e ordiniamolo in base al costo
+
+# unisco i files di output e creo un file con 4 colonne (N,E,h,costo)
+################################################################################################################################
+# quando si installa il file si compilano i files fortran con la seguente sintassi...
+# volendo si potrebbero riscrivere in python ?? che non ha il problema della compilazione ed è anche piu multipiattaforma.. 
+# gfortran -o profilo_pastro profilo.f90
+# gfortran -o distanze_pastro distanze.f90
+################################################################################################################################
+cp "$GISBASE/etc/fortran_code"/profilo_pastro  "$folder"
+cp "$GISBASE/etc/fortran_code"/distanze_pastro  "$folder"
+cp "$GISBASE/scripts"/grafico.p "$folder"
+cd $folder
+touch per_plot
+./profilo_pastro
+
+#ordino il file in funzione del costo
+sort -n -k 4,4 per_plot > per_plot2
+touch per_plot3
+touch info_sentiero
+touch sentiero.txt
+./distanze_pastro
+
+# output informativo
+g.message -i "*****************************************************************"
+g.message -i "*             CARATTERISTICHE DEL SENTIERO TROVATO              *"
+g.message -i "*                                                               *"
+g.message -i "*                                                               *"
+cat info_sentiero
+
+# chiamo uno script python che inserisco tra gli script di grass che mi crea uno shapefile con una polilinea e,
+# per ogni tratto di sentiero, la corrispondente velocita' in km/h
+velocity.py
+v.in.ogr -o -e dsn=sentiero.shp output=tmp_sentiero_trovato --overwrite --quiet
+
+
+# stampiamo l'andamento altimetrico usando gnuplot
+#cd $folder
+gnuplot grafico.p
+#echo "load 'grafico.p'"|gnuplot
+#echo 'exit'|gnuplot
+eog immagini/profilo_altimetrico.gif
+cd ..
+g.remove rast=tmp_profilo_dtm,tmp_profilo_costo --quiet

Added: grass-addons/grass6/raster/r.pastro/pathgar.sh
===================================================================
--- grass-addons/grass6/raster/r.pastro/pathgar.sh	                        (rev 0)
+++ grass-addons/grass6/raster/r.pastro/pathgar.sh	2013-04-11 14:40:11 UTC (rev 55703)
@@ -0,0 +1,104 @@
+#!/bin/bash
+
+# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
+# MODULE:  "PATHGAR SH" per GRASS 6.4 (GRASS Shell Script)				  #
+#											  #
+# AUTHOR:  Andrea Cervetto (cervoz at hotmail.com)			 			  #
+#	   Damiano Natali(damiano.natali at gmail.com)					  #
+#	   Roberto Marzocchi (roberto.marzocchi at gmail.com)			          #
+# PURPOSE: Calcolo del presidio del territorio offerto dalla rete sentieristica presente; #
+#	   Il presente modulo viene solitamente lanciato dallo script pastro.sh.	  #
+#											  #
+# This program is free software under the GNU General Public License (>=v2). 		  #
+# Read the file COPYING that comes with GRASS for details.				  #
+# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
+
+#nome della cartella delle mappe
+#mappe='/home/damiano/spin-off/provincia_spezia/webgis/mappe'
+
+#nome della cartella temporanea
+#percorso='/home/damiano/spin-off/provincia_spezia/webgis/tmp'
+
+# creazione di un report relativo alla regione corrente
+#FILELOG='/home/damiano/spin-off/provincia_spezia/webgis/tmp/filelog/sheltgar.txt'
+FILELOG="$folder/pathgar.txt"
+
+# valutazione del percorso della location
+eval `g.gisenv`
+: ${GISDBASE?} ${LOCATION_NAME?} ${MAPSET?}
+LOCATION="$GISDBASE/$LOCATION_NAME/$MAPSET"
+
+clear
+
+g.message -i "********************************************************************************"
+g.message -i "|                                   PATHGAR. SH                                |"
+g.message -i "| Calcolo del presidio del territorio offertodalla rete sentieristica presente |"
+g.message -i "********************************************************************************"	
+
+
+
+
+################################################################################################
+###   e' realmente necessario????
+################################################################################################
+# zoommiamo sull'area di interesse attraverso uno script apposito
+#region_zoom.sh
+
+# conversione del file vettoriale rappresentante la rete sentieristica da tipo linea a tipo punti:
+# 1) rasterizzazione della mappa dei sentieri
+v.to.rast input=$paths output="tmp_rast"$paths use=val type=line --overwrite --quiet
+# 2) vettorializzazione della mappa dei sentieri come punti
+#r.to.vect input="tmp_rast"$paths output="tmp_punti"$paths feature=point --overwrite --quiet
+# cosi' si velocizza molto il procedimento
+#point_dist=$(($res_calcolo*4))
+#if [$point_dist > 50 ]
+#then
+#	point_dist=50	
+#fi
+point_dist=50
+v.to.points input=$paths output="tmp_punti"$paths type=line dmax=$point_dist --overwrite --quiet
+
+# Creazione della mappa delle friction
+r.slope.aspect elevation=$dtm slope=tmp_slope_percentuale aspect=tmp_aspect format=percent prec=float zfactor=1.0 min_slp_allowed=0.0 --overwrite --quiet 
+# echo 'friction_pendenze=if(slope_percentuale<0.32,2,if(0.32<=slope_percentuale<=0.56,7.5,20))' | r.mapcalc
+
+##############################################################################################################
+## frane e no_guado devono essere definite ??? obbligatori opzionali????
+##############################################################################################################
+
+#r.mapcalc 'tmp_friction_offroad=if(!isnull(tmp_frane),2,if(!isnull(tmp_no_guado),5,if(tmp_slope_percentuale>77,5,1)))'
+r.mapcalc 'tmp_friction_offroad=if(tmp_slope_percentuale>77,5,if(!isnull(tmp_no_guado),5,if(!isnull(tmp_frane),2,1)))'
+#r.mapcalc "tmp_friction_offroad=if(tmp_slope_percentuale>0.77,5,1)" # carta temporanea
+# echo 'friction=if(!isnull("tmp_"$paths"rast"),0,friction_offroad)' | r.mapcalc
+r.mapcalc "tmp_friction=if(!isnull(tmp_rast$paths),0,tmp_friction_offroad)"
+# Calcolo delle aree raggiungibili a partire dai ripari esistenti in meno di tot minuti
+#echo 
+#while ! [ $tmax ]
+#   do echo -n 'Digita la distanza massima in minuti a partire dalla rete sentieristica esistente che si desidera considerare: '
+#   read tmax
+#done
+g.message -i "La distanza massima dai sentieri e' pari a $tmax minuti, ossia $(($tmax*60)) s"
+
+
+r.walk -k elevation=$dtm friction=tmp_friction output=tmp_walkout start_points=tmp_punti$paths max_cost=$(($tmax*60)) percent_memory=10 walk_coeff=$a,$b,$c,$d lambda=1.0 slope_factor=$s_f --overwrite --quiet
+
+#echo 'tmp_walkout=if(tmp_walkout<='$((tmax*60))',tmp_walkout,null())'|r.mapcalc
+#echo 'tmp_walkout_min=walkout/60' | r.mapcalc
+
+r.mapcalc 'tmp_walkout=if(tmp_walkout>'$(($tmax*60))',null(),tmp_walkout)'
+#r.mapcalc 'tmp_walkout=if(tmp_walkout<='$(($tmax*60.0))',tmp_walkout,null())'
+r.mapcalc 'tmp_walkout_min=tmp_walkout/60.0'
+
+
+# visualizziamo a monitor le mappe create, dando la possibilità di interrogarle, e le salviamo nella cartella 
+# /home/damiano/searching/gis&web/mobilita_ambito_montano/tmp
+#region_layout.sh
+
+g.remove rast=tmp_walkout,tmp_friction,tmp_friction_offroad,"tmp_rast"$paths,tmp_slope_percentuale,tmp_aspect,tmp_frane,tmp_no_guado vect="tmp_punti"$paths --quiet
+g.rename rast=tmp_walkout_min,$output --quiet
+
+#g.message -i "PATHGAR module correctly termined"
+g.message -i "Il modulo PATHGAR e' terminato correttamente"
+g.message -i "____________________________________________"
+# torniamo al menù principale
+#pastro.sh

Added: grass-addons/grass6/raster/r.pastro/point2path.sh
===================================================================
--- grass-addons/grass6/raster/r.pastro/point2path.sh	                        (rev 0)
+++ grass-addons/grass6/raster/r.pastro/point2path.sh	2013-04-11 14:40:11 UTC (rev 55703)
@@ -0,0 +1,103 @@
+#!/bin/bash
+
+# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
+# MODULE:  "POINT2PATH SH" per GRASS 6.4 (GRASS Shell Script)				          #
+#											          #
+# AUTHOR:  Andrea Cervetto (cervoz at hotmail.com)						          #
+#	   Damiano Natali (damiano.natali at gmail.com)					          #
+#	   Roberto Marzocchi (roberto.marzocchi at gmail.com)									          	  #
+# PURPOSE: Individua il percorso ottimale tra da due punti e ne calcola il tempo di percorrenza	  #
+#	   Il presente modulo viene solitamente lanciato dallo script pastro.sh.	  	  #
+#											  	  #
+# This program is free software under the GNU General Public License (>=v2). 		  	  #
+# Read the file COPYING that comes with GRASS for details.				  	  #
+# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
+#nome della cartella delle mappe
+#mappe='/home/damiano/spin-off/provincia_spezia/webgis/mappe'
+
+#nome della cartella temporanea
+#percorso='/home/damiano/spin-off/provincia_spezia/webgis/tmp'
+
+# creazione di un report relativo alla regione corrente
+#FILELOG='/home/damiano/spin-off/provincia_spezia/webgis/tmp/filelog/sheltgar.txt'
+FILELOG="$folder/sheltgar.txt"
+
+
+# valutazione del percorso della location
+eval `g.gisenv`
+: ${GISDBASE?} ${LOCATION_NAME?} ${MAPSET?}
+LOCATION="$GISDBASE/$LOCATION_NAME/$MAPSET"
+
+clear
+g.message -i "|************************************************************|"
+g.message -i "|.......................POINT2PATH.SH........................|"
+g.message -i "| Calcolo del percorso ottimale tra un sentiero ed un punto  |"
+g.message -i "|************************************************************|"	
+
+
+# zoommiamo sull'area di interesse attraverso uno script apposito
+#region_zoom.sh
+
+
+
+########################################################################################################################################
+##### DA QUA PULITO
+########################################################################################################################################
+# Creazione della mappa delle friction
+v.to.rast input=$paths output=tmp_rast$paths use=val type=line --overwrite --quiet
+r.slope.aspect elevation=$dtm slope=tmp_slope_percentuale aspect=tmp_aspect format=percent prec=float zfactor=1.0 min_slp_allowed=0.0 --overwrite --quiet
+
+#r.mapcalc 'tmp_friction_offroad=if(!isnull(frane),2,if(!isnull(no_guado),5,if(slope_percentuale>0.77,5,1)))'
+r.mapcalc 'tmp_friction_offroad=if(tmp_slope_percentuale>77,5,if(!isnull(tmp_no_guado),5,if(!isnull(tmp_frane),2,1)))'
+#r.mapcalc "tmp_friction_offroad=if(tmp_slope_percentuale>0.77,5,1)" # carta temporanea
+r.mapcalc "tmp_friction=if(!isnull(tmp_rast$paths),0,tmp_friction_offroad)"
+
+# calcolo mappa di costo
+r.walk -k elevation=$dtm friction=tmp_friction output=tmp_walkout start_points=$partenza max_cost=0 percent_memory=100 nseg=4 walk_coeff=$a,$b,$c,$d lambda=1.0 slope_factor=$s_f --overwrite --quiet
+r.fill.dir -f input=tmp_walkout elevation=tmp_walkout_filled direction=tmp_walkout_dir areas=tmp_areas_walkout --overwrite --quiet
+
+r.mapcalc "tmp_walkout_min=tmp_walkout/60"
+
+
+# ritagliamo la mappa di costo sul vettoriale dei sentieri e troviamone il minimo
+r.mapcalc "tmp_costo_sentiero=if(!isnull(tmp_rast$paths),tmp_walkout,null())"
+#echo 'costo_sentiero=if(!isnull(tmp_$paths_rast),tmp_walkout,null())' | r.mapcalc
+r.info -r map=tmp_costo_sentiero > $folder/info1
+cut $folder/info1 -d \= -f 2 > $folder/info2
+ris=$(cat $folder/info2)
+min=$(echo $ris | cut -d ' ' -f 1)
+cost_max=$(echo $ris | cut -d ' ' -f 2)
+min1=$(echo $min | cut -d \. -f 1)
+min_approx=$(expr $min1 + 1)
+r.mapcalc "tmp_punto_minimo_rast=if(tmp_costo_sentiero<=$min_approx,tmp_costo_sentiero,null())"
+# echo 'tmp_punto_minimo_rast=if(costo_sentiero<='$min_approx',tmp_costo_sentiero,null())'|r.mapcalc
+
+# trasformiamo il punto di minimo da raster a vettoriale
+r.to.vect input=tmp_punto_minimo_rast output=tmp_stop_point feature=point --overwrite --quiet 
+
+# calcola il percorso a minima energia
+r.drain -c input=tmp_walkout_filled output=tmp_drainout vector_points=tmp_stop_point --overwrite --quiet
+g.remove rast=tmp_walkout_filled,tmp_walkout_dir,tmp_areas_walkout --quiet
+
+# creazione del vettoriale del percorso
+r.thin input=tmp_drainout output=tmp_thinout iterations=200 --overwrite	--quiet
+r.to.vect -s input=tmp_thinout output=tmp_sentiero_trovato feature=line --overwrite --quiet
+
+# creiamo il profilo del sentiero e stampiamolo con gnuplot, salvando poi l'immagine: tutto questo attraverso un modulo dedicato
+path_profile.sh
+# visualizziamo a monitor le mappe create, dando la possibilità di interrogarle, e le salviamo nella cartella 
+region_layout2.sh
+
+# Esportiamo quanto visualizzato sul monitor come immagine, in modo che possa essere visualizzata ad esempio su un browser
+#rm $folder/immagini/immagine.png
+#d.out.file output=$folder/immagini/immagine format=png resolution=2 compression=9 quality=75 paper=a4 ps_level=2
+
+g.remove rast=tmp_walkout,tmp_walkout_min,tmp_friction,tmp_friction_offroad,tmp_rast$paths,tmp_slope_percentuale,tmp_aspect --quiet
+g.remove rast=tmp_drainout,tmp_thinout,tmp_punto_minimo_rast,tmp_costo_sentiero vect=tmp_stop_point,tmp_frane,tmp_no_guado --quiet
+g.rename vect=tmp_sentiero_trovato,$output --quiet
+g.remove vect=tmp_partenza --quiet
+
+g.message -i "Il modulo POINT2PATH e' terminato correttamente"
+g.message -i "_______________________________________________"
+# torniamo al menù principale
+#pastro.sh

Added: grass-addons/grass6/raster/r.pastro/point2point.sh
===================================================================
--- grass-addons/grass6/raster/r.pastro/point2point.sh	                        (rev 0)
+++ grass-addons/grass6/raster/r.pastro/point2point.sh	2013-04-11 14:40:11 UTC (rev 55703)
@@ -0,0 +1,106 @@
+#!/bin/bash
+
+# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
+# MODULE:  "POINT2POINT SH" per GRASS 6.4 (GRASS Shell Script)				          #
+#											          #
+# AUTHOR:  Andrea Cervetto (cervoz at hotmail.com)						          #
+#	   Damiano Natali (damiano.natali at gmail.com)					          #
+#	   Roberto Marzocchi (roberto.marzocchi at gmail.com)			          	  #
+# PURPOSE: Individua il PERCORSO ottimale tra da due punti e ne calcola il tempo di percorrenza	  #
+#	   Il presente modulo viene solitamente lanciato dallo script pastro.sh.	  	  #
+#											  	  #
+# This program is free software under the GNU General Public License (>=v2). 		  	  #
+# Read the file COPYING that comes with GRASS for details.				  	  #
+# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
+
+
+
+# creazione di un report relativo alla regione corrente
+#FILELOG='/home/damiano/spin-off/provincia_spezia/webgis/tmp/filelog/sheltgar.txt'
+FILELOG="$folder/sheltgar.txt"
+
+# valutazione del percorso della location
+eval `g.gisenv`
+: ${GISDBASE?} ${LOCATION_NAME?} ${MAPSET?}
+LOCATION="$GISDBASE/$LOCATION_NAME/$MAPSET"
+
+clear
+
+g.message -i "*********************************"
+g.message -i "|        POINT2POINT.SH         |"
+g.message -i "| Calcolo del PERCORSO ottimale |"
+g.message -i "|     tra due punti imposti     |"
+g.message -i "*********************************"	
+
+
+
+
+
+########################################################################################################################################
+##### DA QUA PULITO
+########################################################################################################################################
+
+# creazione della mappa delle friction
+v.to.rast input=$paths output=tmp_rast$paths use=val type=line --overwrite --quiet
+r.slope.aspect elevation=$dtm slope=tmp_slope_percentuale aspect=tmp_aspect format=percent prec=float zfactor=1.0 min_slp_allowed=0.0 --overwrite --quiet 
+
+
+#r.mapcalc 'tmp_friction_offroad=if(!isnull(frane),2,if(tmp_slope_percentuale>0.77,5,1))'
+r.mapcalc 'tmp_friction_offroad=if(tmp_slope_percentuale>77,5,if(!isnull(tmp_no_guado),5,if(!isnull(tmp_frane),2,1)))'
+#r.mapcalc "tmp_friction_offroad=if(tmp_slope_percentuale>0.77,5,1)" # carta temporanea
+r.mapcalc "tmp_friction=if(!isnull(tmp_rast$paths),0,tmp_friction_offroad)"
+# echo 'tmp_friction_offroad=if(tmp_slope_percentuale>0.77,5,1)' | r.mapcalc
+# echo 'tmp_friction=if(!isnull(tmp_sentieri_rast),0,tmp_friction_offroad)' | r.mapcalc
+
+
+#####DEBUG ROBERTO #########
+#conviene aggiungere un filling perche' per percorsi lunghi i sink del dtm creano dei problemi...
+#direi che ora funziona tutto bene
+r.fill.dir -f input=$dtm elevation=tmp_dtm_filled direction=tmp_dtm_dir areas=tmp_areas_dtm --overwrite --quiet
+
+
+# calcolo mappa di costo in secondi e in minuti
+#r.walk -k elevation=$dtm friction=tmp_friction output=tmp_walkout start_points=$partenza stop_points=$arrivo max_cost=0 percent_memory=100 nseg=4 walk_coeff=$a,$b,$c,$d lambda=1.0 slope_factor=$s_f --overwrite --quiet
+
+r.mapcalc "tmp_friction2=tmp_friction*30"
+r.walk -k elevation=tmp_dtm_filled friction=tmp_friction output=tmp_walkout start_points=$partenza stop_points=$arrivo max_cost=0 percent_memory=100 nseg=4 walk_coeff=$a,$b,$c,$d lambda=1.0 slope_factor=$s_f --overwrite --quiet
+
+g.remove rast=tmp_dtm_filled,tmp_dtm_dir,tmp_areas_dtm --quiet
+
+#####DEBUG ROBERTO ######### 
+#conviene aggiungere un filling perche' per percorsi lunghi sembrano crearsi dei sink...la ragione non e' chiarissima --> forse e' il caso di approfondire
+#r.fill.dir input=tmp_walkout elevation=tmp_walkout_filled direction=tmp_walkout_dir --overwrite --quiet
+
+r.mapcalc 'tmp_walkout_min=tmp_walkout/60'
+#echo 'walkout_min=walkout/60' | r.mapcalc
+ 
+# calcola il PERCORSO a minima energia
+#nuovo filling (solo sulle unrisolved areas!!!)
+r.fill.dir -f input=tmp_walkout elevation=tmp_walkout_filled direction=tmp_walkout_dir areas=tmp_areas_walkout --overwrite --quiet
+r.drain -c input=tmp_walkout_filled output=tmp_drainout vector_points=$arrivo --overwrite --quiet
+g.remove rast=tmp_walkout_filled,tmp_walkout_dir,tmp_areas_walkout --quiet
+
+r.mapcalc "tmp_drainout2=if(!isnull(tmp_drainout),if(!isnull(tmp_rast$paths),1,2),null())"
+
+# creazione del vettoriale del PERCORSO (messo dentro path_profile.sh)
+#r.thin input=tmp_drainout2 output=tmp_thinout iterations=200 --overwrite --quiet
+#r.to.vect -s -v input=tmp_thinout output=tmp_sentiero_trovato feature=line --overwrite --quiet
+
+# creiamo il profilo del sentiero e stampiamolo con gnuplot, salvando poi l'immagine: tutto questo attraverso un modulo dedicato
+path_profile.sh
+
+# visualizziamo a monitor le mappe create, dando la possibilità di interrogarle, e le salviamo nella cartella 
+# $folder/tmp
+region_layout.sh
+
+
+g.remove rast=tmp_walkout,tmp_walkout_min,tmp_friction,tmp_friction_offroad --quiet
+g.remove  rast="tmp_rast"$paths,tmp_slope_percentuale,tmp_aspect,tmp_drainout,tmp_thinout,tmp_frane,tmp_no_guado --quiet
+g.remove vect=tmp_arrivo,tmp_partenza --quiet
+
+g.rename vect=tmp_sentiero_trovato,$output --quiet --overwrite
+
+g.message -i "Il modulo POINT2POINT e' terminato correttamente"
+g.message -i "________________________________________________"
+# torniamo al menù principale
+#pastro.sh

Added: grass-addons/grass6/raster/r.pastro/profilo.f90
===================================================================
--- grass-addons/grass6/raster/r.pastro/profilo.f90	                        (rev 0)
+++ grass-addons/grass6/raster/r.pastro/profilo.f90	2013-04-11 14:40:11 UTC (rev 55703)
@@ -0,0 +1,31 @@
+program profilo
+implicit none
+
+integer::i,j,k
+real::a,dist
+real(kind=8),allocatable::prof(:,:),plot(:,:)
+
+open(8,FILE='./profilo_N',STATUS='OLD')
+open(9,FILE='./profilo_E',STATUS='OLD')
+open(10,FILE='./profilo_h',STATUS='OLD')
+open(11,FILE='./profilo_costo',STATUS='OLD')
+open(12,FILE='./per_plot',STATUS='OLD')
+k=0
+do
+   read(8,*,end=100)a
+   k=k+1
+end do
+100 allocate(prof(k,4))
+allocate(plot(k,2))
+rewind(8)
+do i=1,k
+   read(8,*)prof(i,1)
+   read(9,*)prof(i,2)
+   read(10,*)prof(i,3)
+   read(11,*)prof(i,4)
+end do
+do i=2,k
+   write(12,'(F12.3,2X,F12.3,2X,F12.3,2X,F12.3)')prof(i,1),prof(i,2),prof(i,3),prof(i,4)
+end do
+
+end

Added: grass-addons/grass6/raster/r.pastro/r.pastro
===================================================================
--- grass-addons/grass6/raster/r.pastro/r.pastro	                        (rev 0)
+++ grass-addons/grass6/raster/r.pastro/r.pastro	2013-04-11 14:40:11 UTC (rev 55703)
@@ -0,0 +1,866 @@
+#!/bin/sh
+
+############################################################################
+#
+# MODULE:  	"P.A.S.T.R.O." per GRASS 6.4 (GRASS Shell Script)											
+# AUTHOR:  	Andrea Cervetto (cervoz at hotmail.com)						
+#	   	Damiano Natali (damiano.natali at gmail.com)
+#		Tiziano Cosso (tiziano.cosso at gter.it)
+#		Roberto Marzocchi (roberto.marzocchi at gmail.com)										
+# PURPOSE: 	Utility di calcolo dell'accessibilità in ambito montano	 		
+# COPYRIGHT:	This program is free software under the 
+#		GNU General Public License (>=v2). 		
+# 		Read the file COPYING that comes with GRASS for details.			
+#
+############################################################################
+
+
+#%Module
+#%  description: Tools for the management of mobility in the mountain environment
+#%End
+
+###########################################################################################################
+# Tolto il required yes si puo' dare il nome alla guisection  
+###########################################################################################################
+#%option
+#%guisection:P.A.S.T.R.O.general
+#% key: DTM
+#% type: string
+#% gisprompt: old,cell,raster
+#% description: Input DTM (richiesto)
+#% required : no
+#%end
+
+#%option
+#%guisection:P.A.S.T.R.O.general
+#% key: PATHS
+#% type: string
+#% gisprompt: old,vector,vector
+#% description: Carta dei sentieri (richiesta)
+#% required : no
+#%end
+
+#%option
+#%guisection:P.A.S.T.R.O.general
+#% key: SHELTERS
+#% type: string
+#% gisprompt: old,vector,vector
+#% description: Carta dei rifugi esistenti
+#% required : no
+#%end
+
+#%option
+#%guisection:P.A.S.T.R.O.general
+#% key: FUNCTION
+#% type: string
+#% description: selezione modulo P.A.S.T.R.O. 
+#% options:1 - Calcolo dell'area presidiata dall'attuale insieme di rifugi (SHELTGAR),2 - Calcolo dell'area presidiata dall'attuale rete sentieristica (PATHGAR),3 - Calcolo della porzione di territorio raggiungibile da un punto (STRAGFINDER),4 - Calcolo del percorso ottimale tra due punti (POINT2POINT),5 - Calcolo del percorso ottimale tra un punto e un sentiero (POINT2PATH)
+## 6 - Calcolo della lunghezza e tempo di percorrenza di un assegnato sentiero [manca script]
+#% answer:1 - Calcolo dell'area presidiata dall'attuale insieme di rifugi (SHELTGAR)
+#% required : no
+#%end
+
+#%option
+#%guisection:P.A.S.T.R.O.general
+#% key: FOLDER
+#% type: string
+#% gisprompt: folder,output
+#% description: Output folder (required)
+#% required : no
+#%end
+
+##############################################################################################
+## 0 - general options
+##############################################################################################
+
+#%option
+#% key: FRANE
+#% type: string
+#% gisprompt: old,cell,raster
+#% description: Carta con le aree in frana (opzionale)
+#% required : no
+#%end
+
+#%option
+#% key: FIUMI_NO_GUADO
+#% type: string
+#% gisprompt: old,cell,raster
+#% description: Carta raster con i fiumi non guadabili (opzionale)
+#% required : no
+#%end
+
+#%option
+#% key: IMAGE
+#% type: string
+#% gisprompt: old,cell,raster
+#% description: Background image
+#% required : no
+#%end
+#%option
+#% key: RES
+#% type: integer
+#% gisprompt: new
+#% description: a quale risoluzione effettuare il calcolo [di default usa quella iniziale]
+#% required : no
+#%end
+
+#%option
+#% key: WALK_COEFF_A
+#% type: double
+#% description: r.walk coefficient (a)
+#% answer: 0.72
+#% required : no
+#%end
+
+#%option
+#% key: WALK_COEFF_B
+#% type: double
+#% description: r.walk coefficient (b)
+#% answer: 6.0
+#% required : no
+#%end
+
+#%option
+#% key: WALK_COEFF_C
+#% type: double
+#% description: r.walk coefficient (c)
+#% answer: 1.9998
+#% required : no
+#%end
+
+#%option
+#% key: WALK_COEFF_D
+#% type: double
+#% description: r.walk coefficient (d)
+#% answer: -1.9998
+#% required : no
+#%end
+
+#%option
+#% key: WALK_COEFF_S_F
+#% type: double
+#% description: r.walk slope factor coefficient (s_f)
+#% answer: -0.2125
+#% required : no
+#%end
+
+##############################################################################################
+## 1 - sheltgar
+##############################################################################################
+#%option
+#%guisection:SHELTGAR
+#% key: TMAX_SHELTGAR
+#% type: string
+#% description: Distanza massima in minuti a partire dai ripari esistenti che si desidera considerare
+#% required : no
+#%end
+#%option
+#%guisection:SHELTGAR
+#% key: OUT_SHELTGAR
+#% type: string
+#% gisprompt: new
+#% description: Nome della mappa contenente la distanza in minuti dai ripari esistenti
+#% required : no
+#%end
+
+
+##############################################################################################
+## 2 - pathgar
+##############################################################################################
+#%option
+#%guisection:PATHGAR
+#% key: TMAX_PATHGAR
+#% type: string
+#% description: Distanza massima in minuti a partire dalla rete sentieristica che si desidera considerare
+#% required : no
+#%end
+#%option
+#%guisection:PATHGAR
+#% key: OUT_PATHGAR
+#% type: string
+#% gisprompt: new
+#% description: Nome della mappa contenente la distanza in minuti dalla rete sentieristica
+#% required : no
+#%end
+##############################################################################################
+## 3 - stragfinder
+##############################################################################################
+#%flag
+#%guisection:STRAGFINDER
+#% key: s
+#% description: Immissione interattiva del punto in cui e' avvenuta la scomparsa 
+#%end
+
+#%option
+#%guisection:STRAGFINDER
+#% key: LAST_OBS_KML
+#% type: string
+#% gisprompt: old_file,file,input
+#% description: KML file del punto dell'ultimo avvistamento
+#% required : no
+#%end
+
+#%option
+#%guisection:STRAGFINDER
+#% key: LAST_OBS
+#% type: string
+#% gisprompt: old,vector,vector
+#% description: Punto dell'ultimo avvistamento
+#% required : no
+#%end
+
+#%option
+#%guisection:STRAGFINDER
+#% key: DAY
+#% type: string
+#% description: giorno dell'ultimo avvistamento [oggi/ieri/altroieri]
+#% options: oggi,ieri,altroieri
+#% answer: oggi
+#% required : no
+#%end
+
+#%option
+#%guisection:STRAGFINDER
+#% key: HH
+#% type: double
+#% description: ora dell'ultimo avvistamento [24 h]
+#% options: 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24
+#% answer: 1
+#% required : no
+#%end
+
+#%option
+#%guisection:STRAGFINDER
+#% key: MM
+#% type: double
+#% description: minuto dell'ultimo avvistamento
+#% options: 00,01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59
+#% answer: 00
+#% required : no
+#%end
+
+#%option
+#%guisection:STRAGFINDER
+#% key: OUT_STRAGFINDER
+#% type: string
+#% gisprompt: new
+#% description: Nome della mappa contenente la distanza in minuti dalla rete sentieristica
+#% required : no
+#%end
+
+##############################################################################################
+## 4 - point2point
+##############################################################################################
+#%flag
+#%guisection:POINT2POINT
+#% key: p
+#% description: Immissione interattiva dei punti di inizio e fine del sentiero 
+#%end
+
+#%option
+#%guisection:POINT2POINT
+#% key: START_POINT_KML
+#% type: string
+#% gisprompt: old_file,file,input
+#% description: KML del punto da cui si vuole fare partire il sentiero
+#% required : no
+#%end
+
+#%option
+#%guisection:POINT2POINT
+#% key: END_POINT_KML
+#% type: string
+#% gisprompt: old_file,file,input
+#% description: KML del punto in cui deve arrivare il sentiero
+#% required : no
+#%end
+
+#%option
+#%guisection:POINT2POINT
+#% key: START_POINT
+#% type: string
+#% gisprompt: old,vector,vector
+#% description: Punto da cui si vuole fare partire il sentiero
+#% required : no
+#%end
+
+#%option
+#%guisection:POINT2POINT
+#% key: END_POINT
+#% type: string
+#% gisprompt: old,vector,vector
+#% description: Punto in cui deve arrivare il sentiero
+#% required : no
+#%end
+
+#%option
+#%guisection:POINT2POINT
+#% key: OUT_POINT2POINT
+#% type: string
+#% gisprompt: new
+#% description: Nome della mappa contenente il percorso trovato fra i due punti
+#% required : no
+#%end
+
+##############################################################################################
+## 5 - point2path
+##############################################################################################
+###input eventuali (si veda stragfinder)
+#%flag
+#%guisection:POINT2PATH
+#% key: z
+#% description: Immissione interattiva dei punti da cui si vuole raggiungere la rete sentieristica 
+#%end
+
+#%option
+#%guisection:POINT2PATH
+#% key: START_POINT2_KML
+#% type: string
+#% gisprompt: old_file,file,input
+#% description: KML del punto da cui si vuole fare partire il sentiero
+#% required : no
+#%end
+
+#%option
+#%guisection:POINT2PATH
+#% key: START_POINT2
+#% type: string
+#% gisprompt: old,vector,vector
+#% description: Punto da cui si vuole fare partire il sentiero
+#% required : no
+#%end
+
+#%option
+#%guisection:POINT2PATH
+#% key: OUT_POINT2PATH
+#% type: string
+#% gisprompt: new
+#% description: Nome della mappa contenente il percorso trovato fra i due punti
+#% required : no
+#%end
+
+
+
+
+if  [ -z "$GISBASE" ]
+then
+	echo ""
+	echo "You must be in GRASS GIS to run this program"
+	echo ""
+	exit 1
+fi
+
+if [ "$1" != "@ARGS_PARSED@" ] ; then
+  exec g.parser "$0" "$@"
+fi
+
+$GRASS_VERBOSE
+PROG=`basename $0`
+#request control & test (only for imput map)
+if [ -z "$GIS_OPT_DTM" ] ; then
+  g.message -e "ERROR: DTM not specified"
+  exit 1
+fi
+
+#directory corrente 
+act_dir=`pwd`
+
+
+if [ -z "$GIS_OPT_DTM" ] ; then
+  #g.message -e "ERROR: DTM not specified"
+  g.message -e "ERRORE: DTM non specificato"
+  exit 1
+fi
+
+if [ -z "$GIS_OPT_PATHS" ] ; then
+  #g.message -e "ERROR: Paths map not specified"
+  g.message -e "ERRORE: carta dei sentieri non specificata"
+  exit 1
+fi
+
+if [ -z "$GIS_OPT_SHELTERS" ] ; then
+	g.message " "  
+else 
+	shelters="$GIS_OPT_SHELTERS"
+fi
+
+export a
+export b
+export c
+export d 
+export s_f
+export tmp_frane
+export tmp_no_guado
+
+if [ -z "$GIS_OPT_FRANE" ] ; then	
+	r.mapcalc 'tmp_frane=null()'
+	g.message -w "Non è stata definita una carta delle frane"
+else
+	tmp_frane="$GIS_OPT_FRANE"
+	g.copy rast=$tmp_frane,tmp_frane
+fi
+
+if [ -z "$GIS_OPT_FIUMI_NO_GUADO" ] ; then	
+	r.mapcalc 'tmp_no_guado=null()'
+	g.message -w "Non è stata definita una carta con i fiumi non guadabili"
+else
+	tmp_no_guado="$GIS_OPT_FIUMI_NO_GUADO"
+	g.copy rast=$tmp_no_guado,tmp_no_guado
+fi
+
+if [ -z "$GIS_OPT_WALK_COEFF_A" ] ; then	
+	a=0.72
+	g.message -w "Il coefficiente a di r.walk non e'stato specificato, per cui verra' utilizzato il valore di default $a"
+else
+	a="$GIS_OPT_WALK_COEFF_A"
+fi
+
+if [ -z "$GIS_OPT_WALK_COEFF_B" ] ; then	
+	b=6.0
+	g.message -w "Il coefficiente a di r.walk non e'stato specificato, per cui verra' utilizzato il valore di default $b"
+else
+	b="$GIS_OPT_WALK_COEFF_B"
+fi
+if [ -z "$GIS_OPT_WALK_COEFF_C" ] ; then	
+	c=1.9998
+	g.message -w "Il coefficiente a di r.walk non e'stato specificato, per cui verra' utilizzato il valore di default $c"
+else
+	c="$GIS_OPT_WALK_COEFF_C"
+fi
+
+if [ -z "$GIS_OPT_WALK_COEFF_D" ] ; then	
+	d=6.0
+	g.message -w "Il coefficiente a di r.walk non e'stato specificato, per cui verra' utilizzato il valore di default $d"
+else
+	d="$GIS_OPT_WALK_COEFF_D"
+fi
+
+if [ -z "$GIS_OPT_WALK_COEFF_D" ] ; then	
+	d=-1.9998
+	g.message -w "Il coefficiente a di r.walk non e'stato specificato, per cui verra' utilizzato il valore di default $d"
+else
+	d="$GIS_OPT_WALK_COEFF_D"
+fi
+
+if [ -z "$GIS_OPT_WALK_COEFF_S_F" ] ; then	
+	s_f=-0.2125
+	g.message -w "Il coefficiente a di r.walk non e'stato specificato, per cui verra' utilizzato il valore di default $s_f"
+else
+	s_f="$GIS_OPT_WALK_COEFF_S_F"
+fi
+
+g.message -i "************"
+g.message -i "P.A.S.T.R.O."
+g.message -i "************"
+
+#Assegnazione delle variabili globali (dette anche d'ambiente) - lo faro' dopo anche per i singoli scripts
+#echo "dtm="$dtm";export dtm">>$HOME/.bash_profile
+export dtm
+#echo "paths="$paths";export paths">>$HOME/.bash_profile
+export paths
+#echo "shelters="$shelters";export shelters">>$HOME/.bash_profile
+export shelters
+#echo "folder="$folder";export folder">>$HOME/.bash_profile
+export folder
+# le definisco
+dtm="$GIS_OPT_DTM"
+paths="$GIS_OPT_PATHS"
+if [ -z "$GIS_OPT_FOLDER" ]
+	then
+	#g.message -w "Output map is not defined, no output map is written"
+	g.message -w "La cartella dove salvare i files di output non e' definita"
+	folder="PASTRO_output_folder"
+	g.message -w "La carta di output sara' chiamata $output e se esistente verra' sovrascritta di default"
+else
+	folder="$GIS_OPT_FOLDER"
+fi
+
+#optional control:assignement default value
+#echo "res_calcolo="$res_calcolo";export res_calcolo" >> $HOME/.bash_profile
+#echo "image="$image";export image" >> $HOME/.bash_profile
+#echo "check_image="$check_image";export check_image" >> $HOME/.bash_profile
+export res_calcolo
+export image
+export check_image
+
+
+if [ -n "$GIS_OPT_IMAGE" ]
+then
+  check_image=2
+  image="$GIS_OPT_IMAGE"
+else # metto la shaded relief???
+  g.region save=tmp_curr_reg --overwrite
+  g.region rast=$dtm save=tmpdtm --overwrite
+  r.shaded.relief map=$dtm shadedmap=temp_shade --overwrite --quiet
+  g.region region=tmp_curr_reg
+  g.remove region=tmpdtm --quiet
+  check_image=1
+  image="$GIS_OPT_DTM"
+fi   
+
+#creo una carta della regione corrente che eventualmente si puo' visualizzare a monitor
+v.in.region --overwrite --quiet output=temp_regione type=line
+#g.message -i "Sul monitor sono rappresentati i limiti della regione corrente"
+
+#Risoluzione di calcolo
+g.region -p > .resolution.txt
+exec 6<&0          
+exec < .resolution.txt  
+read a1 b1            
+read a2 b2
+read a3 b3
+read a4 b4
+read a5 b5
+read a6 b6
+read a7 b7
+read a8 b8
+read a9 b9
+exec 0<&6 6<&-
+resolution=$b9
+
+if [ -n "$GIS_OPT_RES" ]
+then
+	res_calcolo="$GIS_OPT_RES"
+	g.message -i "Come desiderato i calcoli saranno effettuati a una risoluzione pari a $res_calcolo metri" 
+	g.region -a res=$res_calcolo 
+else
+	res_calcolo=$resolution
+	g.message -i "Da default i calcoli saranno effettuati con la risoluzione iniziale pari a $resolution metri"
+fi   
+g.region -a res=$res_calcolo
+
+#Assegnazione globale delle variabili
+#echo "mappe="$mappe";export mappe">>$HOME/.bash_profile
+#echo "percorso"$percorso";export percorso">>$HOME/.bash_profile
+export mappe 
+export percorso
+
+
+if [ -d $folder ] # Verifica l’esistenza della directory indicata.
+then 
+	#g.message -w "The $folder directory is yet present, the output files will be overwritten" # esiste la directory --> warning sui file di output che verranno sovrascritti
+	g.message -w "La cartella $folder esiste gia', per cui verra' sovrascritta" 
+	#g.message -i "The output file will be written in the $folder directory"
+	g.message -i "Eventuali outputs saranno pertanto salvati nella cartella $folder, secondo quanto prescelto"
+else
+	mkdir $folder  # non esiste la directory --> la creo
+	mappe="$folder/mappe"
+	percorso="$folder/tmp"
+	mkdir $mappe
+	mkdir $percorso
+	mkdir $folder/"immagini"
+	#g.message -i "The output file will be written in the $folder directory"
+	g.message -i "Eventuali outputs saranno pertanto salvati nella cartella $folder, secondo quanto prescelto" 
+fi
+#exit 0
+
+# valutazione del percorso della location(SERVE QUA???)
+eval `g.gisenv`
+: ${GISDBASE?} ${LOCATION_NAME?} ${MAPSET?}
+LOCATION="$GISDBASE/$LOCATION_NAME/$MAPSET"
+
+
+
+#********************************************************************************************************
+# LANCIO IL MODULO P.A.S.T.R.O. PRESCELTO
+#********************************************************************************************************
+# rendiamo la variabile "FUNCTION" una variabile d'ambiente, in modo da poterla richiamare anche negli script successivi
+#Definisco e controllo anche le altre variabili d'ambiente e poi entro nel singolo modulo
+g.message -i "__________________________________________"
+g.message -i "Ho selezionato l'opzione $GIS_OPT_FUNCTION"
+g.message -i "__________________________________________"
+#echo "FUNCTION="$FUNCTION";export FUNCTION">>$HOME/.bash_profile
+export FUNCTION
+export output
+
+#source $HOME/.bash_profile
+#********************************************************************************************************
+# SHELTGAR Calcolo dell'area presidiata dall'attuale insieme di rifugi
+
+if [ "$GIS_OPT_FUNCTION" = "1 - Calcolo dell'area presidiata dall'attuale insieme di rifugi (SHELTGAR)" ]
+	then 
+	FUNCTION=1
+	#echo "tmax="$tmax";export tmax">>$HOME/.bash_profile
+	#echo "output="$output";export output">>$HOME/.bash_profile
+	export tmax
+	export output
+	if [ -z "$GIS_OPT_SHELTERS" ] ; then
+  		#g.message -e "ERROR: Shelters map not specified"
+  		g.message -e "ERRORE: carta dei rifugi non specificata"  
+  		exit 1
+	fi
+	shelters="$GIS_OPT_SHELTERS"	
+	if [ -z "$GIS_OPT_TMAX_SHELTGAR" ] ; then
+		#g.message -e "ERROR: the distance from the shelters is not defined"
+		#g.message -i "Please set a specific distance from the shelters and restart the module"
+		g.message -e "ERRORE: la massima distanza dai rifugi non e' stata definita"
+		g.message -i "Per cortesia inserisci tale valore e lancia nuovamente il comando"
+		exit 1
+	fi
+	if [ -z "$GIS_OPT_OUT_SHELTGAR" ]
+		then
+		g.message -w "Il nome della mappa di output non e' definito"
+		output="output_sheltgar"
+		g.message -w "La carta di output sara' chiamata $output e se esistente verra' sovrascritta di default"
+		g.remove rast=$output --quiet
+	else
+		output="$GIS_OPT_OUT_SHELTGAR"
+	fi
+
+	tmax="$GIS_OPT_TMAX_SHELTGAR"
+	
+	sheltgar.sh 
+fi
+#********************************************************************************************************
+# PATHGAR - Calcolo dell'area presidiata dall'attuale rete sentieristica
+
+if [ "$GIS_OPT_FUNCTION" = "2 - Calcolo dell'area presidiata dall'attuale rete sentieristica (PATHGAR)" ] 
+	then
+	g.message -i "OK" 
+	FUNCTION=2
+	export tmax
+	export output
+	if [ -z "$GIS_OPT_TMAX_PATHGAR" ] ; then
+		#g.message -e "ERROR: the distance from the paths is not defined"
+		#g.message -i "Please set a specific distance from the paths and restart the module"
+		g.message -e "ERRORE: la massima distanza dai sentieri non e' stata definita"
+		g.message -i "Per cortesia inserisci tale valore e lancia nuovamente il comando"
+	exit 1
+	fi
+	if [ -z "$GIS_OPT_OUT_PATHGAR" ]
+		then
+		#g.message -w "Output map is not defined, no output map is written"
+		g.message -w "Il nome della mappa di output non e' definito"
+		output="output_pathgar"
+		g.message -w "La carta di output sara' chiamata $output e se esistente verra' sovrascritta di default"
+	else
+		output="$GIS_OPT_OUT_PATHGAR"
+	fi
+	#echo "tmax="$tmax";export tmax">>$HOME/.bash_profile
+	#echo "output="$output";export output">>$HOME/.bash_profile
+	tmax="$GIS_OPT_TMAX_PATHGAR"	
+	pathgar.sh
+fi
+#********************************************************************************************************
+# Calcolo dell'area raggiungibile da un punto
+
+if [ "$GIS_OPT_FUNCTION" = "3 - Calcolo della porzione di territorio raggiungibile da un punto (STRAGFINDER)" ]	; then 
+	FUNCTION=3
+	#echo "last_obs="$last_obs";export last_obs" >> $HOME/.bash_profile
+	export last_obs
+	# flag e eventualmente richiama la funzione 
+	#test flag
+	if [ "$GIS_FLAG_s" -eq 1 ] ; then
+		# Impostazione della risoluzione di calcolo
+		#g.region res=$RES_DTM
+		g.message -i "Acquisizione del punto e dell'orario in cui è stato visto per l'ultima volta il disperso"	
+		#echo "input"$input";export input">>$HOME/.bash_profile	
+		export input
+		digit_input.sh
+		last_obs=digitato
+	else
+		if [ ! -z "$GIS_OPT_LAST_OBS_KML" ] ; then
+			input_kml="$GIS_OPT_LAST_OBS_KML"
+			g.proj -w > .current_loc.wtk
+			ogr2ogr -s_srs "EPSG:4326" -t_srs '".current_loc.wtk"' tmp_output.kml $input_kml
+			v.in.ogr -z -o -e dsn=tmp_output.kml output=last_obs_kml --overwrite --quiet
+			rm .current_loc.wtk
+			rm -r tmp_output.kml
+			last_obs=last_obs_kml
+		else
+			if [ -z "$GIS_OPT_LAST_OBS" ] ; then
+				#g.message -e "ERROR: the point of the last observation is not defined"
+				#g.message -i "Please set a vector map or create it interatvely using the specific flag (i)"
+				g.message -e "ERRORE: il punto dove si e' visto per l'ultima volta il disperso non e' stato definito"
+				g.message -i "Per cortesia specifica un input e lancia nuovamente il comando"
+				exit 1
+			else
+				last_obs="$GIS_OPT_LAST_OBS"
+			fi
+		fi
+	fi
+	if [ -z "$GIS_OPT_DAY" ] ; then
+		#g.message -e "ERROR: the day option is not defined"
+		#g.message -i "Please set a specific distance from the shelters and restart the module"
+		g.message -e "ERRORE: il giorno in cui si e' visto per l'ultima volta il disperso non e' specificato"
+		g.message -i "Per cortesia specificalo e lancia nuovamente il comando"
+		exit 1
+	fi
+	if [ -z "$GIS_OPT_HH" ]
+		then
+		#g.message -e "Hour of last observation is not defined"
+		#g.message -i "Please set an hour (24 h mode)"
+		g.message -e "ERRORE: l'ora in cui si e' visto per l'ultima volta il disperso non e' specificata"
+		g.message -i "Per cortesia specificala e lancia nuovamente il comando"
+		exit 1
+	fi
+	if [ -z "$GIS_OPT_MM" ]
+		then
+		#g.message -e "Hour of last observation is not defined"
+		#g.message -i "Please set a minute (00-60)"
+		g.message -e "ERRORE: il minuto in cui si e' visto per l'ultima volta il disperso non e' specificat0"
+		g.message -i "Per cortesia specificalo (00-60) e lancia nuovamente il comando"
+		exit 1
+	fi
+	#echo "giorno="$giorno";export giorno">>$HOME/.bash_profile
+	#echo "ora="$ora";export ora">>$HOME/.bash_profile
+	#echo "minuti="$minuti";export minuti">>$HOME/.bash_profile
+	export giorno
+	export ora
+	export minuti
+	giorno="$GIS_OPT_DAY"
+	ora="$GIS_OPT_HH"
+	minuti="$GIS_OPT_MM"
+	export output
+	if [ -z "$GIS_OPT_OUT_STRAGFINDER" ]
+		then
+		#g.message -w "Output map is not defined, no output map is written"
+		g.message -w "Il nome della mappa di output non e' definito"
+		output="output_stragfinder"
+		g.message -w "La carta di output sara' chiamata $output e se esistente verra' sovrascritta di default"
+	else
+		output="$GIS_OPT_OUT_STRAGFINDER"
+	fi
+	stragfinder.sh 
+fi
+#********************************************************************************************************
+# Calcolo del percorso ottimale tra due punti
+
+if [ "$GIS_OPT_FUNCTION" = "4 - Calcolo del percorso ottimale tra due punti (POINT2POINT)" ] ; then 
+	FUNCTION=4
+	#echo "partenza="$partenza";export partenza" >> $HOME/.bash_profile
+	#echo "arrivo="$arrivo";export arrivo" >> $HOME/.bash_profile
+	export partenza
+	export arrivo
+	if [ "$GIS_FLAG_p" -eq 1 ] ; then
+		# Impostazione della risoluzione di calcolo
+		#g.region res=$RES_DTM
+
+		g.message -i "********************************************* "
+		g.message -i "Acquisizione interattiva del punto di partenza"		
+		#echo "input"$input";export input">>$HOME/.bash_profile 	
+		digit_input.sh
+		g.rename vect=digitato,partenza_digit --overwrite
+		partenza=partenza_digit
+		g.message -i "Punto di partenza acquisito "
+		g.message -i "_______________________________________________"
+		g.message -i "********************************************* "	
+		g.message -i "Acquisizione interattiva del punto di arrivo: "		
+		digit_input.sh
+		g.rename vect=digitato,arrivo_digit --overwrite
+		arrivo=arrivo_digit
+		g.message -i "Punto di arrivo acquisito "
+		g.message -i "_______________________________________________"
+	else
+		if [ ! -z "$GIS_OPT_START_POINT_KML" ] ; then
+			input_kml="$GIS_OPT_START_POINT_KML"
+			g.proj -w > current_loc.wtk
+			ogr2ogr -s_srs "EPSG:4326" -t_srs '"current_loc.wtk"' tmp_output.kml $input_kml
+			v.in.ogr -z -o -e dsn=tmp_output.kml output=partenza_kml --overwrite --quiet
+			partenza=partenza_kml
+			rm current_loc.wtk
+			rm -r tmp_output.kml
+		else
+			if [ -z "$GIS_OPT_START_POINT" ] ; then
+				#g.message -e "ERROR: the point of the last observation is not defined"
+				#g.message -i "Please set a vector map or create it interatvely using the specific flag (p)"
+				g.message -e "ERRORE: il punto di partenza non e' definito"
+				g.message -i "Per cortesia indica un input vettoriale, un file kml o specifica interattivamente i punti con il flag (p)"
+				exit 1
+			else
+				partenza="$GIS_OPT_START_POINT"
+			fi
+		fi
+		if [ ! -z "$GIS_OPT_END_POINT_KML" ] ; then
+			input2_kml="$GIS_OPT_END_POINT_KML"
+			g.proj -w > current_loc.wtk
+			ogr2ogr -s_srs "EPSG:4326" -t_srs '"current_loc.wtk"' tmp_output.kml $input2_kml
+			v.in.ogr -z -o -e dsn=tmp_output.kml output=arrivo_kml
+			arrivo=arrivo_kml
+			rm current_loc.wtk
+			rm -r tmp_output.kml
+		else 
+			if [ -z "$GIS_OPT_END_POINT" ] ; then
+				g.message -e "ERRORE: il punto d'arrivo non e' definito"
+				g.message -i "Per cortesia indica un input vettoriale, un file kml o specifica interattivamente i punti con il flag (p)"
+				exit 1
+			else
+				arrivo="$GIS_OPT_END_POINT"
+			fi	
+		fi
+	fi
+	if [ -z "$GIS_OPT_OUT_POINT2POINT" ]
+		then
+		#g.message -w "Output map is not defined, no output map is written"
+		g.message -w "Il nome della mappa di output non e' definito"
+		output="output_point2point"
+		g.message -w "La carta di output sara' chiamata $output e se esistente verra' sovrascritta di default"
+	else
+		output="$GIS_OPT_OUT_POINT2POINT"
+	fi
+	point2point.sh 
+fi
+
+#********************************************************************************************************
+# Calcolo del percorso ottimale tra un punto ed un sentiero
+
+if [ "$GIS_OPT_FUNCTION" = "5 - Calcolo del percorso ottimale tra un punto e un sentiero (POINT2PATH)" ] ; then 
+	FUNCTION=5
+	#echo "partenza="$partenza";export partenza" >> $HOME/.bash_profile
+	export partenza
+	if [ "$GIS_FLAG_z" -eq 1 ] ; then
+		# Impostazione della risoluzione di calcolo
+		#g.region res=$RES_DTM
+		g.message -i "********************************************* "
+		g.message -i "Acquisizione interattiva del punto di partenza"		
+		#echo "input"$input";export input">>$HOME/.bash_profile 	
+		digit_input.sh
+		g.rename vect=digitato,partenza_point2path_digit --overwrite
+		partenza=partenza_point2path_digit
+		g.message -i "Punto di partenza acquisito "
+		g.message -i "_______________________________________________"
+	else
+		if [ ! -z "$GIS_OPT_START_POINT2_KML" ] ; then
+			input_kml="$GIS_OPT_START_POINT2_KML"
+			g.proj -w > current_loc.wtk
+			ogr2ogr -s_srs "EPSG:4326" -t_srs "current_loc.wtk" tmp_output.kml $input_kml
+			v.in.ogr -z -o -e dsn=tmp_output.kml output=partenza_kml --overwrite --quiet
+			partenza=partenza_kml
+			rm current_loc.wtk
+			rm -r tmp_output.kml
+		else
+			if [ -z "$GIS_OPT_START_POINT2" ] ; then
+				#g.message -e "ERROR: the point of the last observation is not defined"
+				#g.message -i "Please set a vector map or create it interatvely using the specific flag (i)"
+				g.message -e "ERRORE: il punto di partenza non e' definito"
+				g.message -i "Per cortesia indica un input vettoriale, un file kml o specifica interattivamente i punti con il flag (z)"
+				exit 1
+			else
+				partenza="$GIS_OPT_START_POINT2"
+			fi
+		fi
+	fi
+	if [ -z "$GIS_OPT_OUT_POINT2PATH" ]
+		then
+		#g.message -w "Output map is not defined, no output map is written"
+		g.message -w "Il nome della mappa di output non e' definito"
+		output="output_point2path"
+		g.message -w "La carta di output sara' chiamata $output e se esistente verra' sovrascritta di default"
+	else
+		output="$GIS_OPT_OUT_POINT2PATH"
+	fi
+	point2path.sh 
+fi
+
+#done
+
+# reimposto la risoluzione della regione iniziale
+g.region region=tmp_curr_reg
+#rimuovo carta temporanea
+g.remove rast="temp_shade" --quiet
+g.remove vect="temp_regione" --quiet
+g.remove region=tmp_curr_reg --quiet
+g.message -i "Eventuali immagini o output testuali creati sono presenti nella cartella $act_dir/$folder"
+#rm $HOME/.bash_profile
+#d.mon stop=x3
+exit 0

Added: grass-addons/grass6/raster/r.pastro/readme.txt
===================================================================
--- grass-addons/grass6/raster/r.pastro/readme.txt	                        (rev 0)
+++ grass-addons/grass6/raster/r.pastro/readme.txt	2013-04-11 14:40:11 UTC (rev 55703)
@@ -0,0 +1,31 @@
+r.pastro is a command written by Gter srl (www.gter.it)
+
+This is a developement version of r.pastro command for GRASS 6.4.x (use of x monitors that is depracated in GRASS 7)
+
+It requires: 
+- gfortran-4.6
+- python (>=2.6)
+- python-pyshp
+- gnuplot
+
+
+To install it run the script install_r_pastro.sh as sudo user directly from GRASS and uninstall_r_pastro.sh to completely remove the script.
+
+E.g in a debian Linux version:
+sudo sh install_r_pastro.sh
+
+
+####################################################################################
+For any information about the command don't hesitate to contact the responsible of its developement within the Gter company. 
+Roberto Marzocchi
+R&D coordinator
+Gter srl Innovazione in Geomatica, Gnss e Gis
+University of Genova spin-off company
+Via Greto di Cornigliano 6r - 16152 Genova
+P.IVA/CF 01998770992
+ph: 010-8694830 Fax: 010-8694737 
+E-mail: roberto.marzocchi at gter.it
+www.gter.it
+www.twitter.com/Gteronline
+www.facebook.com/Gteronline
+

Added: grass-addons/grass6/raster/r.pastro/region_layout.sh
===================================================================
--- grass-addons/grass6/raster/r.pastro/region_layout.sh	                        (rev 0)
+++ grass-addons/grass6/raster/r.pastro/region_layout.sh	2013-04-11 14:40:11 UTC (rev 55703)
@@ -0,0 +1,118 @@
+#!/bin/bash
+
+# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
+# MODULE:  "REGION_LAYOUT SH" per GRASS 6.4 (GRASS Shell Script)				  #
+#											          #
+# AUTHOR:  Damiano Natali (damiano.natali at gmail.com)					          #
+#	   Roberto Marzocchi (roberto.marzocchi at gmail.com)			          	  #
+# PURPOSE: Script di servizio che gestisce il dialogo per la visualizzazione, l'interrogazione    #
+#	   ed il salvataggio delle mappe							  #
+#											  	  #
+# This program is free software under the GNU General Public License (>=v2). 		  	  #
+# Read the file COPYING that comes with GRASS for details.				  	  #
+# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
+
+# Visualizziamo su un monitor la mappa di sfondo comune a tutti i moduli, ovvero l'ortofoto
+d.mon stop=x3 --quiet
+d.mon start=x3
+d.erase
+############################################################################################
+# se non c'e' l'ortofoto si potrebbe mettere l'aspect sotto al dtm con una trasparenza
+############################################################################################
+if (check_image=1); then	
+	d.shadedmap reliefmap=temp_shade drapemap=$dtm
+else
+	d.rast map=$image			
+fi
+
+# Visualizziamo le altre mappe in base al modulo che si è lanciato
+if [ "$FUNCTION" = "1" ]||[ "$FUNCTION" = "2" ]
+   	then d.rast -o map=tmp_walkout_min
+   	d.vect map=$paths display=shape type=line layer=1 color=red fcolor=255:165:0 width=2 wscale=1 icon=basic/x size=5 llayer=1 lcolor=red    bgcolor=none bcolor=none lsize=8 xref=left yref=center render=c
+   	d.vect map=$shelters display=shape type=point layer=1 color=blue fcolor=255:255:0 rgb_column=GRASSRGB zcolor=terrain width=0 wscale=1 icon=basic/circle size=5 llayer=1 lcolor=red bgcolor=none bcolor=none lsize=8 xref=left yref=center render=c
+elif [ "$FUNCTION" = "3" ]
+   	then d.rast -o map=tmp_walkout
+   	d.vect map=$paths type=line color=255:165:0 width=1
+   	d.vect map=$shelters display=shape type=point layer=1 color=blue fcolor=0:255:0 rgb_column=GRASSRGB zcolor=terrain width=0 wscale=1 icon=basic/circle size=8 llayer=1 lcolor=red bgcolor=none bcolor=none lsize=8 xref=left yref=center render=c
+   	d.vect map=$last_obs type=point width=2 color=0:0:0 fcolor=255:255:0 icon=basic/circle size=8
+	rm $folder/immagini/immagine_stragfinder.png
+	d.out.file output=$folder/immagini/immagine_stragfinder format=png resolution=2 compression=9 quality=75 paper=a4 ps_level=2 --quiet
+elif [ "$FUNCTION" = "5" ]
+   	then d.vect map=$partenza display=shape type=point layer=1 color=blue fcolor=255:255:0 rgb_column=GRASSRGB zcolor=terrain width=0 wscale=1 icon=basic/circle size=8 llayer=1 lcolor=red bgcolor=none bcolor=none lsize=8 xref=left yref=center render=c
+  	d.vect map=$paths display=shape type=line layer=1 color=red fcolor=255:165:0 width=2 wscale=1 icon=basic/x size=5 llayer=1 lcolor=red bgcolor=none bcolor=none lsize=8 xref=left yref=center render=c
+   	d.vect map=tmp_sentiero_trovato display=shape type=line layer=1 color=green fcolor=255:255:0 width=2 wscale=1 icon=basic/x size=5 llayer=1 lcolor=red bgcolor=none bcolor=none lsize=8 xref=left yref=center render=c
+	rm $folder/immagini/immagine_point2path.png
+	d.out.file output=$folder/immagini/immagine_point2path format=png resolution=2 compression=9 quality=75 paper=a4 ps_level=2 --quiet
+### caso 4 
+else 
+	d.vect map=$partenza display=shape type=point layer=1 color=blue fcolor=255:255:0 rgb_column=GRASSRGB zcolor=terrain width=0 wscale=1 icon=basic/circle size=8 llayer=1 lcolor=red bgcolor=none bcolor=none lsize=8 xref=left yref=center render=c
+   	d.vect map=$arrivo display=shape type=point layer=1 color=blue fcolor=255:255:0 rgb_column=GRASSRGB zcolor=terrain width=0 wscale=1 icon=basic/circle size=8 llayer=1 lcolor=red bgcolor=none bcolor=none lsize=8 xref=left yref=center render=c
+   	d.vect map=tmp_sentiero_trovato display=shape type=line layer=1 color=black fcolor=255:255:0 width=2 wscale=1 icon=basic/x size=5 llayer=1 lcolor=red bgcolor=none bcolor=none lsize=8 xref=left yref=center render=c
+	# Esportiamo quanto visualizzato sul monitor come immagine, in modo che possa essere visualizzata ad esempio su un browser
+	rm $folder/immagini/immagine_point2point.png
+	d.out.file output=$folder/immagini/immagine_point2point format=png resolution=2 compression=9 quality=75 paper=a4 ps_level=2 --quiet
+fi
+
+# visualizziamo la barra di scala
+d.barscale bcolor=white tcolor=black at=0.2,90
+
+# interroghiamo la mappa (annesse le istruzioni per ogni caso---> da conrollare se van bene)
+#echo
+if [ "$FUNCTION" = "1" ]
+	then 
+	g.message -i "E' ora possibile interrogare la mappa sul display X3 e avere il valore in minuti di percorrenza dal piu' vicino riparo"
+	d.text -b text="sheltgar output" bgcolor=yellow
+elif [ "$FUNCTION" = "2" ]
+	then 
+	g.message -i "E' ora possibile interrogare la mappa sul display X3 e avere il valore in minuti di percorrenza dal sentiero piu' vicino"
+	d.text -b text="Pathgar output" bgcolor=yellow
+elif [ "$FUNCTION" = "3" ]
+	then  
+	g.message -i "Sono visibili sul diplay X3 le aree raggiungibili dal disperso di $giorno alle $ora:$minuti"
+	g.message -i "E' possibile interrogare la mappa sul display X3 e avere il valore in minuti percorribile" 
+	d.text -b text="Stragfinder output" bgcolor=yellow
+elif [ "$FUNCTION" = "4" ]
+	then 
+        g.message -i "E' visualizzato sulla mappa il percorso ottimale fra i 2 punti prescelti"
+	g.message -i "Interrrogando la mappa sul display X3 si puo' avere il valore in minuti di percorrenza dal punto di partenza" ## da verificare che sia questo 
+	d.text -b text="point2point output" bgcolor=yellow
+else 
+	g.message -i "E' visualizzato sulla mappa il percorso ottimale fra il punto di partenza scelto e la rete sentieristica"
+	g.message -i "Interrrogando la mappa sul display X3 si puo' avere il valore in minuti di percorrenza dal punto di partenza" ## da verificare che sia questo 
+	d.text -b text="point2path output" bgcolor=yellow
+fi
+d.what.rast map=tmp_walkout_min
+
+###################################################################################################################
+#####                 DISCUTERE SE SERVE E EVENTUALMENTE COME METTERLO 
+###################################################################################################################
+#while [ "$RISP" != "u" ]
+#   do echo
+#   echo -n 'Vuoi cambiare regione? ("s" per cambiare regione, "u" per uscire e salvare la mappa) '
+#   read RISP
+#   if [ "$RISP" == "s" ]
+#      then d.zoom -f
+#     d.what.rast map=walkout_min   
+#   fi
+#done
+
+# Esportiamo, nei casi in cui ciò serve, il sentiero trovato come file .gpx da caricare direttamente su un ricevitore
+if [ "$FUNCTION" = "4" ]||[ "$FUNCTION" = "5" ]; then	
+	rm $folder/TRACK.gpx
+   	v.out.gpsbabel -t input=tmp_sentiero_trovato type=line output=$folder/TRACK.gpx --quiet
+	# Esportiamo quanto visualizzato sul monitor come immagine, in modo che possa essere visualizzata ad esempio su un browser
+	###########################################################################################################################
+	### planimetria? non si capisce a cosa si riferisce (distinguere caso 3 da 4???)
+	###########################################################################################################################
+	rm $folder/immagini/planimetria_sentiero.png
+	g.region save=temp_calcoli --overwrite
+	g.region vect=tmp_sentiero_trovato save=tmp2_pastro res=$res_calcolo --overwrite
+	d.out.file output=$folder/immagini/planimetria_sentiero format=png resolution=2 compression=9 quality=75 paper=a4 ps_level=2 --quiet	
+	g.region region=temp_calcoli
+	g.remove region=tmp2_pastro --quiet
+	g.remove region=temp_calcoli --quiet
+fi
+
+# torniamo al menù principale
+# d.mon stop=x3
+#exit 0

Added: grass-addons/grass6/raster/r.pastro/region_layout2.sh
===================================================================
--- grass-addons/grass6/raster/r.pastro/region_layout2.sh	                        (rev 0)
+++ grass-addons/grass6/raster/r.pastro/region_layout2.sh	2013-04-11 14:40:11 UTC (rev 55703)
@@ -0,0 +1,38 @@
+#!/bin/bash
+
+# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
+# MODULE:  "REGION_LAYOUT SH" per GRASS 6.4 (GRASS Shell Script)				  #
+#											          #
+# AUTHOR:  Damiano Natali (damiano.natali at gmail.com)					          #
+#	   Roberto Marzocchi (roberto.marzocchi at gmail.com)			          	  #
+# PURPOSE: Script di servizio che gestisce il dialogo per la visualizzazione, l'interrogazione    #
+#	   ed il salvataggio delle mappe							  #
+#											  	  #
+# This program is free software under the GNU General Public License (>=v2). 		  	  #
+# Read the file COPYING that comes with GRASS for details.				  	  #
+# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
+
+
+
+# Esportiamo, nei casi in cui ciò serve, il sentiero trovato come file .gpx da caricare direttamente su un ricevitore
+if [ "$FUNCTION" = "4" ]||[ "$FUNCTION" = "5" ]; then	
+	rm $folder/TRACK.gml
+	rm $folder/TRACK.xsd
+   	#v.out.gpsbabel -t input=tmp_sentiero_trovato type=line output=$folder/TRACK.gpx --quiet
+	v.out.ogr format=GML type=line input=tmp_sentiero_trovato dsn=$folder/TRACK.gml --quiet
+	# Esportiamo quanto visualizzato sul monitor come immagine, in modo che possa essere visualizzata ad esempio su un browser
+	###########################################################################################################################
+	### planimetria? non si capisce a cosa si riferisce (distinguere caso 3 da 4???)
+	###########################################################################################################################
+	rm $folder/immagini/planimetria_sentiero.png
+	g.region save=temp_calcoli --overwrite
+	g.region vect=tmp_sentiero_trovato save=tmp2_pastro res=$res_calcolo --overwrite
+	d.out.file output=$folder/immagini/planimetria_sentiero format=png resolution=2 compression=9 quality=75 paper=a4 ps_level=2 --quiet	
+	g.region region=temp_calcoli
+	g.remove region=tmp2_pastro --quiet
+	g.remove region=temp_calcoli --quiet
+fi
+
+# torniamo al menù principale
+# d.mon stop=x3
+#exit 0

Added: grass-addons/grass6/raster/r.pastro/region_zoom.sh
===================================================================
--- grass-addons/grass6/raster/r.pastro/region_zoom.sh	                        (rev 0)
+++ grass-addons/grass6/raster/r.pastro/region_zoom.sh	2013-04-11 14:40:11 UTC (rev 55703)
@@ -0,0 +1,68 @@
+#!/bin/bash
+
+# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
+# MODULE:  "REGION_ZOOM SH" per GRASS 6.4 (GRASS Shell Script)				          #
+#											          #
+# AUTHOR:  Damiano Natali (damiano.natali at gmail.com)					          #
+#										          	  #
+# PURPOSE: Script di servizio che gestisce il dialogo per l'individuazione della regione attiva   #
+#											  	  #
+# This program is free software under the GNU General Public License (>=v2). 		  	  #
+# Read the file COPYING that comes with GRASS for details.				  	  #
+# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
+
+echo "Usa il mouse per selezionare l'area di interesse"
+echo
+
+d.zoom -f
+while [ "$RISP" != "s" ]
+   do echo
+   echo -n "La regione selezionata è quella desiderata? [s/n] "
+   if [ "$RISP" == "n" ]
+      then d.zoom -f
+   fi
+   read RISP
+done
+echo
+echo 'La regione attuale ha queste caratteristiche'
+echo
+g.region -p
+echo
+
+# Valutiamo i parametri della nuova regione
+# eval `g.region -g`
+# : ${n?} ${s?} ${w?} ${e?} ${nsres?}
+
+# echo -n 'Limite nord della nuova regione? '
+# read lim_n
+# if ! [ $lim_n ]
+#    then lim_n=$n
+# fi
+# echo -n 'Limite sud della nuova regione? '
+# read lim_s
+# if ! [ $lim_s ]
+#    then lim_s=$s
+# fi
+# echo -n 'Limite est della nuova regione? '
+# read lim_e
+# if ! [ $lim_e ]
+#    then lim_e=$e
+# fi
+# echo -n 'Limite ovest della nuova regione? '
+# read lim_w
+# if ! [ $lim_w ]
+#    then lim_w=$w
+# fi
+
+while ! [ $RISOL ]; do
+   echo -n 'Risoluzione della nuova regione? '
+   read RISOL
+done
+
+echo
+echo 'La regione di calcolo è'
+g.region -p res=$RISOL
+# g.region -p n=$lim_n s=$lim_s e=$lim_e w=$lim_w res=$risol
+echo
+
+exit 0

Added: grass-addons/grass6/raster/r.pastro/sheltgar.sh
===================================================================
--- grass-addons/grass6/raster/r.pastro/sheltgar.sh	                        (rev 0)
+++ grass-addons/grass6/raster/r.pastro/sheltgar.sh	2013-04-11 14:40:11 UTC (rev 55703)
@@ -0,0 +1,117 @@
+#!/bin/bash
+
+# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 
+# MODULE:  "SHELTGAR SH" per GRASS 6.4 (GRASS Shell Script)				#
+#											#
+# AUTHOR:  Andrea Cervetto (cervoz at hotmail.com)						#
+#	   Damiano Natali (damiano.natali at gmail.com)					#
+#	   Roberto Marzocchi (roberto.marzocchi at gmail.com)			        #
+# PURPOSE: Calcolo del presidio del territorio offerto dai rifugi presenti;		#
+#	   Il presente modulo viene solitamente lanciato dallo script pastro.sh.	#
+#											#
+# This program is free software under the GNU General Public License (>=v2). 		#
+# Read the file COPYING that comes with GRASS for details.				#
+# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
+
+#nome della cartella delle mappe
+#mappe='/home/damiano/spin-off/provincia_spezia/webgis/mappe'
+
+#nome della cartella temporanea
+#percorso='/home/damiano/spin-off/provincia_spezia/webgis/tmp'
+
+# creazione di un report relativo alla regione corrente
+#FILELOG='/home/damiano/spin-off/provincia_spezia/webgis/tmp/filelog/sheltgar.txt'
+#FILELOG="$folder/sheltgar.txt"
+
+g.message -i "La cartella $folder e' stata creata"
+# valutazione del percorso della location
+eval `g.gisenv`
+: ${GISDBASE?} ${LOCATION_NAME?} ${MAPSET?}
+LOCATION="$GISDBASE/$LOCATION_NAME/$MAPSET"
+
+# redirigere lo standard output dallo schermo al file di log
+exec 7>&1
+exec > "$folder/sheltgar.txt"
+#r.univar map=$output > "$folder/sheltgar.txt"
+r.univar map=$dtm > "$folder/sheltgar.txt"
+
+# redirigere lo standard output dal file di log allo schermo, chiudendo il file di log
+exec 1<&7 7<&-
+
+# redirigere lo standard input dalla tastiera al file di log
+exec 6<&0
+exec < "$folder/sheltgar.txt"
+read -n31
+read numero_celle_tot
+read ; read ; read ; read ; read -n3
+read numero_celle
+
+# redirigere lo standard input dal file di log alla tastiera, chiudendo il file di log, e calcolo della percentuale di area coperta
+exec 0<&6 6<&-
+area_coperta=$(echo "scale=2; ($numero_celle/$numero_celle_tot)*100.0" | bc)
+
+clear
+
+g.message -i "*******************************************************************"
+g.message -i "...........................SHELTGAR.SH............................."
+g.message -i "..Calcolo del presidio del territorio offerto dai rifugi presenti.."
+g.message -i "*******************************************************************"	
+
+
+
+# zoommiamo sull'area di interesse attraverso uno script apposito
+#region_zoom.sh
+
+# creazione della mappa delle friction
+v.to.rast input=$paths output="tmp_rast$paths" use=val type=line --overwrite --quiet
+r.slope.aspect elevation=$dtm slope=tmp_slope_percentuale aspect=tmp_aspect format=percent prec=float zfactor=1.0 min_slp_allowed=0.0 --overwrite --quiet
+
+
+# echo 'friction_pendenze=if(slope_percentuale<0.32,2,if(0.32<=slope_percentuale<=0.56,7.5,20))' | r.mapcalc
+#echo 'tmp_friction_offroad=if(!isnull(frane),2,if(!isnull(no_guado),5,if(slope_percentuale>0.77,5,1)))' | r.mapcalc
+#r.mapcalc 'tmp_friction_offroad=if(!isnull(frane),2,if(!isnull(no_guado),5,if(tmp_slope_percentuale>0.77,5,1)))'
+r.mapcalc 'tmp_friction_offroad=if(tmp_slope_percentuale>77,5,if(!isnull(tmp_no_guado),5,if(!isnull(tmp_frane),2,1)))'
+#r.mapcalc "tmp_friction_offroad=if(tmp_slope_percentuale>0.77,5,1)" # carta temporanea
+#echo 'tmp_friction=if(!isnull("tmp"$path"_rast"),0,tmp_friction_offroad)' | r.mapcalc
+r.mapcalc 'tmp_friction=if(!isnull(tmp_rast'$paths'),0,tmp_friction_offroad)'
+
+# calcolo delle aree raggiungibili a partire dai ripari esistenti in meno di tot minuti (parametroda inserire nella pastro_GUI -->sezione sheltgar
+#echo 
+#while ! [ $tmax ]
+#   do echo -n 'Digita la distanza massima in minuti a partire dai ripari esistenti che si desidera considerare: '
+#   read tmax
+#done
+
+
+#g.message -i "The distance from the shelters is$(($tmax*60))s"
+g.message -i "La distanza massima dai rifugi e' pari a $tmax minuti, ossia $(($tmax*60)) s"
+#echo 'premi un tasto'
+#read
+
+r.walk -k --overwrite elevation=$dtm friction=tmp_friction output=tmp_walkout start_points=$shelters max_cost=$(($tmax*60)) walk_coeff=$a,$b,$c,$d lambda=1.0 slope_factor=$s_f --overwrite --quiet
+
+#echo 'tmp_walkout=if(tmp_walkout>'$(($tmax*60))',null(),tmp_walkout)' | r.mapcalc
+#echo 'tmp_walkout_min=tmp_walkout/60.0' | r.mapcalc
+
+r.mapcalc 'tmp_walkout=if(tmp_walkout>'$(($tmax*60))',null(),tmp_walkout)'
+r.mapcalc 'tmp_walkout_min=tmp_walkout/60.0'
+
+#################################################################################################
+#### si potrebbe fare un contour per facilitare la visione? o anche no... 
+#################################################################################################
+
+# visualizziamo a monitor le mappe create, dando la possibilità di interrogarle, e le salviamo nella cartella 
+# /home/damiano/searching/gis&web/mobilita_ambito_montano/tmp
+#region_layout.sh
+
+
+g.rename rast=tmp_walkout_min,$output --quiet
+g.remove rast=tmp_walkout,tmp_friction,tmp_friction_offroad,"tmp_rast"$paths,tmp_slope_percentuale,tmp_aspect,tmp_frane,tmp_no_guado --quiet
+#g.message -i "SHELTGAR module correctly termined" 
+g.message -i "il modulo SHELTGAR e' concluso correttamente"
+g.message -i "____________________________________________"
+
+# torniamo al menù principale
+# pastro.sh
+
+exit 0

Added: grass-addons/grass6/raster/r.pastro/space2tab.py
===================================================================
--- grass-addons/grass6/raster/r.pastro/space2tab.py	                        (rev 0)
+++ grass-addons/grass6/raster/r.pastro/space2tab.py	2013-04-11 14:40:11 UTC (rev 55703)
@@ -0,0 +1,41 @@
+#!/usr/bin/env python
+#-*- coding:utf-8 -*-
+#
+############################################################################
+#
+# MODULE:       
+# AUTHOR(S):    Roberto Marzocchi (roberto.marzocchi at gmail.com)           
+# PURPOSE:	text file formatting
+# COPYLEFT:     
+# COMMENT:      ...a lot of comments to be easy-to-read for/by beginners
+#
+#############################################################################
+
+
+import os,sys,shutil,re,glob
+space = re.compile(r'\s+')
+multiSpace = re.compile(r"\s\s+") 
+
+nomefile1=".tmp_coord.txt"
+nomefile2="tmp_coord2.txt"
+
+# legge dal file coordinate 
+E=[]
+N=[]
+
+for riga in file(nomefile1): # modifica con nome generico 
+	#print riga
+	line = riga
+	a = space.split(line.strip())
+	# print a
+	E.append(float(a[0]))
+	N.append(float(a[1]))
+
+k=0
+miofile = open(nomefile2,'w')
+while k<len(E):
+	#scrivi = "%d %d %d" % E_point[k], % N_point[k], % res[k]
+	#print "%.2f %.2f %.2f\n" % (round(E_point[k],2),round(N_point[k],2),round(res[k],2))
+	miofile.write("%.2f|%.2f\n" % (round(E[k],2),round(N[k],2)))
+	k+=1
+miofile.close()

Added: grass-addons/grass6/raster/r.pastro/stragfinder.sh
===================================================================
--- grass-addons/grass6/raster/r.pastro/stragfinder.sh	                        (rev 0)
+++ grass-addons/grass6/raster/r.pastro/stragfinder.sh	2013-04-11 14:40:11 UTC (rev 55703)
@@ -0,0 +1,147 @@
+#!/bin/sh
+
+# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 
+# MODULE:  "STRAGFINDER SH" per GRASS 6.4 (GRASS Shell Script)				
+#											
+# AUTHOR:	Damiano Natali (damiano.natali at gmail.com)	
+#		Tiziano Cosso (tiziano.cosso at gter.it)				
+#											
+# PURPOSE: Calcolo dell'area raggiungibile in tot tempo da una persona a piedi.		
+#	   Il presente modulo viene solitamente lanciato dallo script pastro.sh.	
+#											
+# This program is free software under the GNU General Public License (>=v2). 		
+# Read the file COPYING that comes with GRASS for details.				
+# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
+
+
+#°°°°°°DA VERIFICARE SE SERVE E NEL CASO RENDERLI PERCORSI GENERICI°°°°°#
+#nome della cartella delle mappe
+#mappe='/home/damiano/spin-off/provincia_spezia/webgis/mappe'
+
+#nome della cartella temporanea
+#percorso='/home/damiano/spin-off/provincia_spezia/webgis/tmp'
+
+# creazione di un report relativo alla regione corrente
+#FILELOG='/home/damiano/spin-off/provincia_spezia/webgis/tmp/filelog/sheltgar.txt'
+FILELOG="$folder/sheltgar.txt"
+
+# valutazione del percorso della location
+eval `g.gisenv`
+: ${GISDBASE?} ${LOCATION_NAME?} ${MAPSET?}
+LOCATION="$GISDBASE/$LOCATION_NAME/$MAPSET"
+
+clear
+
+g.message -i "*******************************************************************"
+g.message -i "|                          STRAGFINDER.SH                         |"
+g.message -i "| 	         Utility per il ritrovamento di dispersi             |"
+g.message -i "*******************************************************************"	
+#testa inputs obbligatori
+
+
+
+
+
+#echo -n "Ora approssimativa dell'ultimo avvistamento? [ora.minuti] "
+#echo
+#°°°°°°°°°°°°°°°°°°PUNTO DI ULTIMO AVVISTAMENTO - TIZIANO°°°°°°°°°°°°°°°°°
+# secondo me non serve c'e gia' nella gUI
+#if [ -n "$GIS_OPT_IMAGE" ]
+#then
+#  image="$GIS_OPT_IMAGE"
+#else
+#  image="$GIS_OPT_DTM"
+#fi   
+
+
+
+
+#### verifica se serve (mi sembra un po inutile messo qua)
+#d.rast.leg map=$dtm
+# image solo se c'è 
+#d.rast map=$image 
+
+
+
+
+#read ora_minuti
+################################################################################################
+#### non so perche ma non funziona (risolto nella GUI se non ci piace vediamo di farlo funzionare)
+#ora=${ora_minuti:0:2}
+#minuti=${ora_minuti:3:2}
+################################################################################################
+
+# messo nella GUI
+#while [ "$giorno" != "oggi" ] && [ "$giorno" != "ieri" ] && [ "$giorno" != "altroieri" ]; do
+#   echo -n "di che giorno? [oggi/ieri/altroieri] "
+#   read giorno
+#done
+
+if [ "$giorno" = "oggi" ]
+   then stringa_old=$(date +%Y-%m-%d' '$ora:$minuti':00 UTC')
+elif [ "$giorno" = "ieri" ]
+   then stringa_old=$(date --date=yesterday +%Y-%m-%d' '$ora:$minuti':00 UTC')
+elif [ "$giorno" = "altroieri" ]
+   then stringa_old=$(date --date='today - 2 days' +%Y-%m-%d|echo' '$ora:$minuti':00 UTC')
+fi
+
+# echo $stringa_old
+# read
+#calcolo il tempo in secondi che intercorre fra l'ultimo avvistamento e l'ora attuale
+sec_old=$(date --date="$stringa_old" +%s)
+stringa_new=$(date +%Y-%m-%d' '%H:%M:%S' UTC')
+sec_new=$(date --date="$stringa_new" +%s)
+delta_t=$(($sec_new-$sec_old))
+
+g.message -i "L'ultimo avvistamento e' avvenuto $giorno alle $ora:$minuti , ossia $delta_t secondi fa"
+
+
+if [ "$delta_t" -lt 0 ] ; then
+	g.message -e "The last sighting  is after the actual date and time"
+	g.message -e "Please check the input date and time"
+	exit 1
+fi
+
+
+
+#°°°°°°°°GIA' MESSO NELLA GUI°°°°°°°°°
+# Impostazione della risoluzione di calcolo
+#echo -n "A quale risoluzione vuoi effettuare il calcolo? [m]"
+#echo
+#read res_calcolo
+#g.region res=$res_calcolo
+
+# creazione della mappa delle friction
+v.to.rast input=$paths output="tmp_rast"$paths use=val type=line --overwrite --quiet
+r.slope.aspect elevation=$dtm slope=tmp_slope_percentuale aspect=tmp_aspect format=percent prec=float zfactor=1.0 min_slp_allowed=0.0 --overwrite --quiet 
+
+
+
+#r.mapcalc 'tmp_friction_offroad=if(!isnull(frane),2,if(tmp_slope_percentuale>0.77,5,1))'
+r.mapcalc 'tmp_friction_offroad=if(tmp_slope_percentuale>77,5,if(!isnull(tmp_no_guado),5,if(!isnull(tmp_frane),2,1)))'
+#r.mapcalc "tmp_friction_offroad=if(tmp_slope_percentuale>0.77,5,1)" # carta temporanea
+r.mapcalc "tmp_friction=if(!isnull(tmp_rast$paths),0,tmp_friction_offroad)"
+#echo 'friction_offroad=if(!isnull(frane),2,if(slope_percentuale>0.77,5,1))' | r.mapcalc
+#echo 'friction=if(!isnull(tmp_rast"$paths"),0,friction_offroad)' | r.mapcalc
+
+
+# calcolo delle aree raggiungibili a partire dal punto selezionato fino a questo momento
+r.walk -k elevation=$dtm friction=tmp_friction output=tmp_walkout start_points=$last_obs max_cost=$delta_t walk_coeff=$a,$b,$c,$d lambda=1.0 slope_factor=$s_f --overwrite --quiet
+
+r.mapcalc 'tmp_walkout_min=tmp_walkout/60.0'
+
+###########################################################################################################################
+# questa volta non lo faccio in minuti ma solo in secondi...e' corretto o e' una dimenticanza
+###########################################################################################################################
+
+# visualizziamo a monitor le mappe create, dando la possibilità di interrogarle, e le salviamo nella cartella 
+# /home/damiano/searching/gis&web/mobilita_ambito_montano/tmp
+region_layout.sh
+g.rename rast=tmp_walkout_min,$output --quiet
+g.remove rast=tmp_friction,tmp_friction_offroad,tmp_rast$paths,tmp_slope_percentuale,tmp_aspect,tmp_frane,tmp_no_guado,tmp_walkout --quiet
+g.message -i "Il modulo STRAGFINDER e' terminato correttamente"
+g.message -i "________________________________________________"
+# torniamo al menù principale
+#pastro.sh
+
+exit 0

Added: grass-addons/grass6/raster/r.pastro/uninstall_r_pastro.sh
===================================================================
--- grass-addons/grass6/raster/r.pastro/uninstall_r_pastro.sh	                        (rev 0)
+++ grass-addons/grass6/raster/r.pastro/uninstall_r_pastro.sh	2013-04-11 14:40:11 UTC (rev 55703)
@@ -0,0 +1,45 @@
+#!/bin/bash
+
+#!/bin/bash
+
+############################################################################
+#
+# MODULE:  	script to uninstall "P.A.S.T.R.O." on GRASS 6.4 (GRASS Shell Script)											
+# AUTHOR:  	Tiziano Cosso (tiziano.cosso at gter.it)
+#		Roberto Marzocchi (roberto.marzocchi at gmail.com)										
+# PURPOSE: 	Utility di calcolo dell'accessibilità in ambito montano	 		
+# COPYRIGHT:	This program is free software under the 
+#		GNU General Public License (>=v2). 		
+# 		Read the file COPYING that comes with GRASS for details.			
+#
+############################################################################
+
+
+if  [ -z "$GISBASE" ]
+then
+	echo ""
+	echo "You must be in GRASS GIS to run this program"
+	echo ""
+	exit 1
+fi
+
+
+#rm the fortran codes
+rm "$GISBASE/etc/fortran_code"/profilo_pastro  
+rm "$GISBASE/etc/fortran_code"/distanze_pastro 
+#rm profilo_pastro
+#rm distanze_pastro 
+
+rm "$GISBASE/scripts"/r.pastro
+rm "$GISBASE/scripts"/sheltgar.sh 
+rm "$GISBASE/scripts"/pathgar.sh 
+rm "$GISBASE/scripts"/stragfinder.sh 
+rm "$GISBASE/scripts"/point2point.sh 
+rm "$GISBASE/scripts"/point2path.sh
+rm "$GISBASE/scripts"/path_profile.sh 
+rm "$GISBASE/scripts"/region_layout.sh  
+rm "$GISBASE/scripts"/region_zoom.sh 
+rm "$GISBASE/scripts"/digit_input.sh
+rm "$GISBASE/scripts"/grafico.p
+rm "$GISBASE/scripts"/space2tab.py
+rm "$GISBASE/scripts"/velocity.py

Added: grass-addons/grass6/raster/r.pastro/velocity.py
===================================================================
--- grass-addons/grass6/raster/r.pastro/velocity.py	                        (rev 0)
+++ grass-addons/grass6/raster/r.pastro/velocity.py	2013-04-11 14:40:11 UTC (rev 55703)
@@ -0,0 +1,91 @@
+#!/usr/bin/env python
+#-*- coding:utf-8 -*-
+#
+############################################################################
+#
+# MODULE:       
+# AUTHOR(S):    Roberto Marzocchi (roberto.marzocchi at gter.it)           
+# PURPOSE:	create a shapefile with a polyline with velocity evaluated with the r.walk grass command 
+# COPYLEFT:     
+# COMMENT:      ...a lot of comments to be easy-to-read for/by beginners
+#
+#############################################################################
+
+
+import os,sys,shutil,re,glob
+import math
+space = re.compile(r'\s+')
+multiSpace = re.compile(r"\s\s+") 
+
+# come dipendenze scarica e installa (sudo python setup.py install) la libreria pyshp
+# Pure Python read/write support for ESRI Shapefile format
+# http://pypi.python.org/pypi/pyshp
+import shapefile
+
+
+nomefile1="per_plot2"
+nomefile2="sentiero"
+
+# legge dal file coordinate 
+E=[]
+N=[]
+z=[]
+costo=[]
+
+for riga in file(nomefile1): # modifica con nome generico 
+	#print riga
+	line = riga
+	a = space.split(line.strip())
+	# print a
+	E.append(float(a[0]))
+	N.append(float(a[1]))
+	z.append(float(a[2]))
+	costo.append(float(a[3]))
+
+dist=[]
+vel=[]
+dif_costo=[]
+i=0
+while i<len(E):
+		if i==0:
+			dist.append(0.0)
+			vel.append(0.0)
+			dif_costo.append(0.0)
+			i+=1
+			# print dist_progr
+		else: 
+			dist.append( math.sqrt( (E[i]-E[i-1])**2+ (N[i]-N[i-1])**2 + (z[i]-z[i-1])**2 ) )
+			dif_costo.append(costo[i]-costo[i-1])
+			vel.append(min(9.99,3.6*dist[i]/dif_costo[i]))
+			i+=1
+			
+			
+			
+
+w = shapefile.Writer(shapefile.POLYLINE)
+w.field("ID","N",8,0)
+w.field("V_km_h","N",8,2)
+# Create new shapefile
+# Add points to line
+#lon_idx, lat_idx = header['Longitude'], header['Latitude']
+k=1
+while k<len(E)-1:
+	#scrivi = "%d %d %d" % E_point[k], % N_point[k], % res[k]
+	#print "%.2f %.2f %.2f\n" % (round(E_point[k],2),round(N_point[k],2),round(res[k],2))
+	E1=E[k-1]
+	N1=N[k-1]
+	E2=E[k]
+	N2=N[k]
+	w.line(parts=[[[E1,N1],[E2,N2]]])
+	vv=round(vel[k],2)
+	w.record(ID=k,V_km_h=vv)
+	k+=1
+	#print k,E2,vv
+
+#print "ok"
+
+w.save(nomefile2)	
+	
+
+
+



More information about the grass-commit mailing list