-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdrawrec.gs
More file actions
executable file
·63 lines (55 loc) · 1.62 KB
/
Copy pathdrawrec.gs
File metadata and controls
executable file
·63 lines (55 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
*
* drawrec.gs
*
* This function draws a rectangle over a map using World Coordinates,
* i.e., longitude and latitude.
*
* Usage: drawrec lon_min lon_max lat_min lat_max <fill> <warn on|off>
* <fill> can be 0 or 1
* <warn on|off> can be on or off
*
* Written by Henrique Barbosa July 2004
* Last update September 05
*
function drawrec(args)
* Get arguments
Rxa = subwrd(args,1)
Rxb = subwrd(args,2)
Rya = subwrd(args,3)
Ryb = subwrd(args,4)
fil = subwrd(arqs,5)
opt = subwrd(args,6)
* Test for parameters
if (Rxa='' | Rxb='' | Rya='' | Ryb='')
say 'usage: drawrec lon_min lon_max lat_min lat_max <fill> <warn on|off>
return
endif
* Find allowed dimensions
'q dims'
lonlin =sublin(result,2)
Bxa = subwrd(lonlin,6)
Bxb = subwrd(lonlin,8)
latlin =sublin(result,3)
Bya = subwrd(latlin,6)
Byb = subwrd(latlin,8)
* Test if user input within allowed dimensions
if (opt!='off')
if (Rya<Bya | Rya>Byb); say 'warn: lat_min='Rya' is outside range ['Bya','Byb']'; endif
if (Ryb<Bya | Ryb>Byb); say 'warn: lat_max='Ryb' is outside range ['Bya','Byb']'; endif
if (Rxa<Bxa | Rxa>Bxb); say 'warn: lon_min='Rxa' is outside range ['Bxa','Bxb']'; endif
if (Rxb<Bxa | Rxb>Bxb); say 'warn: lon_max='Rxb' is outside range ['Bxa','Bxb']'; endif
endif
* Transform world coordinates to xy
'q w2xy 'Rxa' 'Rya
x1=subwrd(result,3)
y1=subwrd(result,6)
'q w2xy 'Rxb' 'Ryb
x2=subwrd(result,3)
y2=subwrd(result,6)
* Draw a Filled/Empty rectangle
if (fil=1)
'draw recf 'x1' 'y1' 'x2' 'y2
else
'draw rec 'x1' 'y1' 'x2' 'y2''
endif
return