[GRASS-SVN] r37458 - grass/branches/develbranch_6/scripts/d.rast.leg

svn_grass at osgeo.org svn_grass at osgeo.org
Mon May 25 04:33:43 EDT 2009


Author: hamish
Date: 2009-05-25 04:33:43 -0400 (Mon, 25 May 2009)
New Revision: 37458

Modified:
   grass/branches/develbranch_6/scripts/d.rast.leg/d.rast.leg
Log:
FP legends not so thin, quote variables, minor cleanup

Modified: grass/branches/develbranch_6/scripts/d.rast.leg/d.rast.leg
===================================================================
--- grass/branches/develbranch_6/scripts/d.rast.leg/d.rast.leg	2009-05-25 07:18:02 UTC (rev 37457)
+++ grass/branches/develbranch_6/scripts/d.rast.leg/d.rast.leg	2009-05-25 08:33:43 UTC (rev 37458)
@@ -51,7 +51,7 @@
 #% key: map
 #% type: string
 #% gisprompt: old,cell,raster
-#% description: Name of raster map
+#% description: Name of raster map to display
 #% required : yes
 #%end
 #%option
@@ -92,6 +92,8 @@
 
 if [ $GIS_FLAG_N -eq 1 ] ; then
   OMIT="-n"
+else
+  OMIT=""
 fi
 
 if [ $GIS_FLAG_F -eq 1 ] ; then
@@ -111,17 +113,22 @@
    exit 1
 fi
 filemapset="${mapset}"
+# would it be better to search for cats/ file ??
 HISTFILEDIR=$GISDBASE/$LOCATION_NAME/$filemapset/cell_misc/
+eval `r.info -t "$GIS_OPT_MAP"`
 
 # for rast=
-if [ ! -z $GIS_OPT_RAST ] ; then 
-	eval `g.findfile el=cell file=$GIS_OPT_RAST`
-	if [ ! "$file" ] ; then
-	   g.message -e "Raster map '$GIS_OPT_RAST' not found in mapset search path"
-	   exit 1
-	fi
+if [ -n "$GIS_OPT_RAST" ] ; then
+    eval `g.findfile el=cell file="$GIS_OPT_RAST"`
+    if [ ! "$file" ] ; then
+	g.message -e "Raster map '$GIS_OPT_RAST' not found in mapset search path"
+	exit 1
+    else
+	eval `r.info -t "$GIS_OPT_RAST"`
+    fi
 fi
 
+
 # save defined font setting
 FONTCMD=`d.frame -l | grep d.font | sed 's+"++1'| sed 's+"++1'`
 d.frame -e
@@ -132,32 +139,34 @@
 XPOS=$GIS_OPT_POSITION
 
 #at=bottom,top,left,right
+if [ "$datatype" = "CELL" ] ; then
+    # using at= turns off automatic font resize to fit in frame
+    LEG_AT=""
+else
+    LEG_AT="at=7,93,3,18"
+fi
 
-if [ -z "$GIS_OPT_NUM_OF_LINES" ]
-then
 
+if [ -z "$GIS_OPT_NUM_OF_LINES" ] ; then
        #draw title
-        d.frame -s at=90,100,$XPOS,100  frame=title
-#	if test -f $GISBASE/bin/d.text.freetype ; then
-#          d.text.freetype -sp text=$GIS_OPT_MAP col=black size=18 \
-#	         east_north=20,20 path=/usr/X11R6/lib/X11/fonts/TTF/luximb.ttf
-#	else
-          echo "$MAPNAME" | d.text col=black size=30
-#	fi
+	d.frame -s at=90,100,$XPOS,100  frame=title
+	echo "$MAPNAME" | d.text col=black size=30
 
        #draw legend
     	d.frame -s at=0,90,$XPOS,100 frame=right
-	if [ -z $GIS_OPT_RAST ] ; then
+	if [ -z "$GIS_OPT_RAST" ] ; then
+		g.message -d "No lines; own legend"
 		if test -f $HISTFILEDIR/$GIS_OPT_MAP/histogram ; then
-	  	     d.legend $FLIP -n map=$GIS_OPT_MAP
+	  	     d.legend $FLIP -n map="$GIS_OPT_MAP" $LEG_AT
         	else
-	             d.legend $FLIP $OMIT map=$GIS_OPT_MAP
+	             d.legend $FLIP $OMIT map="$GIS_OPT_MAP" $LEG_AT
         	fi
 	else
+		g.message -d "No lines; external legend"
 		if test -f $HISTFILEDIR/$GIS_OPT_RAST/histogram ; then
-		     d.legend $FLIP -n map=$GIS_OPT_RAST
+		     d.legend $FLIP -n map="$GIS_OPT_RAST" $LEG_AT
 		else
-		     d.legend $FLIP $OMIT map=$GIS_OPT_RAST
+		     d.legend $FLIP $OMIT map="$GIS_OPT_RAST" $LEG_AT
 		fi
 	fi
 
@@ -168,33 +177,32 @@
 else
 
        #draw title
-        d.frame -s at=90,100,$XPOS,100 frame=title
-#	if test -f $GISBASE/bin/d.text.freetype ; then
-#          d.text.freetype -sp text=$GIS_OPT_MAP col=black size=18 \
-#	         east_north=20,20 path=/usr/X11R6/lib/X11/fonts/TTF/luximb.ttf
-#	else
-          echo "$MAPNAME" | d.text col=black size=30
-#	fi
+	d.frame -s at=90,100,$XPOS,100 frame=title
+	echo "$MAPNAME" | d.text col=black size=30
 
        #draw legend
     	d.frame -s at=0,90,$XPOS,100 frame=right
-	if [ -z $GIS_OPT_RAST ] ; then
+	if [ -z "$GIS_OPT_RAST" ] ; then
+		g.message -d message="Lines=$GIS_OPT_NUM_OF_LINES; own legend"
 		if test -f $HISTFILEDIR/$GIS_OPT_MAP/histogram ; then
-	             d.legend $FLIP -n map=$GIS_OPT_MAP lines=$GIS_OPT_NUM_OF_LINES
+	             d.legend $FLIP -n map="$GIS_OPT_MAP" \
+			lines="$GIS_OPT_NUM_OF_LINES" $LEG_AT
         	else
-	             d.legend $FLIP $OMIT map=$GIS_OPT_MAP
+	             d.legend $FLIP $OMIT map="$GIS_OPT_MAP" $LEG_AT
         	fi
 	else
+		g.message -d message="Lines=$GIS_OPT_NUM_OF_LINES; external legend"
 		if test -f $HISTFILEDIR/$GIS_OPT_RAST/histogram ; then
-		     d.legend $FLIP -n map=$GIS_OPT_RAST lines=$GIS_OPT_NUM_OF_LINES
+		     d.legend $FLIP -n map="$GIS_OPT_RAST" \
+			lines="$GIS_OPT_NUM_OF_LINES" $LEG_AT
 		else
-		     d.legend $FLIP $OMIT map=$GIS_OPT_RAST
+		     d.legend $FLIP $OMIT map="$GIS_OPT_RAST" $LEG_AT
 		fi
 	fi
 
        #draw map
 	d.frame -s at=0,100,0,$XPOS frame=left
-    	d.rast map=$GIS_OPT_MAP
+    	d.rast map="$GIS_OPT_MAP"
 fi
 
 



More information about the grass-commit mailing list