瀏覽代碼

Added rast parameter for static legends

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@33529 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Neteler 16 年之前
父節點
當前提交
63ca11fbe3
共有 2 個文件被更改,包括 48 次插入11 次删除
  1. 43 11
      scripts/d.rast.leg/d.rast.leg
  2. 5 0
      scripts/d.rast.leg/d.rast.leg.html

+ 43 - 11
scripts/d.rast.leg/d.rast.leg

@@ -51,7 +51,7 @@
 #% key: map
 #% type: string
 #% gisprompt: old,cell,raster
-#% description: raster input map
+#% description: Name of raster map
 #% required : yes
 #%end
 #%option
@@ -60,6 +60,13 @@
 #% description: Number of lines to appear in the legend
 #% required : no
 #%end
+#%option
+#% key: rast
+#% type: string
+#% gisprompt: old,cell,raster
+#% description: Name of raster map to generate legend from
+#% required : no
+#%end
 
 if test "$GISBASE" = ""; then
  echo "You must be in GRASS GIS to run this program." >&2
@@ -87,6 +94,15 @@ fi
 filemapset="${mapset}"
 HISTFILEDIR=$GISDBASE/$LOCATION_NAME/$filemapset/cell_misc/
 
+# 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
+fi
+
 # save defined font setting
 FONTCMD=`d.frame -l | grep d.font | sed 's+"++1'| sed 's+"++1'`
 d.frame -e
@@ -110,11 +126,19 @@ then
 
        #draw legend
     	d.frame -s at=0,90,65,100 frame=right
-        if test -f $HISTFILEDIR/$GIS_OPT_MAP/histogram ; then
-    	     d.legend $FLIP -n map=$GIS_OPT_MAP
-        else
-             d.legend $FLIP $OMIT map=$GIS_OPT_MAP
-        fi
+	if [ -z $GIS_OPT_RAST ] ; then
+		if test -f $HISTFILEDIR/$GIS_OPT_MAP/histogram ; then
+	  	     d.legend $FLIP -n map=$GIS_OPT_MAP
+        	else
+	             d.legend $FLIP $OMIT map=$GIS_OPT_MAP
+        	fi
+	else
+		if test -f $HISTFILEDIR/$GIS_OPT_RAST/histogram ; then
+		     d.legend $FLIP -n map=$GIS_OPT_RAST
+		else
+		     d.legend $FLIP $OMIT map=$GIS_OPT_RAST
+		fi
+	fi
 
        #draw map
 	d.frame -s at=0,100,0,65 frame=left
@@ -133,11 +157,19 @@ else
 
        #draw legend
     	d.frame -s at=0,90,65,100 frame=right
-        if test -f $HISTFILEDIR/$GIS_OPT_MAP/histogram ; then
-             d.legend $FLIP -n map=$GIS_OPT_MAP lines=$GIS_OPT_NUM_OF_LINES
-        else
-             d.legend $FLIP $OMIT map=$GIS_OPT_MAP
-        fi
+	if [ -z $GIS_OPT_RAST ] ; then
+		if test -f $HISTFILEDIR/$GIS_OPT_MAP/histogram ; then
+	             d.legend $FLIP -n map=$GIS_OPT_MAP lines=$GIS_OPT_NUM_OF_LINES
+        	else
+	             d.legend $FLIP $OMIT map=$GIS_OPT_MAP
+        	fi
+	else
+		if test -f $HISTFILEDIR/$GIS_OPT_RAST/histogram ; then
+		     d.legend $FLIP -n map=$GIS_OPT_RAST lines=$GIS_OPT_NUM_OF_LINES
+		else
+		     d.legend $FLIP $OMIT map=$GIS_OPT_RAST
+		fi
+	fi
 
        #draw map
 	d.frame -s at=0,100,0,65 frame=left

+ 5 - 0
scripts/d.rast.leg/d.rast.leg.html

@@ -18,6 +18,11 @@ rest being truncated.
 <P>
 The user may adjust the <B>num_of_lines</B> parameter or
 the size of graphics window to get an appropriate result.
+
+<P>
+The user may specify a second raster map with the <b>rast</b> parameter from
+which the legend is generated. This is useful to visualize (time) series of
+raster maps with a common static legend instead of the default dynamic legend.
 <P>
 To remove all frames when clearing the display, use
 "<em><tt>d.erase -f</tt></em>".