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
|
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
include <syserr.h>
include "mwcs.h"
# MW_GWATTRS -- Get the string value of the named WCS attribute for axis N.
# If the attribute name is a number N, attribute number N is returned instead,
# allowing the attributes to be listed without knowing their names.
procedure mw_gwattrs (mw, axis, attribute, valstr, maxch)
pointer mw #I pointer to MWCS descriptor
int axis #I axis to which attribute belongs
char attribute[SZ_ATNAME] #U attribute name
char valstr[ARB] #O attribute value
int maxch #I max chars to output value string
pointer wp, ap
int item, atno, i
int ctoi()
bool streq()
errchk syserrs
begin
# Get current WCS.
wp = MI_WCS(mw)
if (wp == NULL)
call syserrs (SYS_MWNOWCS, "mw_gwattrs")
# Get attribute number if number was given.
i = 1
if (ctoi (attribute, i, atno) == 0)
atno = 0
# Lookup the named or numbered attribute and output the value
# string if found.
item = 0
do i = 1, WCS_NWATTR(wp) {
ap = WCS_WATTR(wp,i)
if (AT_AXIS(ap) == axis) {
item = item + 1
if (atno > 0) {
if (atno == item) {
call strcpy (S(mw,AT_NAME(ap)), attribute, SZ_ATNAME)
call strcpy (S(mw,AT_VALUE(ap)), valstr, maxch)
return
}
} else if (streq (S(mw,AT_NAME(ap)), attribute)) {
call strcpy (S(mw,AT_VALUE(ap)), valstr, maxch)
return
}
}
}
call syserrs (SYS_MWWATTRNF, attribute)
end
|