Mapper
libraries
common
plot_isohytes_old.c
Go to the documentation of this file.
1
2
#include "
prototypes_new.h
"
3
4
5
void
plot_isohyets
(
int
isom,Pixmap pixm,
int
h,
int
display_flag
)
6
7
{
8
9
extern
int
iscale
;
10
extern
Display *
display
;
11
extern
int
npoint
[2],
zoom
;
12
extern
GC
gc
;
13
extern
struct
isoh
*
isoh
;
14
extern
unsigned
long
imap
[16];
15
extern
Widget
drawing_area
;
16
extern
struct
display_set
display_set
[4];
17
int
i
,
j
,
k
,m;
18
int
color
,
MY
=10;
19
float
xrat
,
yrat
,
mult
,
dmult
,
cmult
;
20
long
nx
[4],
ny
[4];
21
Dimension
width
,
height
;
22
Arg
args
[10];
23
unsigned
long
XSIZE
,
YSIZE
;
24
XPoint
point
[5];
25
long
xmin
,
xmax
,
ymin
,
ymax
,
lint1
,
lint2
;
26
signed
long
xcen
,
ycen
;
27
int
iflag,maxi,maxj,mini,minj,nlong,
di
[4][4],
dj
[4][4];
28
int
ceni,cenj;
29
float
ddi;
30
float
fm;
31
float
xk,yk;
32
int
kk;
33
float
deltax,deltay;
34
float
vx,vy;
35
36
di
[0][0]=-1;
37
di
[0][1]= 0;
38
di
[0][2]= 0;
39
di
[0][3]=-1;
40
41
dj
[0][0]=-1;
42
dj
[0][1]=-1;
43
dj
[0][2]= 0;
44
dj
[0][3]= 0;
45
46
di
[1][0]= 0;
47
di
[1][1]= 1;
48
di
[1][2]= 1;
49
di
[1][3]= 0;
50
51
dj
[1][0]=-1;
52
dj
[1][1]=-1;
53
dj
[1][2]= 0;
54
dj
[1][3]= 0;
55
56
di
[2][0]= 0;
57
di
[2][1]= 1;
58
di
[2][2]= 1;
59
di
[2][3]= 0;
60
61
dj
[2][0]= 0;
62
dj
[2][1]= 0;
63
dj
[2][2]= 1;
64
dj
[2][3]= 1;
65
66
di
[3][0]=-1;
67
di
[3][1]= 0;
68
di
[3][2]= 0;
69
di
[3][3]=-1;
70
71
dj
[3][0]= 0;
72
dj
[3][1]= 0;
73
dj
[3][2]= 1;
74
dj
[3][3]= 1;
75
76
dmult
=
display_set
[
display_flag
].
dmult
[h];
77
xmin
=
display_set
[
display_flag
].
xmin
[h];
78
xmax
=
display_set
[
display_flag
].
xmax
[h];
79
ymin
=
display_set
[
display_flag
].
ymin
[h];
80
ymax
=
display_set
[
display_flag
].
ymax
[h];
81
xcen
=
display_set
[
display_flag
].
xcen
[h];
82
ycen
=
display_set
[
display_flag
].
ycen
[h];
83
84
XtSetArg(
args
[0],XtNwidth,&
width
);
85
XtSetArg(
args
[1],XtNheight,&
height
);
86
XtGetValues(
drawing_area
,
args
,2);
87
88
XSIZE
=(long)
width
*10L;
89
YSIZE
=(long)
height
*10L;
90
91
xrat
=(float)
XSIZE
/(
float
)12800;
92
yrat
=(float)
YSIZE
/(
float
)9600;
93
94
if
(
xrat
<
yrat
)
95
mult
=
xrat
;
96
97
else
98
mult
=
yrat
;
99
100
cmult
=
dmult
*
mult
;
101
lint1
=(long)
npoint
[0]*(
long
)
MY
;
102
lint2
=(long)
npoint
[1]*(
long
)
MY
;
103
104
XSetFillRule(
display
,
gc
,WindingRule);
105
106
mini=minj=0;
107
maxi=
isoh
->
maxi
;
108
maxj=
isoh
->
maxj
;
109
ceni=maxi/2;
110
cenj=maxj/2;
111
112
if
(
zoom
> 1) {
113
114
iflag=0;
115
116
for
(
i
=0;
i
<maxi;
i
++) {
117
118
nlong=(
xmin
+((float)
isoh
->
coord
[
i
][cenj].
x
*
cmult
-
lint1
))*
zoom
+
xcen
;
119
120
121
if
(iflag==0 && nlong <
xmin
)
122
continue
;
123
124
if
(iflag==1 && nlong <
xmax
)
125
continue
;
126
127
if
(iflag==0)
128
mini=
i
;
129
130
if
(iflag==1)
131
maxi=
i
;
132
133
iflag++;
134
135
136
}
137
138
iflag=0;
139
140
for
(
j
=0;
j
<maxj;
j
++) {
141
142
nlong=(
ymin
+((float)
isoh
->
coord
[ceni][
j
].
y
*
cmult
-
lint2
))*
zoom
+
ycen
;
143
144
145
if
(iflag==0 && nlong < 0)
146
continue
;
147
148
if
(iflag==1 && nlong <
YSIZE
)
149
continue
;
150
151
if
(iflag==0)
152
minj=
j
;
153
154
155
if
(iflag==1)
156
maxj=
j
;
157
158
iflag++;
159
160
}
161
162
}
163
164
165
if
(
iscale
==0)
166
fm=.5;
167
else
168
fm=pow(2,(
double
)(
iscale
-1));
169
170
for
(
i
=mini;
i
<maxi;
i
++) {
171
172
for
(
j
=minj;
j
<maxj;
j
++) {
173
174
175
if
(
isoh
->
value
[isom][
i
][
j
] < 0)
176
continue
;
177
178
ddi=(float)(
isoh
->
value
[isom][
i
][
j
])/(25.3);
179
180
if
(ddi <= 0)
181
continue
;
182
183
for
(h=1;h <= 16;h++) {
184
185
if
(ddi < fm*h ) {
186
187
color
=h;
188
break
;
189
190
}
191
192
}
193
194
if
(
color
> 16)
195
color
=16;
196
197
color
=
imap
[
color
-1];
198
199
if
(
color
==0)
200
continue
;
201
202
XSetForeground(
display
,
gc
,
color
);
203
204
if
(
j
==0) {
205
206
if
(
i
==0 ||
i
==maxi-1)
207
continue
;
208
209
for
(
k
=2;
k
<4;
k
++) {
210
211
xk=0;
212
yk=0;
213
214
for
(kk=0;kk<4;kk++) {
215
216
if
(
zoom
<= 1) {
217
218
xk=xk+
xmin
+(float)
isoh
->
coord
[
i
+
di
[
k
][kk]][
j
+
dj
[
k
][kk]].
x
*
cmult
;
219
yk=yk+
ymin
+(
float
)
isoh
->
coord
[
i
+
di
[
k
][kk]][
j
+
dj
[
k
][kk]].
y
*
cmult
;
220
vy=
ymin
+(float)
isoh
->
coord
[
i
][
j
].
y
*
cmult
;
221
}
222
223
else
{
224
225
xk=xk+(
xmin
+((float)
isoh
->
coord
[
i
+
di
[
k
][kk]][
j
+
dj
[
k
][kk]].
x
*
cmult
-
226
lint1
))*
zoom
+
xcen
;
227
yk=yk+(
ymin
+((float)
isoh
->
coord
[
i
+
di
[
k
][kk]][
j
+
dj
[
k
][kk]].
y
*
cmult
-
228
lint2
))*
zoom
+
ycen
;
229
vy=(
ymin
+((float)
isoh
->
coord
[
i
][
j
].
y
*
cmult
-
lint2
))*
zoom
+
ycen
;
230
}
231
232
}
233
234
nx
[
k
]=xk/4;
235
ny
[
k
]=yk/4;
236
237
}
238
239
deltay=
ny
[3] - vy;
240
241
nx
[1]=
nx
[2];
242
nx
[0]=
nx
[3];
243
ny
[1]=vy - deltay;
244
ny
[0]=vy - deltay;
245
246
247
}
248
249
else
if
(
i
==0) {
250
251
if
(
j
==0 ||
j
==maxj-1)
252
continue
;
253
254
255
for
(
k
=1;
k
<3;
k
++) {
256
257
xk=0;
258
yk=0;
259
260
for
(kk=0;kk<4;kk++) {
261
262
if
(
zoom
<= 1) {
263
264
xk=xk+
xmin
+(float)
isoh
->
coord
[
i
+
di
[
k
][kk]][
j
+
dj
[
k
][kk]].
x
*
cmult
;
265
yk=yk+
ymin
+(
float
)
isoh
->
coord
[
i
+
di
[
k
][kk]][
j
+
dj
[
k
][kk]].
y
*
cmult
;
266
vx=
xmin
+(float)
isoh
->
coord
[
i
][
j
].
x
*
cmult
;
267
}
268
269
else
{
270
271
xk=xk+(
xmin
+((float)
isoh
->
coord
[
i
+
di
[
k
][kk]][
j
+
dj
[
k
][kk]].
x
*
cmult
-
272
lint1
))*
zoom
+
xcen
;
273
yk=yk+(
ymin
+((float)
isoh
->
coord
[
i
+
di
[
k
][kk]][
j
+
dj
[
k
][kk]].
y
*
cmult
-
274
lint2
))*
zoom
+
ycen
;
275
vx=(
xmin
+((float)
isoh
->
coord
[
i
][
j
].
x
*
cmult
-
lint1
))*
zoom
+
xcen
;
276
277
}
278
279
}
280
281
nx
[
k
]=xk/4;
282
ny
[
k
]=yk/4;
283
284
285
}
286
287
deltax=
nx
[1] - vx;
288
289
ny
[0]=
ny
[1];
290
ny
[3]=
ny
[2];
291
nx
[0]=vx - deltax;
292
nx
[3]=vx - deltax;
293
294
295
}
296
297
else
if
(
j
==maxj-1) {
298
299
if
(
i
==0 ||
i
==maxi-1)
300
continue
;
301
302
for
(
k
=0;
k
<2;
k
++) {
303
304
xk=0;
305
yk=0;
306
307
for
(kk=0;kk<4;kk++) {
308
309
if
(
zoom
<= 1) {
310
311
xk=xk+
xmin
+(float)
isoh
->
coord
[
i
+
di
[
k
][kk]][
j
+
dj
[
k
][kk]].
x
*
cmult
;
312
yk=yk+
ymin
+(
float
)
isoh
->
coord
[
i
+
di
[
k
][kk]][
j
+
dj
[
k
][kk]].
y
*
cmult
;
313
vy=
ymin
+(float)
isoh
->
coord
[
i
][
j
].
y
*
cmult
;
314
}
315
316
else
{
317
318
xk=xk+(
xmin
+((float)
isoh
->
coord
[
i
+
di
[
k
][kk]][
j
+
dj
[
k
][kk]].
x
*
cmult
-
319
lint1
))*
zoom
+
xcen
;
320
yk=yk+(
ymin
+((float)
isoh
->
coord
[
i
+
di
[
k
][kk]][
j
+
dj
[
k
][kk]].
y
*
cmult
-
321
lint2
))*
zoom
+
ycen
;
322
vy=(
ymin
+((float)
isoh
->
coord
[
i
][
j
].
y
*
cmult
-
323
lint2
))*
zoom
+
ycen
;
324
325
}
326
327
}
328
329
nx
[
k
]=xk/4;
330
ny
[
k
]=yk/4;
331
332
}
333
334
deltay=vy -
ny
[0];
335
336
nx
[2]=
nx
[0];
337
nx
[3]=
nx
[1];
338
ny
[2]=vy + deltay;
339
ny
[3]=vy + deltay;
340
341
}
342
343
else
if
(
i
==maxi-1) {
344
345
if
(
j
==0 ||
j
==maxj-1)
346
continue
;
347
348
for
(
k
=0;
k
<4;
k
++) {
349
350
if
(
k
==1 ||
k
==2)
351
continue
;
352
353
xk=0;
354
yk=0;
355
356
for
(kk=0;kk<4;kk++) {
357
358
if
(
zoom
<= 1) {
359
360
xk=xk+
xmin
+(float)
isoh
->
coord
[
i
+
di
[
k
][kk]][
j
+
dj
[
k
][kk]].
x
*
cmult
;
361
yk=yk+
ymin
+(
float
)
isoh
->
coord
[
i
+
di
[
k
][kk]][
j
+
dj
[
k
][kk]].
y
*
cmult
;
362
vx=
xmin
+(float)
isoh
->
coord
[
i
][
j
].
x
*
cmult
;
363
364
}
365
366
else
{
367
368
xk=xk+(
xmin
+((float)
isoh
->
coord
[
i
+
di
[
k
][kk]][
j
+
dj
[
k
][kk]].
x
*
cmult
-
369
lint1
))*
zoom
+
xcen
;
370
yk=yk+(
ymin
+((float)
isoh
->
coord
[
i
+
di
[
k
][kk]][
j
+
dj
[
k
][kk]].
y
*
cmult
-
371
lint2
))*
zoom
+
ycen
;
372
vx=(
xmin
+((float)
isoh
->
coord
[
i
][
j
].
x
*
cmult
-
lint1
))*
zoom
+
xcen
;
373
}
374
375
}
376
377
nx
[
k
]=xk/4;
378
ny
[
k
]=yk/4;
379
380
}
381
382
deltax= vx -
nx
[0];
383
384
ny
[1]=
ny
[0];
385
ny
[2]=
ny
[3];
386
387
nx
[1]=vx + deltax;
388
nx
[2]=vx + deltax;
389
390
391
}
392
393
394
else
{
395
396
for
(
k
=0;
k
<4;
k
++) {
397
398
xk=0;
399
yk=0;
400
401
for
(kk=0;kk<4;kk++) {
402
403
if
(
zoom
<= 1) {
404
405
xk=xk+
xmin
+(float)
isoh
->
coord
[
i
+
di
[
k
][kk]][
j
+
dj
[
k
][kk]].
x
*
cmult
;
406
yk=yk+
ymin
+(
float
)
isoh
->
coord
[
i
+
di
[
k
][kk]][
j
+
dj
[
k
][kk]].
y
*
cmult
;
407
408
}
409
410
411
412
else
{
413
414
xk=xk+(
xmin
+((float)
isoh
->
coord
[
i
+
di
[
k
][kk]][
j
+
dj
[
k
][kk]].
x
*
cmult
-
415
lint1
))*
zoom
+
xcen
;
416
yk=yk+(
ymin
+((float)
isoh
->
coord
[
i
+
di
[
k
][kk]][
j
+
dj
[
k
][kk]].
y
*
cmult
-
417
lint2
))*
zoom
+
ycen
;
418
419
}
420
421
}
422
423
nx
[
k
]=xk/4;
424
ny
[
k
]=yk/4;
425
426
}
427
428
}
429
430
for
(
k
=0;
k
<4;
k
++) {
431
432
point
[
k
].
x
=(
nx
[
k
]+5)/
MY
;
433
point
[
k
].
y
=(
ny
[
k
]+5)/
MY
;
434
435
}
436
437
point
[4].
x
=
point
[0].
x
;
438
point
[4].
y
=
point
[0].
y
;
439
440
XFillPolygon(
display
,pixm,
gc
,
point
,5,Convex,CoordModeOrigin);
441
442
}
443
444
}
445
446
return
;
447
448
}
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
i
static int i
Definition:
get_apps_defaults.c:110
display
Display * display
Definition:
mapper.c:159
mult
float mult
Definition:
edit_stations.c:6
j
int j
Definition:
mapp2h.h:48
k
int k
Definition:
mapp2h.h:48
iscale
int iscale
Definition:
mapper.c:101
isoh
struct isoh * isoh
Definition:
mapper.c:144
imap
unsigned long imap[16]
Definition:
mapper.c:116
display_flag
int display_flag
Definition:
mapper.c:100
plot_isohyets
void plot_isohyets(int isom, Pixmap pixm, int h, int display_flag)
Definition:
plot_isohytes_old.c:5
xrat
float xrat
Definition:
plot_qpf_legend.c:20
xmax
long xmax
Definition:
plot_qpf_legend.c:26
dj
int dj[4]
Definition:
plot_qpf_legend.c:28
color
int color
Definition:
plot_qpf_legend.c:19
yrat
float yrat
Definition:
plot_qpf_legend.c:20
ny
long ny[4]
Definition:
plot_qpf_legend.c:21
ymax
long ymax
Definition:
plot_qpf_legend.c:26
lint1
long lint1
Definition:
plot_qpf_legend.c:26
gc
GC gc
Definition:
mapper.c:163
cmult
float cmult
Definition:
plot_qpf_legend.c:20
xcen
signed long xcen
Definition:
plot_qpf_legend.c:27
height
Dimension height
Definition:
plot_qpf_legend.c:22
ycen
signed long ycen
Definition:
plot_qpf_legend.c:27
width
Dimension width
Definition:
plot_qpf_legend.c:22
lint2
long lint2
Definition:
plot_qpf_legend.c:26
args
Arg args[10]
Definition:
plot_qpf_legend.c:23
xmin
long xmin
Definition:
plot_qpf_legend.c:26
XSIZE
unsigned long XSIZE
Definition:
plot_qpf_legend.c:24
MY
int MY
Definition:
plot_qpf_legend.c:19
zoom
int zoom
Definition:
plot_qpf_legend.c:9
nx
long nx[4]
Definition:
plot_qpf_legend.c:21
dmult
float dmult
Definition:
plot_qpf_legend.c:20
drawing_area
Widget drawing_area
Definition:
mapper.c:185
npoint
int npoint[2]
Definition:
mapper.c:105
ymin
long ymin
Definition:
plot_qpf_legend.c:26
YSIZE
unsigned long YSIZE
Definition:
plot_qpf_legend.c:24
di
int di[4]
Definition:
plot_qpf_legend.c:28
prototypes_new.h
coord::y
short int y
Definition:
misc.h:498
coord::x
short int x
Definition:
misc.h:497
display_set
Definition:
misc.h:603
display_set::dmult
float dmult[4]
Definition:
misc.h:613
display_set::xmin
long xmin[4]
Definition:
misc.h:607
display_set::xmax
long xmax[4]
Definition:
misc.h:609
display_set::ymax
long ymax[4]
Definition:
misc.h:610
display_set::ymin
long ymin[4]
Definition:
misc.h:608
display_set::ycen
long ycen[4]
Definition:
misc.h:612
display_set::xcen
long xcen[4]
Definition:
misc.h:611
isoh
Definition:
misc.h:538
isoh::coord
struct coord ** coord
Definition:
misc.h:540
isoh::maxi
int maxi
Definition:
misc.h:542
isoh::value
short int *** value
Definition:
misc.h:541
isoh::maxj
int maxj
Definition:
misc.h:543
point
Definition:
mapp2h.h:29
point::y
int y
Definition:
mapp2h.h:30
point::x
int x
Definition:
mapp2h.h:30
Generated by
1.9.1