[GRASS-SVN] r43493 - grass/branches/releasebranch_6_4/scripts/d.rast.leg

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Sep 18 10:33:40 EDT 2010


Author: neteler
Date: 2010-09-18 14:33:40 +0000 (Sat, 18 Sep 2010)
New Revision: 43493

Modified:
   grass/branches/releasebranch_6_4/scripts/d.rast.leg/d.rast.leg
Log:
backported legend positioning improvements

Modified: grass/branches/releasebranch_6_4/scripts/d.rast.leg/d.rast.leg
===================================================================
--- grass/branches/releasebranch_6_4/scripts/d.rast.leg/d.rast.leg	2010-09-18 12:41:57 UTC (rev 43492)
+++ grass/branches/releasebranch_6_4/scripts/d.rast.leg/d.rast.leg	2010-09-18 14:33:40 UTC (rev 43493)
@@ -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
@@ -77,21 +77,23 @@
 #% key: position
 #% type: double
 #% description: Position of vertical map-legend separator (in percent)
-#% answer: 65
+#% answer: 80
 #% required : no
 #%end
 
 if test "$GISBASE" = ""; then
- echo "You must be in GRASS GIS to run this program." >&2
- exit 1
+    echo "You must be in GRASS GIS to run this program." >&2
+    exit 1
 fi
 
 if [ "$1" != "@ARGS_PARSED@" ] ; then
-  exec g.parser "$0" "$@"
+    exec g.parser "$0" "$@"
 fi
 
 if [ $GIS_FLAG_N -eq 1 ] ; then
   OMIT="-n"
+else
+  OMIT=""
 fi
 
 if [ $GIS_FLAG_F -eq 1 ] ; then
@@ -111,18 +113,23 @@
    exit 1
 fi
 filemapset="${mapset}"
+# would it be better to search for cats/ file ??
 eval `g.gisenv`
 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
@@ -133,32 +140,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
 
@@ -169,33 +178,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