~ubuntu-branches/ubuntu/vivid/grass/vivid-proposed

« back to all changes in this revision

Viewing changes to scripts/d.vect.thematic/d.vect.thematic

  • Committer: Package Import Robot
  • Author(s): Bas Couwenberg
  • Date: 2015-02-20 23:12:08 UTC
  • mfrom: (8.2.6 experimental)
  • Revision ID: package-import@ubuntu.com-20150220231208-1u6qvqm84v430b10
Tags: 7.0.0-1~exp1
* New upstream release.
* Update python-ctypes-ternary.patch to use if/else instead of and/or.
* Drop check4dev patch, rely on upstream check.
* Add build dependency on libpq-dev to grass-dev for libpq-fe.h.
* Drop patches applied upstream, refresh remaining patches.
* Update symlinks for images switched from jpg to png.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/sh
2
 
#
3
 
############################################################################
4
 
#
5
 
# MODULE:       d.vect.thematic
6
 
# AUTHOR(S):    Michael Barton, Arizona State University with contributions
7
 
#               by Martin Landa, Jachym Cepicky, Daniel Calvelo Aros and Moritz Lennert
8
 
# PURPOSE:          Displays thematic vector map with graduated colors
9
 
#               or graduated points and line thickneses
10
 
# COPYRIGHT:    (C) 2006 by the GRASS Development Team
11
 
#
12
 
#               This program is free software under the GNU General Public
13
 
#               License (>=v2). Read the file COPYING that comes with GRASS
14
 
#               for details.
15
 
#
16
 
#############################################################################
17
 
 
18
 
 
19
 
#%Module
20
 
#%  description: Displays thematic vector map
21
 
#%  keywords: display, vector, thematic, legend
22
 
#%End
23
 
#%option
24
 
#% guisection: Files
25
 
#% key: map
26
 
#% type: string
27
 
#% gisprompt: old,vector,vector
28
 
#% description: Name of vector map
29
 
#% required : yes
30
 
#%end
31
 
#%option
32
 
#% guisection: Theme
33
 
#% key: type
34
 
#% type: string
35
 
#% description: Feature type
36
 
#% options: area,point,centroid,line,boundary
37
 
#% answer: area
38
 
#% required : yes
39
 
#%end
40
 
#%option
41
 
#% guisection: Theme
42
 
#% key: column
43
 
#% gisprompt: old_dbcolumn,dbcolumn,dbcolumn
44
 
#% type: string
45
 
#% description: Name of attribute column to use for thematic display (must be numeric)
46
 
#% required : yes
47
 
#%end
48
 
#%option
49
 
#% guisection: Theme
50
 
#% key: themetype
51
 
#% type: string
52
 
#% options: graduated_colors,graduated_points,graduated_lines
53
 
#% answer: graduated_colors
54
 
#% description: Type of thematic display
55
 
#% required : yes
56
 
#%end
57
 
#%option
58
 
#% guisection: Theme
59
 
#% key: themecalc
60
 
#% type: string
61
 
#% options: interval,std_deviation,quartiles,custom_breaks
62
 
#% answer: interval
63
 
#% description: Thematic divisions of data for display
64
 
#% required : yes
65
 
#%end
66
 
#%option
67
 
#% guisection: Theme
68
 
#% key: breakpoints
69
 
#% type: string
70
 
#% label: Break points for custom breaks option
71
 
#% description: Separate values by spaces (0 10 20 30 ...)
72
 
#% required : no
73
 
#%end
74
 
#%option
75
 
#% guisection: Theme
76
 
#% key: layer
77
 
#% type: integer
78
 
#% gisprompt: old_layer,layer,layer
79
 
#% description: Layer number
80
 
#% answer: 1
81
 
#% required : no
82
 
#%end
83
 
#%option
84
 
#% guisection: Points
85
 
#% key: icon
86
 
#% type: string
87
 
#% description: Vector point icon for point data
88
 
#% options: basic/box,basic/circle,basic/cross2,basic/diamond,basic/star,basic/cross1,basic/x
89
 
#% answer: basic/circle
90
 
#% required : no
91
 
#%end
92
 
#%option
93
 
#% guisection: Points
94
 
#% key: size
95
 
#% type: double
96
 
#% label: Icon size for point data
97
 
#% description: Minimum icon size/line width for graduated points/lines)
98
 
#% answer: 5
99
 
#% required : no
100
 
#%end
101
 
#%option
102
 
#% guisection: Points
103
 
#% key: maxsize
104
 
#% type: double
105
 
#% description: Maximum icon size/line width for graduated points and lines
106
 
#% answer: 20
107
 
#% required : no
108
 
#%end
109
 
#%option
110
 
#% guisection: Theme
111
 
#% key: nint
112
 
#% type: integer
113
 
#% description: Number of classes for interval theme (integer)
114
 
#% answer: 4
115
 
#% required : no
116
 
#%end
117
 
#%option
118
 
#% guisection: Color
119
 
#% key: colorscheme
120
 
#% type: string
121
 
#% label: Color scheme for graduated color mapping
122
 
#% description: Select 'single_color' for graduated point/line display
123
 
#% options: blue-red,red-blue,green-red,red-green,blue-green,green-blue,cyan-yellow,yellow-cyan,custom_gradient,single_color
124
 
#% answer: blue-red
125
 
#% required : yes
126
 
#%end
127
 
#% option
128
 
#% guisection: Color
129
 
#% key: pointcolor
130
 
#% type: string
131
 
#% label: Color for graduated points map
132
 
#% description: GRASS named color or R:G:B triplet. Set color scheme to single color
133
 
#% answer: 255:0:0
134
 
#% required : no
135
 
#%end
136
 
#% option
137
 
#% guisection: Color
138
 
#% key: linecolor
139
 
#% type: string
140
 
#% label: Color for graduated lines or point/area outlines
141
 
#% description: GRASS named color or R:G:B triplet. Set color scheme to single color.
142
 
#% answer: 0:0:0
143
 
#% required : no
144
 
#%end
145
 
#% option
146
 
#% guisection: Color
147
 
#% key: startcolor
148
 
#% type: string
149
 
#% label: Beginning color for custom color gradient
150
 
#% description: Must be expressed as R:G:B triplet
151
 
#% answer: 255:0:0
152
 
#% required : no
153
 
#%end
154
 
#% option
155
 
#% guisection: Color
156
 
#% key: endcolor
157
 
#% type: string
158
 
#% label: Ending color for custom color gradient
159
 
#% description: Must be expressed as R:G:B triplet
160
 
#% answer: 0:0:255
161
 
#% required : no
162
 
#%end
163
 
#% option
164
 
#% guisection: Misc
165
 
#% key: monitor
166
 
#% type: string
167
 
#% description: Select x11 display monitor for legend
168
 
#% options: x0,x1,x2,x3,x4,x5,x6,none
169
 
#% answer: x1
170
 
#% required : no
171
 
#%end
172
 
#%flag 
173
 
#% guisection: Files
174
 
#%key: g
175
 
#%description: Save thematic map commands to group file for GIS Manager
176
 
#%end
177
 
#%option
178
 
#% guisection: Theme
179
 
#% key: where
180
 
#% type: string
181
 
#% description: WHERE conditions of SQL statement without 'where' keyword
182
 
#% required : no
183
 
#%end
184
 
#%option
185
 
#% guisection: Files
186
 
#% key: psmap
187
 
#% type: string
188
 
#% label: Root for the name of psmap instruction files to be in current directory
189
 
#% description: If not set, no psmap instruction files will be created)
190
 
#% required : no
191
 
#%end
192
 
#%option
193
 
#% guisection: Files
194
 
#% key: group
195
 
#% type: string
196
 
#% gisprompt: new_file,file,group
197
 
#% description: Name of group file where thematic map commands will be saved
198
 
#% required : no
199
 
#%end
200
 
#%flag 
201
 
#% guisection: Theme
202
 
#%key: l
203
 
#%description: Create graphic legend in x11 display monitor
204
 
#%end
205
 
#%flag
206
 
#% guisection: Color
207
 
#% key: f
208
 
#% description: Only draw fills (no outlines) for areas and points
209
 
#%end
210
 
#%flag
211
 
#% guisection: Color
212
 
#% key: u
213
 
#% description: Update color values to GRASSRGB column in attribute table
214
 
#%end
215
 
#%flag 
216
 
#% guisection: Misc
217
 
#%key: s
218
 
#%description: Output legend for GIS Manager (for scripting use only)
219
 
#%end
220
 
#%flag 
221
 
#% guisection: Misc
222
 
#%key: m
223
 
#%description: Use math notation brackets in legend
224
 
#%end
225
 
 
226
 
if  [ -z "$GISBASE" ] ; then
227
 
    echo "You must be in GRASS GIS to run this program." >&2
228
 
 exit 1
229
 
fi   
230
 
 
231
 
if [ "$1" != "@ARGS_PARSED@" ] ; then
232
 
    exec g.parser "$0" "$@"
233
 
fi
234
 
 
235
 
PROG=`basename "$0"`
236
 
 
237
 
#### check if we have awk
238
 
if [ ! -x "`which awk`" ] ; then
239
 
    g.message -e "awk required, please install awk or gawk first" 
240
 
    exit 1
241
 
fi
242
 
 
243
 
# setting environment, so that awk works properly in all languages
244
 
unset LC_ALL
245
 
LC_NUMERIC=C
246
 
export LC_NUMERIC
247
 
 
248
 
# hard-coded parameter: the maximum number of legend items before
249
 
# we strip them using a middle ellipsis
250
 
MAX_LEG_ITEMS=18
251
 
 
252
 
# check column type
253
 
COLTYPE=`v.info -c "$GIS_OPT_MAP" layer="$GIS_OPT_LAYER" 2> /dev/null | grep -w "$GIS_OPT_COLUMN" | cut -d'|' -f1 | tr -s '[:upper:]' '[:lower:]'`
254
 
 
255
 
#COLTYPE=... 
256
 
if [ -z "$COLTYPE" ] ; then 
257
 
   g.message -e message="No such column [$GIS_OPT_COLUMN]" 
258
 
   exit 1 
259
 
fi 
260
 
 
261
 
if [ "$COLTYPE" != "integer" ] && [ "$COLTYPE" != "double precision" ] ; then
262
 
   g.message -e message="Column <$GIS_OPT_COLUMN> is of type <$COLTYPE> which is not numeric."
263
 
   exit 1
264
 
fi
265
 
 
266
 
# create temporary file to hold output from v.univar
267
 
TMP1="`g.tempfile pid=$$`"
268
 
if [ $? -ne 0 ] || [ -z "$TMP1" ] ; then
269
 
    g.message -e "Unable to create temporary file for statistics"
270
 
    exit 1
271
 
fi
272
 
 
273
 
# create temporary file to hold d.graph commands for legend
274
 
TMP2="`g.tempfile pid=$$`"
275
 
if [ $? -ne 0 ] || [ -z "$TMP2" ] ; then
276
 
    g.message -e "Unable to create temporary file for legend"
277
 
    exit 1
278
 
fi
279
 
 
280
 
# Create temporary file to commands for GIS Manager group
281
 
TMP3="`g.tempfile pid=$$`"
282
 
if [ $? -ne 0 ] || [ -z "$TMP3" ] ; then
283
 
    g.message -e "Unable to create temporary file for group"
284
 
    exit 1
285
 
fi
286
 
 
287
 
# Create temporary file for commands for ps.map map file
288
 
TMP4="`g.tempfile pid=$$`"
289
 
if [ $? -ne 0 ] || [ -z "$TMP4" ] ; then
290
 
    g.message -e "Unable to create temporary file for ps.map legend"
291
 
    exit 1
292
 
fi
293
 
 
294
 
# Create temporary file for commands for ps.map legend file
295
 
TMP5="`g.tempfile pid=$$`"
296
 
if [ $? -ne 0 ] || [ -z "$TMP5" ] ; then
297
 
    g.message -e "Unable to create temporary file for ps.map legend"
298
 
    exit 1
299
 
fi
300
 
 
301
 
# create file to hold elements for GIS Manager legend
302
 
TMP6="`g.tempfile pid=$$`"
303
 
if [ $? -ne 0 ] || [ -z "$TMP6" ] ; then
304
 
    g.message -e "Unable to create temporary file for GIS Manager legend" 
305
 
    exit 1
306
 
fi
307
 
 
308
 
 
309
 
# Set display variables for group
310
 
atype=0
311
 
ptype=0
312
 
ctype=0
313
 
ltype=0
314
 
btype=0
315
 
 
316
 
case "$GIS_OPT_TYPE" in
317
 
    "area" ) atype=1 ;; 
318
 
    "point" )  ptype=1 ;;
319
 
    "centroid" ) ctype=1 ;;
320
 
    "line" ) ltype=1 ;;
321
 
    "boundary" ) btype=1 ;;
322
 
esac
323
 
 
324
 
cleanup()
325
 
{
326
 
    \rm -f "$TMP1" "$TMP1.sort" "$TMP2" "$TMP2.sort" "$TMP3" "$TMP3.sort" \
327
 
           "$TMP4" "$TMP4.sort" "$TMP5" "$TMP5.sort" "$TMP6" "$TMP6.sort"
328
 
}
329
 
 
330
 
# what to do in case of user break:
331
 
exitprocedure()
332
 
{
333
 
    g.message -e message='User break!'
334
 
    cleanup
335
 
    exit 1
336
 
}
337
 
# shell check for user break (signal list: trap -l)
338
 
trap "exitprocedure" 2 3 15
339
 
 
340
 
# identify current monitor or start monitor
341
 
if [ "$GIS_FLAG_S" -ne 1 ] ; then
342
 
    currmon=`eval d.mon -L | grep "(selected)" | awk '{print $1}'`
343
 
fi
344
 
 
345
 
if [ -z "$currmon" -a "$GIS_FLAG_S" -ne 1 ] ; then
346
 
        g.message -e message='*** You must open a display monitor ***'
347
 
        cleanup
348
 
        exit 2
349
 
fi
350
 
 
351
 
# if running in the GUI, do not create a graphic legend in an xmon
352
 
if [ "$GIS_FLAG_S" -eq 1 ] ; then
353
 
    GIS_FLAG_L=0
354
 
    # if running in GUI, turn off immediate mode rendering so that the
355
 
    # iterated d.vect commands will composite using the display driver
356
 
    autowrite=$GRASS_PNG_AUTO_WRITE
357
 
    pngread=$GRASS_PNG_READ
358
 
    GRASS_PNG_READ=TRUE
359
 
    export GRASS_PNG_READ
360
 
    GRASS_PNG_AUTO_WRITE=FALSE
361
 
    export GRASS_PNG_AUTO_WRITE
362
 
fi
363
 
 
364
 
table=`v.db.connect "$GIS_OPT_MAP" -gl layer="$GIS_OPT_LAYER" fs="|" | cut -f2 -d'|'`
365
 
database=`v.db.connect "$GIS_OPT_MAP" -gl layer="$GIS_OPT_LAYER" fs="|" | cut -f4 -d'|'`
366
 
driver=`v.db.connect "$GIS_OPT_MAP" -gl layer="$GIS_OPT_LAYER" fs="|" | cut -f5 -d'|'`
367
 
 
368
 
if [ -z "$table" ] ; then
369
 
    g.message -e message="No table connected or layer <$GIS_OPT_LAYER> does not exist."
370
 
    exit 1
371
 
fi
372
 
 
373
 
# update color values to the table?
374
 
if [ "$GIS_FLAG_U" -eq 1 ] ; then
375
 
    # test, if the column GRASSRGB is in the table
376
 
    if [ -z "`db.columns table=$table database=$database driver=$driver| grep -i grassrgb`" ] ; then
377
 
        g.message message="Creating column 'grassrgb' in table '$table'"
378
 
        echo "ALTER TABLE $table ADD COLUMN grassrgb varchar(11)" | db.execute database="${database}" driver=${driver}
379
 
    fi
380
 
fi
381
 
 
382
 
# Group name
383
 
if [ -z "$GIS_OPT_GROUP" ] ; then
384
 
    group="themes"
385
 
else
386
 
    group=$GIS_OPT_GROUP
387
 
fi
388
 
 
389
 
echo "Group $group" > "$TMP3"
390
 
 
391
 
# Calculate statistics for thematic intervals
392
 
if [ -z "$GIS_OPT_WHERE" ] ; then
393
 
  if [ "$GIS_OPT_TYPE" = "line" ] ; then
394
 
     v.univar -e -g map=$GIS_OPT_MAP type=line column=$GIS_OPT_COLUMN layer="$GIS_OPT_LAYER" > "$TMP1"
395
 
  else
396
 
     v.univar -e -g map=$GIS_OPT_MAP type=point,centroid column=$GIS_OPT_COLUMN layer="$GIS_OPT_LAYER" > "$TMP1"
397
 
  fi
398
 
else
399
 
  if [ "$GIS_OPT_TYPE" = "line" ] ; then
400
 
     v.univar -e -g map=$GIS_OPT_MAP type=line column=$GIS_OPT_COLUMN where="$GIS_OPT_WHERE" layer="$GIS_OPT_LAYER" > "$TMP1"
401
 
 else
402
 
     v.univar -e -g map=$GIS_OPT_MAP type=point,centroid column=$GIS_OPT_COLUMN where="$GIS_OPT_WHERE" layer="$GIS_OPT_LAYER" > "$TMP1"
403
 
 fi
404
 
fi
405
 
  
406
 
min=`grep 'min=' "$TMP1" | sed s/min=//`
407
 
max=`grep 'max=' "$TMP1" | sed s/max=//`
408
 
mean=`grep 'mean=' "$TMP1" | sed s/mean=//`
409
 
sd=`grep 'population_stddev=' "$TMP1" | sed s/'population_stddev='//`
410
 
q1=`grep 'first_quartile=' "$TMP1" | sed s/'first_quartile='//`
411
 
q2=`grep 'median=' "$TMP1" | sed s/'median='//`
412
 
q3=`grep 'third_quartile=' "$TMP1" | sed s/'third_quartile='//`
413
 
q4="$max"
414
 
ptsize="$GIS_OPT_SIZE"
415
 
 
416
 
if [ -n "$GIS_OPT_BREAKPOINTS" ] && [ "$GIS_OPT_THEMECALC" != "custom_breaks" ] ; then
417
 
    g.message -w "Custom breakpoints ignored due to themecalc setting."
418
 
fi
419
 
 
420
 
# set interval for each thematic map calculation type
421
 
case "$GIS_OPT_THEMECALC" in 
422
 
"interval" )
423
 
    numint=$GIS_OPT_NINT
424
 
    step=`echo $min $max $numint | awk '{print (($2 - $1) / $3)}'`
425
 
    breakpoints=`echo $min $max $numint | awk '{for(i=0;i<$3;i++){printf $1+($2-$1)/$3*i " "}printf $2}'`
426
 
    annotations=""
427
 
    ;;
428
 
 
429
 
"std_deviation" )
430
 
    # 2 standard deviation units on either side of mean,
431
 
    # plus min to -2 sd units and +2 sd units to max, if applicable
432
 
    breakpoints=`echo $min $max $mean $sd | awk '{printf $1;for(i=-2;i<=2;i++){ith=$3+i*$4;if($1<ith && $2>ith){printf " " ith}}print " " $2}'`
433
 
    annotations=`echo $min $max $mean $sd | awk '{printf "";for(i=-2;i<=2;i++){ith=$3+i*$4;if($1<ith && $2>ith){if(i!=0){printf ";"((i<0)?"":"+") i "sd"} }}print ";"}'`
434
 
    numint=`echo $breakpoints | awk '{print NF-1}'`
435
 
    ;;
436
 
 
437
 
"quartiles" )
438
 
    numint=4
439
 
    # one for each quartile
440
 
    breakpoints="$min $q1 $q2 $q3 $max"
441
 
    annotations=" q1; q2; q3; q4"
442
 
    ;;
443
 
 
444
 
"custom_breaks" )
445
 
        if [ -z "$GIS_OPT_BREAKPOINTS" ] ; then
446
 
            breakpoints=`cat | awk '{gsub("[^0-9., ]","",$0);print}'`
447
 
        else
448
 
                breakpoints="$GIS_OPT_BREAKPOINTS"
449
 
        fi
450
 
    numint=`echo $breakpoints|awk '{print NF-1}'`
451
 
    annotations=""
452
 
    ;;
453
 
 
454
 
 "*")
455
 
    g.message -e "Unknown themecalc type"
456
 
    cleanup
457
 
    exit
458
 
esac
459
 
 
460
 
pointstep=`echo $GIS_OPT_MAXSIZE $ptsize $numint | awk '{print (($1 - $2) / ($3-1))}'`
461
 
 
462
 
# Prepare legend cuts for too large numint
463
 
if [ $numint -gt $MAX_LEG_ITEMS ]; then
464
 
    xupper=`echo $numint $MAX_LEG_ITEMS | awk '{print int($1 - $2/2)+1}'`
465
 
    xlower=`echo $MAX_LEG_ITEMS | awk '{print int($1/2)+1}'`
466
 
else
467
 
    xupper=0
468
 
    xlower=0
469
 
fi
470
 
 
471
 
# legend title
472
 
echo "color 0:0:0" > "$TMP2"
473
 
echo "size 2 2" >> "$TMP2"
474
 
echo "move 1 95" >> "$TMP2"
475
 
echo "text Thematic map legend for column $GIS_OPT_COLUMN of map $GIS_OPT_MAP" >> "$TMP2"
476
 
echo "size 1.5 1.8" >> "$TMP2"
477
 
echo "move 4 90" >> "$TMP2"
478
 
echo "text Value range: $min - $max" >> "$TMP2"
479
 
 
480
 
echo "title - - - {Thematic map legend for column $GIS_OPT_COLUMN of map $GIS_OPT_MAP}" > "$TMP6"
481
 
 
482
 
echo "text 1% 95% Thematic map legend for column $GIS_OPT_COLUMN of map $GIS_OPT_MAP" >> "$TMP5"
483
 
echo "  ref bottom left" >> "$TMP5"
484
 
echo "end" >> "$TMP5"
485
 
echo "text 4% 90% Value range: $min - $max" >> "$TMP5"
486
 
echo "  ref bottom left" >> "$TMP5"
487
 
echo "end" >> "$TMP5"
488
 
 
489
 
g.message message="Thematic map legend for column $GIS_OPT_COLUMN of map $GIS_OPT_MAP"
490
 
g.message message="Value range: $min - $max"
491
 
 
492
 
# graduated color thematic mapping
493
 
if [ "$GIS_OPT_THEMETYPE" = "graduated_colors" ] ; then
494
 
    # set color schemes for graduated color maps
495
 
    case "$GIS_OPT_COLORSCHEME" in
496
 
                "blue-red" )
497
 
            startc="0:0:255"
498
 
            endc="255:0:0"
499
 
            ;;    
500
 
        "red-blue" )
501
 
            startc="255:0:0"
502
 
            endc="0:0:255"
503
 
            ;;
504
 
        "green-red" )
505
 
            startc="0:255:0"
506
 
            endc="255:0:0"
507
 
            ;;
508
 
        "red-green" )
509
 
            startc="255:0:0"
510
 
            endc="0:255:0"
511
 
            ;;
512
 
        "blue-green" )
513
 
            startc="0:0:255"
514
 
            endc="0:255:0"
515
 
            ;;
516
 
                "green-blue" )
517
 
            startc="0:255:0"
518
 
            endc="0:0:255"
519
 
            ;;
520
 
                "cyan-yellow" )
521
 
            startc="0:255:255"
522
 
            endc="255:255:0"
523
 
            ;;
524
 
                "yellow-cyan" )
525
 
            startc="255:255:0"
526
 
            endc="0:255:255"
527
 
            ;;
528
 
        "custom_gradient" )
529
 
            startc="$GIS_OPT_STARTCOLOR"
530
 
            endc="$GIS_OPT_ENDCOLOR"
531
 
            ;;
532
 
        "single_color" )
533
 
            if [ "$GIS_OPT_THEMETYPE" = "graduated_points" ]; then
534
 
                        startc="$GIS_OPT_LINECOLOR"
535
 
                        endc="$GIS_OPT_LINECOLOR"
536
 
            else
537
 
                        startc="$GIS_OPT_POINTCOLOR"
538
 
                        endc="$GIS_OPT_POINTCOLOR"
539
 
            fi
540
 
            ;;
541
 
        "*")
542
 
            g.message -e message="This should not happen: gparser error. Unknown color scheme $GIS_OPT_COLORSCHEME"
543
 
            cleanup
544
 
            exit
545
 
            ;;
546
 
    esac
547
 
 
548
 
    for i in 1 2 3; do
549
 
        eval color$i=`echo $startc | cut -d':' -f$i`
550
 
        eval endcolor$i=`echo $endc | cut -d':' -f$i`
551
 
    done
552
 
 
553
 
    #The number of color steps is one less then the number of classes
554
 
    nclrstep=`expr $numint - 1`
555
 
    
556
 
    clrstep1=`expr \( $color1 - $endcolor1 \) / $nclrstep`
557
 
    clrstep2=`expr \( $color2 - $endcolor2 \) / $nclrstep`
558
 
    clrstep3=`expr \( $color3 - $endcolor3 \) / $nclrstep`
559
 
 
560
 
    themecolor="$startc"
561
 
 
562
 
    # display graduated color themes
563
 
    if [ "$GIS_OPT_THEMECALC" = "interval" ] ; then
564
 
        echo "move 4 87" >> "$TMP2"
565
 
        echo "text Mapped by $numint intervals of $step" >> "$TMP2"
566
 
 
567
 
                echo "subtitle - - - {Mapped by $numint intervals of $step}" >> "$TMP6"
568
 
 
569
 
        echo "text 4% 87% Mapped by $numint intervals of $step" >> "$TMP5"
570
 
        echo "  ref bottom left" >> "$TMP5"
571
 
        echo "end" >> "$TMP5"
572
 
 
573
 
        g.message message="Mapped by $numint intervals of $step"
574
 
    fi
575
 
 
576
 
    # display graduated color themes for standard deviation units
577
 
    if [ "$GIS_OPT_THEMECALC" = "std_deviation" ] ; then
578
 
 
579
 
        echo "move 4 87" >> "$TMP2"
580
 
        echo "text Mapped by standard deviation units of $sd (mean =$mean)" >> "$TMP2"
581
 
 
582
 
                echo "subtitle - - - {Mapped by standard deviation units of $sd (mean =$mean)}" >> "$TMP6"
583
 
 
584
 
        echo "text 4% 87% Mapped by standard deviation units of $sd (mean =$mean)" >> "$TMP5"
585
 
        echo "  ref bottom left" >> "$TMP5"
586
 
        echo "end" >> "$TMP5"
587
 
 
588
 
        g.message message="Mapped by standard deviation units of $sd (mean =$mean)"
589
 
    fi
590
 
 
591
 
    # display graduated color themes for quartiles
592
 
    if [ "$GIS_OPT_THEMECALC" = "quartiles" ] ; then
593
 
 
594
 
        echo "move 4 87" >> "$TMP2"
595
 
        echo "text Mapped by quartiles (median =$q2)" >> "$TMP2"
596
 
 
597
 
                echo "subtitle - - - {Mapped by quartiles (median =$q2)}" >> "$TMP6"
598
 
 
599
 
        echo "text 4% 87% Mapped by quartiles (median =$q2)" >> "$TMP5"
600
 
        echo "  ref bottom left" >> "$TMP5"
601
 
        echo "end" >> "$TMP5"
602
 
 
603
 
        
604
 
 
605
 
        g.message message="Mapped by quartiles (median = $q2)"
606
 
    fi
607
 
 
608
 
    echo "move 4 83" >> "$TMP2"
609
 
    echo "text Color" >> "$TMP2"
610
 
    echo "move 14 83" >> "$TMP2"
611
 
    echo "text Value" >> "$TMP2"
612
 
    echo "move 4 80" >> "$TMP2"
613
 
    echo "text =====" >> "$TMP2"
614
 
    echo "move 14 80" >> "$TMP2"
615
 
    echo "text ============" >> "$TMP2"
616
 
 
617
 
 
618
 
    echo "text 4% 83% Color" >> "$TMP5"
619
 
    echo "  ref bottom left" >> "$TMP5"
620
 
    echo "end" >> "$TMP5"
621
 
    echo "text 14% 83% Value" >> "$TMP5"
622
 
    echo "  ref bottom left" >> "$TMP5"
623
 
    echo "end" >> "$TMP5"
624
 
    echo "text 4% 80% =====" >> "$TMP5"
625
 
    echo "  ref bottom left" >> "$TMP5"
626
 
    echo "end" >> "$TMP5"
627
 
    echo "text 14% 80% ============" >> "$TMP5"
628
 
    echo "  ref bottom left" >> "$TMP5"
629
 
    echo "end" >> "$TMP5"
630
 
 
631
 
 
632
 
    echo "Color(R:G:B)" "Value" | awk '{print $1 "\t" $2}'
633
 
    echo "============" "==========" | awk '{print $1 "\t" $2}'
634
 
 
635
 
    line1=78
636
 
    line2=76
637
 
    line3=75
638
 
 
639
 
    i=1
640
 
    first="true"
641
 
 
642
 
    while [ $i -le $numint ]     
643
 
        do 
644
 
        if [ "$GIS_FLAG_M" -eq 1 ] ; then
645
 
        # math notation
646
 
           if [ "$first" = "true" ] ; then
647
 
                closebracket="]"
648
 
                openbracket="["
649
 
                mincomparison=">="
650
 
                first="false"
651
 
            else
652
 
                closebracket="]"
653
 
                openbracket="]"
654
 
                mincomparison=">"            
655
 
            fi
656
 
        else
657
 
            closebracket="" 
658
 
            openbracket=""
659
 
            if [ "$first" = "true" ] ; then
660
 
                mincomparison=">="
661
 
                first="false"
662
 
            else
663
 
                mincomparison=">"            
664
 
            fi
665
 
        fi
666
 
 
667
 
        themecolor="$color1:$color2:$color3"
668
 
        if [ "$GIS_FLAG_F" -eq 1 ] ; then
669
 
                linecolor="none"
670
 
        else
671
 
                if [ "$GIS_OPT_TYPE" = "line" -o "$GIS_OPT_TYPE" = "boundary" ] ; then
672
 
                   linecolor=$themecolor
673
 
                else
674
 
                    linecolor="$GIS_OPT_LINECOLOR"
675
 
                fi
676
 
        fi
677
 
      
678
 
        rangemin=`echo $i $breakpoints | awk '{t=$1+1;print $t}'`
679
 
        rangemax=`echo $i $breakpoints | awk '{t=$1+2;print $t}'`
680
 
 
681
 
        if [ -z "$annotations" ]; then
682
 
            extranote=""
683
 
        else
684
 
            extranote=`echo $annotations| cut -d';' -f$i`
685
 
        fi
686
 
 
687
 
    if [ $i -lt $xlower -o $i -ge $xupper ]; then
688
 
        xline1=`expr $line2 + 2`
689
 
        xline3=`expr $line2 - 1`
690
 
        echo "color $themecolor" >> "$TMP2"
691
 
        echo "polygon" >> "$TMP2"
692
 
        echo "5 $xline1" >> "$TMP2"
693
 
        echo "8 $xline1" >> "$TMP2"
694
 
        echo "8 $xline3" >> "$TMP2"
695
 
        echo "5 $xline3" >> "$TMP2"
696
 
        echo "color $linecolor" >> "$TMP2"
697
 
        echo "move 5 $xline1" >> "$TMP2"
698
 
        echo "draw 8 $xline1" >> "$TMP2"
699
 
        echo "draw 8 $xline3" >> "$TMP2"
700
 
        echo "draw 5 $xline3" >> "$TMP2"
701
 
        echo "draw 5 $xline1" >> "$TMP2"
702
 
        echo "move 14 $line2" >> "$TMP2"
703
 
        echo "color 0:0:0" >> "$TMP2"
704
 
        echo "text $openbracket$rangemin - $rangemax$closebracket $extranote"  >> "$TMP2"
705
 
    else
706
 
        if [ $i -eq $xlower ]; then
707
 
            echo "color 0:0:0" >> "$TMP2"
708
 
            echo "move 10 $line2" >> "$TMP2"
709
 
            echo "text ..." >> "$TMP2"
710
 
        else
711
 
            #undo next increment
712
 
            line2=`expr $line2 + 4`         
713
 
        fi
714
 
    fi
715
 
 
716
 
    if [ $i -lt $xlower -o $i -ge $xupper ]; then
717
 
      echo "area $themecolor $linecolor - {$openbracket$rangemin - $rangemax$closebracket $extranote}" >> "$TMP6"
718
 
 
719
 
        if [ "$GIS_OPT_TYPE" = "line" -o "$GIS_OPT_TYPE" = "boundary" ] ; then
720
 
          echo "line 5% $xline1% 8% $xline1%" >> "$TMP5"
721
 
          echo "  color $linecolor" >> "$TMP5"
722
 
          echo "end" >> "$TMP5"
723
 
          echo "text 14% $xline1% $openbracket$rangemin - $rangemax$closebracket $extranote"  >> "$TMP5"
724
 
          echo "  ref center left" >> "$TMP5"
725
 
          echo "end" >> "$TMP5"
726
 
        elif [ "$GIS_OPT_TYPE" = "point" -o "$GIS_OPT_TYPE" = "centroid" ] ; then
727
 
          echo "point 8% $xline1%" >> "$TMP5"
728
 
          echo "  color $linecolor" >> "$TMP5"
729
 
          echo "  fcolor $themecolor" >> "$TMP5"
730
 
          echo "  size $GIS_OPT_SIZE" >> "$TMP5"
731
 
          echo "  symbol $GIS_OPT_ICON" >> "$TMP5"
732
 
          echo "end" >> "$TMP5"
733
 
          echo "text 14% $xline1% $openbracket$rangemin - $rangemax$closebracket $extranote"  >> "$TMP5"
734
 
          echo "  ref center left" >> "$TMP5"
735
 
          echo "end" >> "$TMP5"
736
 
        else
737
 
          echo "rectangle 5% $xline1% 8% $xline3%" >> "$TMP5"
738
 
          echo "  color 0:0:0" >> "$TMP5"
739
 
          echo "  fcolor $themecolor" >> "$TMP5"
740
 
          echo "end" >> "$TMP5"
741
 
          echo "text 14% $xline3% $openbracket$rangemin - $rangemax$closebracket DCADCA $extranote"  >> "$TMP5"
742
 
          echo "  ref bottom left" >> "$TMP5"
743
 
          echo "end" >> "$TMP5"
744
 
        fi
745
 
    else
746
 
        if [ $i -eq $xlower ]; then
747
 
            echo "color 0:0:0" >>"$TMP5"
748
 
            echo "text 14% $xline3% ..." >> "$TMP5"
749
 
            echo "  ref bottom left" >> "$TMP5"
750
 
            echo "end" >> "$TMP5"
751
 
 
752
 
            echo "text - - - {...}" >> "$TMP6"
753
 
        fi
754
 
    fi
755
 
        
756
 
 
757
 
 
758
 
        echo $themecolor@$rangemin@$rangemax@$extranote@$openbracket@$closebracket | awk -F@ '{print $1 "\t\t" $5$2" - "$3$6" "$4}'
759
 
        if [ -z "$GIS_OPT_WHERE" ] ; then
760
 
            sqlwhere="$GIS_OPT_COLUMN $mincomparison $rangemin and $GIS_OPT_COLUMN<=$rangemax"
761
 
        else
762
 
            sqlwhere="$GIS_OPT_COLUMN $mincomparison $rangemin and $GIS_OPT_COLUMN<=$rangemax AND $GIS_OPT_WHERE"
763
 
        fi
764
 
 
765
 
        # update color to database?
766
 
        if [ $GIS_FLAG_U -eq 1 ] ; then
767
 
            echo "UPDATE $table SET GRASSRGB = '$themecolor' WHERE\
768
 
                $sqlwhere" | db.execute database="${database}" driver=${driver}
769
 
        fi
770
 
               
771
 
        # Create group for GIS Manager
772
 
        if [ "$GIS_FLAG_G" -eq 1 ] ; then
773
 
        
774
 
            # change rgb colors to hex
775
 
            xthemecolor=`echo $themecolor | awk -F: '{printf("#%02X%02X%02X\n",$1,$2,$3)}'`
776
 
#            xlinecolor=`echo $linecolor | awk -F: '{printf("#%02X%02X%02X\n",$1,$2,$3)}'`
777
 
            
778
 
            if [ "$linecolor" = "black" ] ; then
779
 
                xlinecolor="#000000"
780
 
            else
781
 
                xlinecolor=$xthemecolor
782
 
            fi
783
 
 
784
 
            # create group entry
785
 
            echo "  _check 1" >> "$TMP3"
786
 
            echo "  Vector $GIS_OPT_COLUMN = $rangemin - $rangemax" >> "$TMP3"
787
 
            echo "    _check 1" >> "$TMP3"
788
 
            echo "    map $GIS_OPT_MAP" >> "$TMP3"
789
 
            echo "    display_shape 1" >> "$TMP3"
790
 
            echo "    display_cat 0" >> "$TMP3"
791
 
            echo "    display_topo 0" >> "$TMP3"
792
 
            echo "    display_dir 0" >> "$TMP3"
793
 
            echo "    display_attr 0" >> "$TMP3"
794
 
            echo "    type_point $ptype" >> "$TMP3"
795
 
            echo "    type_line $ltype" >> "$TMP3"
796
 
            echo "    type_boundary $btype" >> "$TMP3"
797
 
            echo "    type_centroid $ctype" >> "$TMP3"
798
 
            echo "    type_area $atype" >> "$TMP3"
799
 
            echo "    type_face 0" >> "$TMP3"
800
 
            echo "    color $xlinecolor" >> "$TMP3"
801
 
            echo "    fcolor $xthemecolor" >> "$TMP3"
802
 
            echo "    width $ptsize" >> "$TMP3"
803
 
            echo "    _use_fcolor 1" >> "$TMP3"
804
 
            echo "    lcolor #000000" >> "$TMP3"
805
 
            echo "    sqlcolor 0" >> "$TMP3"
806
 
            echo "    icon $GIS_OPT_ICON" >> "$TMP3"
807
 
            echo "    size $ptsize" >> "$TMP3"
808
 
            echo "    field $GIS_OPT_LAYER" >> "$TMP3"
809
 
            echo "    lfield $GIS_OPT_LAYER" >> "$TMP3"
810
 
            echo "    attribute" >> "$TMP3"
811
 
            echo "    xref left" >> "$TMP3"
812
 
            echo "    yref center" >> "$TMP3"
813
 
            echo "    lsize 8" >> "$TMP3"
814
 
            echo "    cat" >> "$TMP3"
815
 
            echo "    where "$sqlwhere >> "$TMP3"
816
 
            echo "    _query_text 0" >> "$TMP3"
817
 
            echo "    _query_edit 1" >> "$TMP3"
818
 
            echo "    _use_where 1" >> "$TMP3"
819
 
            echo "    minreg" >> "$TMP3"
820
 
            echo "    maxreg" >> "$TMP3"
821
 
            echo "    _width 0.1" >> "$TMP3"
822
 
            echo "  End" >> "$TMP3"
823
 
        fi
824
 
        
825
 
        
826
 
        # display theme vector map
827
 
 
828
 
        d.vect map=$GIS_OPT_MAP type=$GIS_OPT_TYPE layer=$GIS_OPT_LAYER \
829
 
            where="$sqlwhere" \
830
 
            color=$linecolor fcolor=$themecolor icon=$GIS_OPT_ICON size=$ptsize
831
 
 
832
 
        if [ "$GIS_OPT_TYPE" = "line" -o "$GIS_OPT_TYPE" = "boundary" ] ; then
833
 
                  echo "vlines $GIS_OPT_MAP" >> "$TMP4"
834
 
                  echo "  type $GIS_OPT_TYPE" >> "$TMP4"
835
 
                  echo "  layer $GIS_OPT_LAYER" >> "$TMP4"
836
 
                  echo "  where $sqlwhere" >> "$TMP4"
837
 
                  echo "  color $linecolor" >> "$TMP4"
838
 
                  echo "  label $rangemin - $rangemax" >> "$TMP4"
839
 
                  echo "end" >> "$TMP4"
840
 
        elif [ "$GIS_OPT_TYPE" = "point" -o "$GIS_OPT_TYPE" = "centroid" ] ; then
841
 
                  echo "vpoints $GIS_OPT_MAP" >> "$TMP4"
842
 
                  echo "  type $GIS_OPT_TYPE" >> "$TMP4"
843
 
                  echo "  layer $GIS_OPT_LAYER" >> "$TMP4"
844
 
                  echo "  where $sqlwhere" >> "$TMP4"
845
 
                  echo "  color $linecolor" >> "$TMP4"
846
 
                  echo "  fcolor $themecolor" >> "$TMP4"
847
 
                  echo "  symbol $GIS_OPT_ICON" >> "$TMP4"
848
 
                  echo "  label $rangemin - $rangemax" >> "$TMP4"
849
 
                  echo "end" >> "$TMP4"
850
 
        else
851
 
                  echo "vareas $GIS_OPT_MAP" >> "$TMP4"
852
 
                  echo "  layer $GIS_OPT_LAYER" >> "$TMP4"
853
 
                  echo "  where $sqlwhere" >> "$TMP4"
854
 
                  echo "  color $linecolor" >> "$TMP4"
855
 
                  echo "  fcolor $themecolor" >> "$TMP4"
856
 
                  echo "  label $rangemin - $rangemax" >> "$TMP4"
857
 
                  echo "end" >> "$TMP4"
858
 
        fi
859
 
 
860
 
 
861
 
        # increment for next theme
862
 
        i=`expr $i + 1`
863
 
        if [ $i = $numint ] ; then
864
 
          color1=$endcolor1
865
 
          color2=$endcolor2
866
 
          color3=$endcolor3
867
 
        else
868
 
          color1=`expr $color1 - $clrstep1`
869
 
          color2=`expr $color2 - $clrstep2`
870
 
          color3=`expr $color3 - $clrstep3`
871
 
        fi
872
 
        line1=`expr $line1 - 4`
873
 
        line2=`expr $line2 - 4`
874
 
        line3=`expr $line3 - 4`
875
 
    done
876
 
    
877
 
fi
878
 
 
879
 
#graduated points and line widths thematic mapping
880
 
 
881
 
if [ "$GIS_OPT_THEMETYPE" = "graduated_points" -o "$GIS_OPT_THEMETYPE" = "graduated_lines" ] ; then
882
 
 
883
 
    #display graduated points/lines by intervals
884
 
    if [ "$GIS_OPT_THEMECALC" = "interval" ] ; then
885
 
        echo "move 4 87" >> "$TMP2"
886
 
        echo "text Mapped by $numint intervals of $step" >> "$TMP2"
887
 
 
888
 
                echo "subtitle - - - {Mapped by $numint intervals of $step}" >> "$TMP6"
889
 
 
890
 
        echo "text 4% 87% Mapped by $numint intervals of $step" >> "$TMP5"
891
 
        echo "  ref bottom left" >> "$TMP5"
892
 
        echo "end" >> "$TMP5"
893
 
 
894
 
        g.message message="Mapped by $numint intervals of $step"
895
 
    fi
896
 
        
897
 
    # display graduated points/lines for standard deviation units
898
 
    if [ "$GIS_OPT_THEMECALC" = "std_deviation" ] ; then
899
 
 
900
 
        echo "move 4 87" >> "$TMP2"
901
 
        echo "text Mapped by standard deviation units of $sd (mean =$mean)" >> "$TMP2"
902
 
 
903
 
                echo "subtitle - - - {Mapped by standard deviation units of $sd (mean =$mean)}" >> "$TMP6"
904
 
 
905
 
        echo "text 4% 87% Mapped by standard deviation units of $sd (mean =$mean)" >> "$TMP5"
906
 
                echo "  ref bottom left" >> "$TMP5"
907
 
                echo "end" >> "$TMP5"
908
 
        
909
 
        g.message message="Mapped by standard deviation units of $sd (mean =$mean)"
910
 
    fi
911
 
    
912
 
    # display graduated points/lines for quartiles
913
 
    if [ "$GIS_OPT_THEMECALC" = "quartiles" ] ; then
914
 
 
915
 
        echo "move 4 87" >> "$TMP2"
916
 
        echo "text Mapped by quartiles (median =$q2)" >> "$TMP2"
917
 
 
918
 
                echo "subtitle - - - {Mapped by quartiles (median =$q2)}" >> "$TMP6"
919
 
 
920
 
        echo "text 4% 87% Mapped by quartiles (median =$q2)" >> "$TMP5"
921
 
        echo "  ref bottom left" >> "$TMP5"
922
 
        echo "end" >> "$TMP5"
923
 
 
924
 
        g.message message="Mapped by quartiles (median = $q2)"
925
 
    fi
926
 
        
927
 
    line1=76
928
 
    line2=75
929
 
    echo "move 4 83" >> "$TMP2"
930
 
    echo "text Size/width" >> "$TMP2"
931
 
    echo "move 25 83" >> "$TMP2"
932
 
    echo "text Value" >> "$TMP2"
933
 
    echo "move 4 80" >> "$TMP2"
934
 
    echo "text ==============" >> "$TMP2"
935
 
    echo "move 25 80" >> "$TMP2"
936
 
    echo "text ==============" >> "$TMP2"
937
 
 
938
 
 
939
 
    echo "text 4% 83% Icon size" >> "$TMP5"
940
 
    echo "  ref bottom left" >> "$TMP5"
941
 
    echo "end" >> "$TMP5"
942
 
    echo "text 25% 83% Value" >> "$TMP5"
943
 
    echo "  ref bottom left" >> "$TMP5"
944
 
    echo "end" >> "$TMP5"
945
 
    echo "text 4% 80% ============" >> "$TMP5"
946
 
    echo "  ref bottom left" >> "$TMP5"
947
 
    echo "end" >> "$TMP5"
948
 
    echo "text 25% 80% ============" >> "$TMP5"
949
 
    echo "  ref bottom left" >> "$TMP5"
950
 
    echo "end" >> "$TMP5"
951
 
 
952
 
    
953
 
    echo "Size/width" "Value" | awk '{print $1 " " $2"\t"$3}'
954
 
    echo "==========" "=====" | awk '{print $1 "\t" $2}'
955
 
 
956
 
    themecolor=$GIS_OPT_POINTCOLOR
957
 
    
958
 
        if [ "$GIS_FLAG_F" -eq 1 ] ; then
959
 
                linecolor="none"
960
 
        else
961
 
                linecolor="$GIS_OPT_LINECOLOR"
962
 
        fi
963
 
 
964
 
    i=$numint
965
 
    ptsize=$GIS_OPT_MAXSIZE
966
 
 
967
 
    while [ $i -ge 1 ]     
968
 
        do 
969
 
        if [ "$GIS_FLAG_M" -eq 1 ] ; then
970
 
        # math notation
971
 
           if [ "$i" = "1" ] ; then
972
 
                closebracket="]"
973
 
                openbracket="["
974
 
                mincomparison=">="
975
 
            else
976
 
                closebracket="]"
977
 
                openbracket="]"
978
 
                mincomparison=">"            
979
 
            fi
980
 
        else
981
 
            closebracket="" 
982
 
            openbracket=""
983
 
            if [ "$i" = "1" ] ; then
984
 
                mincomparison=">="
985
 
            else
986
 
                mincomparison=">"            
987
 
            fi
988
 
        fi
989
 
 
990
 
        themecolor=$GIS_OPT_POINTCOLOR
991
 
 
992
 
                if [ "$GIS_FLAG_F" -eq 1 ] ; then
993
 
                        linecolor="none"
994
 
                else
995
 
                        linecolor="$GIS_OPT_LINECOLOR"
996
 
                fi
997
 
      
998
 
        rangemin=`echo $i $breakpoints | awk '{t=$1+1;print $t}'`
999
 
        rangemax=`echo $i $breakpoints | awk '{t=$1+2;print $t}'`
1000
 
 
1001
 
        if [ -z "$annotations" ]; then
1002
 
            extranote=""
1003
 
        else
1004
 
            extranote=`echo $annotations| cut -d';' -f$i`
1005
 
        fi            
1006
 
 
1007
 
        iconsize=`echo $ptsize | awk '{print int($1 / 2)}'`
1008
 
        lineht=`echo $ptsize | awk '{print int($1 / 4)}'`
1009
 
        if [ "$lineht" -lt "4" ] ; then
1010
 
            lineht=4
1011
 
        fi
1012
 
 
1013
 
    if [ $i -lt $xlower -o $i -ge $xupper ]; then
1014
 
        if [ "$GIS_OPT_THEMETYPE" = "graduated_lines" ]; then
1015
 
            echo "color $linecolor" >> "$TMP2"
1016
 
            echo "line $themecolor $linecolor $ptsize {$openbracket$rangemin - $rangemax$closebracket $extranote}" >> "$TMP6"
1017
 
        else
1018
 
            echo "color $themecolor" >> "$TMP2"
1019
 
            echo "point $themecolor $linecolor $ptsize {$openbracket$rangemin - $rangemax$closebracket $extranote}" >> "$TMP6"
1020
 
        fi
1021
 
 
1022
 
        echo "icon + $iconsize 5 $line1" >> "$TMP2"
1023
 
        echo "color 0:0:0" >> "$TMP2"
1024
 
        echo "move 10 $line2" >> "$TMP2"
1025
 
        echo "text $ptsize pts" >> "$TMP2"
1026
 
        echo "move 25 $line2" >> "$TMP2"
1027
 
        echo "text $openbracket$rangemin - $rangemax$closebracket $extranote"  >> "$TMP2"
1028
 
    else
1029
 
        if [ $i -eq $xlower ]; then
1030
 
            echo "color 0:0:0" >>"$TMP2"
1031
 
            echo "move 10 $line2" >> "$TMP2"
1032
 
            echo "text ..." >> "$TMP2"
1033
 
            echo "text - - - ..." >> "$TMP6"
1034
 
        else
1035
 
            # undo future line increment
1036
 
            line2=`expr $line2 + $lineht`
1037
 
        fi
1038
 
    fi
1039
 
 
1040
 
    if [ $i -lt $xlower -o $i -ge $xupper ]; then
1041
 
        echo "point 8% $line1%" >> "$TMP5"
1042
 
        echo "  color $linecolor" >> "$TMP5"
1043
 
        echo "  fcolor $themecolor" >> "$TMP5"
1044
 
        echo "  size $iconsize" >> "$TMP5"
1045
 
        echo "  symbol $GIS_OPT_ICON" >> "$TMP5"
1046
 
        echo "end" >> "$TMP5"
1047
 
        echo "text 25% $line1% $openbracket$rangemin - $rangemax$closebracket $extranote"  >> "$TMP5"
1048
 
        echo "  ref center left" >> "$TMP5"
1049
 
        echo "end" >> "$TMP5"
1050
 
    else
1051
 
        if [ $i -eq $xlower ]; then
1052
 
            echo "text 25% $xline1% ..."  >> "$TMP5"
1053
 
            echo "   ref center left"  >> "$TMP5"
1054
 
            echo "end" >> "$TMP5"
1055
 
        fi
1056
 
    fi
1057
 
 
1058
 
        echo $ptsize@$rangemin@$rangemax@$extranote@$openbracket@$closebracket | awk -F@ '{print $1 "\t\t" $5$2" - "$3$6" "$4}'
1059
 
 
1060
 
        if [ -z "$GIS_OPT_WHERE" ] ; then
1061
 
           sqlwhere="$GIS_OPT_COLUMN $mincomparison $rangemin and $GIS_OPT_COLUMN<=$rangemax"
1062
 
        else
1063
 
           sqlwhere="$GIS_OPT_COLUMN $mincomparison $rangemin and $GIS_OPT_COLUMN<=$rangemax AND $GIS_OPT_WHERE"
1064
 
        fi
1065
 
 
1066
 
        # update color to database?
1067
 
        if [ $GIS_FLAG_U -eq 1 ] ; then
1068
 
            echo "UPDATE $table SET GRASSRGB = '$themecolor' WHERE\
1069
 
                $sqlwhere" | db.execute database="${database}" driver=${driver}
1070
 
        fi
1071
 
      
1072
 
        # Create group for GIS Manager
1073
 
        if [ "$GIS_FLAG_G" -eq 1 ] ; then
1074
 
        
1075
 
            # change rgb colors to hex
1076
 
            xthemecolor=`echo $themecolor | awk -F: '{printf("#%02X%02X%02X\n",$1,$2,$3)}'`
1077
 
            xlinecolor="#000000"
1078
 
 
1079
 
            # create group entry
1080
 
            echo "  _check 1" >> "$TMP3"
1081
 
            echo "  Vector $GIS_OPT_COLUMN = $rangemin - $rangemax" >> "$TMP3"
1082
 
            echo "    _check 1" >> "$TMP3"
1083
 
            echo "    map $GIS_OPT_MAP" >> "$TMP3"
1084
 
            echo "    display_shape 1" >> "$TMP3"
1085
 
            echo "    display_cat 0" >> "$TMP3"
1086
 
            echo "    display_topo 0" >> "$TMP3"
1087
 
            echo "    display_dir 0" >> "$TMP3"
1088
 
            echo "    display_attr 0" >> "$TMP3"
1089
 
            echo "    type_point $ptype" >> "$TMP3"
1090
 
            echo "    type_line $ltype" >> "$TMP3"
1091
 
            echo "    type_boundary $btype" >> "$TMP3"
1092
 
            echo "    type_centroid $ctype" >> "$TMP3"
1093
 
            echo "    type_area $atype" >> "$TMP3"
1094
 
            echo "    type_face 0" >> "$TMP3"
1095
 
            echo "    color $xlinecolor" >> "$TMP3"
1096
 
            echo "    width $ptsize" >> "$TMP3"
1097
 
            echo "    fcolor $xthemecolor" >> "$TMP3"
1098
 
            echo "    _use_fcolor 1" >> "$TMP3"
1099
 
            echo "    lcolor #000000" >> "$TMP3"
1100
 
            echo "    sqlcolor 0" >> "$TMP3"
1101
 
            echo "    icon $GIS_OPT_ICON" >> "$TMP3"
1102
 
            echo "    size $ptsize" >> "$TMP3"
1103
 
            echo "    field $GIS_OPT_LAYER" >> "$TMP3"
1104
 
            echo "    lfield $GIS_OPT_LAYER" >> "$TMP3"
1105
 
            echo "    attribute" >> "$TMP3"
1106
 
            echo "    xref left" >> "$TMP3"
1107
 
            echo "    yref center" >> "$TMP3"
1108
 
            echo "    lsize 8" >> "$TMP3"
1109
 
            echo "    cat" >> "$TMP3"
1110
 
            echo "    where "$sqlwhere >> "$TMP3"
1111
 
            echo "    _query_text 0" >> "$TMP3"
1112
 
            echo "    _query_edit 1" >> "$TMP3"
1113
 
            echo "    _use_where 1" >> "$TMP3"
1114
 
            echo "    minreg" >> "$TMP3"
1115
 
            echo "    maxreg" >> "$TMP3"
1116
 
            echo "    _width 0.1" >> "$TMP3"
1117
 
            echo "  End" >> "$TMP3"
1118
 
        fi
1119
 
        
1120
 
        #graduates line widths or point sizes
1121
 
 
1122
 
        if [ "$GIS_OPT_THEMETYPE" = "graduated_lines" ] ; then
1123
 
                d.vect map=$GIS_OPT_MAP type=$GIS_OPT_TYPE layer=$GIS_OPT_LAYER \
1124
 
            where="$sqlwhere" \
1125
 
            color=$linecolor fcolor=$themecolor icon=$GIS_OPT_ICON size=$ptsize \
1126
 
            width=$ptsize
1127
 
                else 
1128
 
                        d.vect map=$GIS_OPT_MAP type=$GIS_OPT_TYPE layer=$GIS_OPT_LAYER \
1129
 
            where="$sqlwhere" \
1130
 
            color=$linecolor fcolor=$themecolor icon=$GIS_OPT_ICON size=$ptsize
1131
 
                fi
1132
 
 
1133
 
          echo "vpoints $GIS_OPT_MAP" >> "$TMP4"
1134
 
          echo "  type $GIS_OPT_TYPE" >> "$TMP4"
1135
 
          echo "  layer $GIS_OPT_LAYER" >> "$TMP4"
1136
 
          echo "  where $sqlwhere" >> "$TMP4"
1137
 
          echo "  color $linecolor" >> "$TMP4"
1138
 
          echo "  fcolor $themecolor" >> "$TMP4"
1139
 
          echo "  symbol $GIS_OPT_ICON" >> "$TMP4"
1140
 
          echo "  size $ptsize" >> "$TMP4"
1141
 
          echo "  label $rangemin - $rangemax" >> "$TMP4"
1142
 
          echo "end" >> "$TMP4"
1143
 
 
1144
 
 
1145
 
        ptsize=`echo $ptsize $pointstep | awk '{print $1 - $2}'`
1146
 
 
1147
 
        line1=`expr $line1 - $lineht`
1148
 
        line2=`expr $line2 - $lineht`
1149
 
        i=`expr $i - 1`
1150
 
    done
1151
 
 
1152
 
fi
1153
 
 
1154
 
if [ "$GIS_FLAG_S" -eq 1 ] ; then
1155
 
    # reset display parameters
1156
 
    GRASS_PNG_READ=$pngread
1157
 
    export GRASS_PNG_READ
1158
 
    GRASS_PNG_AUTO_WRITE=$autowrite
1159
 
    export GRASS_PNG_AUTO_WRITE
1160
 
fi
1161
 
 
1162
 
# Create graphic legend
1163
 
if [ "$GIS_FLAG_L" -eq 1 -a "$GIS_OPT_MONITOR" != "none" ] ; then
1164
 
    if [ `eval d.mon -L | grep $GIS_OPT_MONITOR | awk '{print $5}'` = "not" ] ; then
1165
 
        d.mon start=$GIS_OPT_MONITOR > /dev/null
1166
 
    else 
1167
 
        d.mon select=$GIS_OPT_MONITOR > /dev/null
1168
 
        d.erase
1169
 
    fi
1170
 
    d.graph input="$TMP2"
1171
 
    if [ -n "$currmon" ] ; then
1172
 
      d.mon select=$currmon
1173
 
    fi
1174
 
fi
1175
 
 
1176
 
# Create group file for GIS Manager
1177
 
echo "End" >> "$TMP3"
1178
 
if [ "$GIS_FLAG_G" -eq 1 ] ; then
1179
 
    cat "$TMP3" > "${group}.dm"
1180
 
fi
1181
 
 
1182
 
# Create ps.map map file
1183
 
echo "end" >> "$TMP4"
1184
 
if [ "$GIS_OPT_PSMAP" ] ; then
1185
 
    cat "$TMP4" > "$GIS_OPT_PSMAP.psmap"
1186
 
fi
1187
 
 
1188
 
# Create ps.map legend file
1189
 
echo "end" >> "$TMP5"
1190
 
if [ "$GIS_OPT_PSMAP" ] ; then
1191
 
    cat "$TMP5" > "$GIS_OPT_PSMAP\_legend.psmap"
1192
 
fi
1193
 
 
1194
 
# Create text file to use with d.graph in GIS Manager
1195
 
if [ "$GIS_FLAG_S" -eq 1 ] ; then
1196
 
        tmpdir=`eval dirname "$TMP6"`
1197
 
        tlegfile="$tmpdir/gismlegend.txt"
1198
 
#       echo $tlegfile > outtxt.txt
1199
 
    cp "$TMP6" "$tlegfile"
1200
 
fi
1201
 
 
1202
 
cleanup