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