| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# --8<--8<--8<--8<-- |
|
2
|
|
|
|
|
|
|
# |
|
3
|
|
|
|
|
|
|
# Copyright (C) 2007 Smithsonian Astrophysical Observatory |
|
4
|
|
|
|
|
|
|
# |
|
5
|
|
|
|
|
|
|
# This file is part of Astro::NED::Query |
|
6
|
|
|
|
|
|
|
# |
|
7
|
|
|
|
|
|
|
# Astro::NED::Query is free software: you can redistribute it and/or modify |
|
8
|
|
|
|
|
|
|
# it under the terms of the GNU General Public License as published by |
|
9
|
|
|
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or (at |
|
10
|
|
|
|
|
|
|
# your option) any later version. |
|
11
|
|
|
|
|
|
|
# |
|
12
|
|
|
|
|
|
|
# This program is distributed in the hope that it will be useful, |
|
13
|
|
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14
|
|
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15
|
|
|
|
|
|
|
# GNU General Public License for more details. |
|
16
|
|
|
|
|
|
|
# |
|
17
|
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License |
|
18
|
|
|
|
|
|
|
# along with this program. If not, see . |
|
19
|
|
|
|
|
|
|
# |
|
20
|
|
|
|
|
|
|
# -->8-->8-->8-->8-- |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
package Astro::NED::Response::Fields; |
|
23
|
|
|
|
|
|
|
|
|
24
|
6
|
|
|
6
|
|
5167
|
use Regexp::Common qw( RE_num_ALL ); |
|
|
6
|
|
|
|
|
18218
|
|
|
|
6
|
|
|
|
|
72
|
|
|
25
|
|
|
|
|
|
|
|
|
26
|
6
|
|
|
6
|
|
377918
|
use 5.006; |
|
|
6
|
|
|
|
|
28
|
|
|
|
6
|
|
|
|
|
223
|
|
|
27
|
6
|
|
|
6
|
|
32
|
use strict; |
|
|
6
|
|
|
|
|
12
|
|
|
|
6
|
|
|
|
|
183
|
|
|
28
|
6
|
|
|
6
|
|
33
|
use warnings; |
|
|
6
|
|
|
|
|
11
|
|
|
|
6
|
|
|
|
|
5645
|
|
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
our $VERSION = '0.30'; |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# mapping between HTML table column names and Object field names |
|
33
|
|
|
|
|
|
|
my @Fields = |
|
34
|
|
|
|
|
|
|
( |
|
35
|
|
|
|
|
|
|
{ name => 'No', |
|
36
|
|
|
|
|
|
|
re => qr/row\s+no[.]/i, |
|
37
|
|
|
|
|
|
|
chk => qr/^\d+$/, |
|
38
|
|
|
|
|
|
|
}, |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
{ name => 'Name', |
|
41
|
|
|
|
|
|
|
re => qr/object name/i, |
|
42
|
|
|
|
|
|
|
chk => undef, |
|
43
|
|
|
|
|
|
|
}, |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
{ name => 'Lat', |
|
46
|
|
|
|
|
|
|
re => qr/lat$/i, |
|
47
|
|
|
|
|
|
|
chk => undef, |
|
48
|
|
|
|
|
|
|
}, |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
{ name => 'Lon', |
|
51
|
|
|
|
|
|
|
re => qr/lon$/i, |
|
52
|
|
|
|
|
|
|
chk => undef, |
|
53
|
|
|
|
|
|
|
}, |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
{ name => 'Type', |
|
56
|
|
|
|
|
|
|
re => qr/object type/i, |
|
57
|
|
|
|
|
|
|
chk => undef, |
|
58
|
|
|
|
|
|
|
}, |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
{ name => 'RA', |
|
61
|
|
|
|
|
|
|
re => qr/RA$/, |
|
62
|
|
|
|
|
|
|
chk => qr/[-+]? \d{2}h \d{2}m \d{2}[.]\d s/ix, |
|
63
|
|
|
|
|
|
|
}, |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
{ name => 'Dec', |
|
66
|
|
|
|
|
|
|
re => qr/DEC$/, |
|
67
|
|
|
|
|
|
|
chk => qr/[-+]? \d{2}d \d{2}m \d{2} s/ix, |
|
68
|
|
|
|
|
|
|
}, |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
{ name => 'Velocity', |
|
71
|
|
|
|
|
|
|
re => qr{km/s}i, |
|
72
|
|
|
|
|
|
|
chk => RE_num_real(), |
|
73
|
|
|
|
|
|
|
}, |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
{ name => 'Z', |
|
76
|
|
|
|
|
|
|
re => qr/redshift z$/i, |
|
77
|
|
|
|
|
|
|
chk => RE_num_real(), |
|
78
|
|
|
|
|
|
|
}, |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
{ name => 'VZQual', |
|
81
|
|
|
|
|
|
|
re => qr/qual$/i, |
|
82
|
|
|
|
|
|
|
chk => undef, |
|
83
|
|
|
|
|
|
|
}, |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
{ name => 'mag', |
|
86
|
|
|
|
|
|
|
re => qr/Filter$/, |
|
87
|
|
|
|
|
|
|
chk => undef |
|
88
|
|
|
|
|
|
|
}, |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
{ name => 'Distance', |
|
91
|
|
|
|
|
|
|
re => qr/distance/i, |
|
92
|
|
|
|
|
|
|
chk => RE_num_real(), |
|
93
|
|
|
|
|
|
|
}, |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
{ name => 'NRefs', |
|
96
|
|
|
|
|
|
|
re => qr/number of refs/i, |
|
97
|
|
|
|
|
|
|
chk => RE_num_int(), |
|
98
|
|
|
|
|
|
|
}, |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
{ name => 'NNotes', |
|
101
|
|
|
|
|
|
|
re => qr/number of notes/i, |
|
102
|
|
|
|
|
|
|
chk => RE_num_int(), |
|
103
|
|
|
|
|
|
|
}, |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
{ name => 'NPhot', |
|
106
|
|
|
|
|
|
|
re => qr/number of phot/i, |
|
107
|
|
|
|
|
|
|
chk => RE_num_int(), |
|
108
|
|
|
|
|
|
|
}, |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
{ name => 'NPosn', |
|
111
|
|
|
|
|
|
|
re => qr/number of posn/i, |
|
112
|
|
|
|
|
|
|
chk => RE_num_int(), |
|
113
|
|
|
|
|
|
|
}, |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
{ name => 'NVel', |
|
116
|
|
|
|
|
|
|
re => qr{number of vel/z}i, |
|
117
|
|
|
|
|
|
|
chk => RE_num_int(), |
|
118
|
|
|
|
|
|
|
}, |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
{ name => 'NDiam', |
|
121
|
|
|
|
|
|
|
re => qr/number of diam/i, |
|
122
|
|
|
|
|
|
|
chk => RE_num_int(), |
|
123
|
|
|
|
|
|
|
}, |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
{ name => 'NAssoc', |
|
126
|
|
|
|
|
|
|
re => qr/number of assoc/i, |
|
127
|
|
|
|
|
|
|
chk => RE_num_int(), |
|
128
|
|
|
|
|
|
|
}, |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
{ name => 'Images', |
|
131
|
|
|
|
|
|
|
re => qr/images/i, |
|
132
|
|
|
|
|
|
|
chk => undef, |
|
133
|
|
|
|
|
|
|
}, |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
{ name => 'Spectra', |
|
136
|
|
|
|
|
|
|
re => qr/spectra/i, |
|
137
|
|
|
|
|
|
|
chk => undef, |
|
138
|
|
|
|
|
|
|
}, |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
); |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
## no critic (AccessOfPrivateData) |
|
145
|
|
|
|
|
|
|
# @Fields is a list of arrayrefs, not objects. |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
my @FieldNames = map { $_->{name} } @Fields; |
|
148
|
|
|
|
|
|
|
my %Fields = map { ( $_->{name} => $_ ) } @Fields; |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
## use critic |
|
151
|
|
|
|
|
|
|
|
|
152
|
0
|
|
|
0
|
1
|
0
|
sub fields { return @Fields }; |
|
153
|
7
|
|
|
7
|
1
|
96
|
sub names { return @FieldNames }; |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
sub match |
|
156
|
|
|
|
|
|
|
{ |
|
157
|
79
|
|
|
79
|
1
|
97
|
my ( $colname ) = @_; |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
## no critic (AccessOfPrivateData) |
|
160
|
|
|
|
|
|
|
# @Fields is a list of refs, not objects. |
|
161
|
79
|
|
|
|
|
107
|
return grep { $colname =~ $_->{re} } @Fields; |
|
|
1659
|
|
|
|
|
5038
|
|
|
162
|
|
|
|
|
|
|
## use critic |
|
163
|
|
|
|
|
|
|
} |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
sub check |
|
166
|
|
|
|
|
|
|
{ |
|
167
|
11
|
|
|
11
|
1
|
18
|
my ( $data ) = @_; |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
# reset internal iterator state |
|
170
|
11
|
|
|
|
|
18
|
keys %$data; |
|
171
|
|
|
|
|
|
|
|
|
172
|
11
|
|
|
|
|
43
|
while( my ( $name, $value ) = each %$data ) |
|
173
|
|
|
|
|
|
|
{ |
|
174
|
207
|
100
|
|
|
|
421
|
next unless defined $value; |
|
175
|
187
|
|
|
|
|
280
|
my $chk = $Fields{$name}{chk}; |
|
176
|
187
|
|
|
|
|
196
|
eval { |
|
177
|
187
|
50
|
33
|
|
|
418
|
'CODE' eq ref $chk && ! $chk->($value) and die; |
|
178
|
187
|
100
|
100
|
|
|
1087
|
'Regexp' eq ref $chk && $value !~ $chk and die; |
|
179
|
|
|
|
|
|
|
}; |
|
180
|
187
|
100
|
|
|
|
689
|
$@ and die( "illegal value ($value) for column $name\n" ); |
|
181
|
|
|
|
|
|
|
} |
|
182
|
|
|
|
|
|
|
|
|
183
|
10
|
|
|
|
|
36
|
return; |
|
184
|
|
|
|
|
|
|
} |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
1; |
|
188
|
|
|
|
|
|
|
__END__ |