[GRASS5] d.legend with vector file support
Jachym Cepicky
jachym.cepicky at centrum.cz
Wed May 18 09:17:19 EDT 2005
New patches for d.legend. Thanks Martin, some functions have been improved.
I added the flag -t (for vector), you never know, if there are not
---^--
two maps (raster and vector) with the same nema in GRASSDBASE.
It would be good to solve points somehow. Maybe there should be other
column in dbfile for vector points: except GRASSRGB for color GRASSPOINT
for point type... and in the future GRASSLINE, GRASSAREA ...
Anyway, I did not understand, how to draw point symbols to GRASS-monitor,
if someone could give me some hint.
To the problem with R_RGB_color(), Glynn showed me, that it shoudl get unsigned
chars. I tryed to change it, but it did not help :-( I must be blind...
I'm sending new patches, which should be applied at fresh CVS version of
d.legend, so *not* over the patches, I sended last time.. sorry, If I'm doing
something wrong, this seems to me as the best way...
I'm sending new improved d.vect.leg2 too. It uses new d.legend funcionality.
Looking forward to your comments
Jachym
--
Jachym Cepicky
e-mail: jachym.cepicky at centrum.cz
URL: http://les-ejk.cz
GPG: http://www.fle.czu.cz/~jachym/gnupg_public_key/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: d.legend.patches.tar
Type: application/x-tar
Size: 30720 bytes
Desc: not available
Url : http://lists.osgeo.org/pipermail/grass-dev/attachments/20050518/33671c62/d.legend.patches.tar
-------------- next part --------------
#!/bin/sh
#
############################################################################
#
# MODULE: d.vect.leg
# AUTHOR(S): Jachym Cepicky, Ustav geoinformacnich technologii, MZLU v
# Brne, Czech Rep.
# PURPOSE: Displays legend from database table
# COPYRIGHT: (C) 2005 by the GRASS Development Team
#
# This program is free software under the GNU General Public
# License (>=v2). Read the file COPYING that comes with GRASS
# for details.
#
#############################################################################
#%Module
#% description: Displays a legend for a vector map layer in the active frame on the graphics monitor.
#%End
#%option
#% key: map
#% type: string
#% gisprompt: old,vector,vector
#% description: Vector map to display legend
#% required : yes
#%end
#%option
#% key: column
#% type: string
#% description: Column to use for thematic display (must be numeric)
#% required : yes
#%end
#%option
#% key: layer
#% type: integer
#% description: Layer to use for thematic display
#% answer: 1
#% required : no
#%end
#%option
#% key: type
#% type: string
#% description: Vector map type
#% options: area,point,centroid,line,boundary
#% answer: area
#% required : yes
#%end
if [ -z $GISBASE ] ; then
echo "You must be in GRASS GIS to run this program."
exit 1
fi
if [ "$1" != "@ARGS_PARSED@" ] ; then
exec g.parser "$0" "$@"
fi
# setting environment, so that awk works properly in all languages
export LC_NUMERIC=C
mon=`d.mon -L | grep selected | awk '{print $1}'`
if [ "$mon" == "" ]; then
echo -e "ERROR: No monitor selected"
echo -e "ERROR: Select your monitor with 'd.mon'"
exit 1;
fi
# what to do in case of user break:
exitprocedure()
{
echo "User break!"
exit 1
}
# shell check for user break (signal list: trap -l)
trap "exitprocedure" 2 3 15
map_type=$GIS_OPT_type
table=`v.db.connect $GIS_OPT_map -g | grep -w $GIS_OPT_layer | awk '{print $2}'`
if [ -z "$table" ]
then
echo "No table connected or layer <$GIS_OPT_layer> doesn't exist!"
exit 1
fi
d.frame -e
d.frame -s at=0,100,0,65 frame=left
d.vect -a map=$GIS_OPT_map type=$GIS_OPT_type layer=$GIS_OPT_layer
d.frame -s at=0,100,65,100 frame=right
heading="$GIS_OPT_map: $GIS_OPT_column"
head_length=`echo $heading | wc -m`;
underline=""
# print underline
for ((i=1; "$i" < "$head_length"; i++)); do
underline="-$underline"
done
# print heading
echo -e "$heading\n$underline"|d.text color=black size=3;
d.legend -t map=$GIS_OPT_map layer=$GIS_OPT_layer type=$map_type column=$GIS_OPT_column at=94,00,100,5
d.frame -s frame=left
More information about the grass-dev
mailing list