voruby 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +339 -0
- data/REQUIREMENTS +4 -0
- data/Rakefile.rb +296 -0
- data/lib/voruby/adql/adql.rb +2735 -0
- data/lib/voruby/adql/ext.rb +15 -0
- data/lib/voruby/adql/loader.rb +5 -0
- data/lib/voruby/adql/operations.rb +54 -0
- data/lib/voruby/adql/parser.rb +160 -0
- data/lib/voruby/adql/transforms.rb +573 -0
- data/lib/voruby/ext.rb +17 -0
- data/lib/voruby/loader.rb +4 -0
- data/lib/voruby/misc/propertyfile.rb +36 -0
- data/lib/voruby/plastic/applications.rb +174 -0
- data/lib/voruby/plastic/constants.rb +30 -0
- data/lib/voruby/plastic/loader.rb +10 -0
- data/lib/voruby/plastic/plastic.rb +1 -0
- data/lib/voruby/resources/conesearch/conesearch.rb +9 -0
- data/lib/voruby/resources/conesearch/conesearch_v0_2.rb +55 -0
- data/lib/voruby/resources/conesearch/conesearch_v0_3.rb +50 -0
- data/lib/voruby/resources/conesearch/conesearch_v1_0.rb +72 -0
- data/lib/voruby/resources/conesearch/loader.rb +4 -0
- data/lib/voruby/resources/loader.rb +50 -0
- data/lib/voruby/resources/nodes.rb +190 -0
- data/lib/voruby/resources/openskynode/loader.rb +4 -0
- data/lib/voruby/resources/openskynode/openskynode.rb +9 -0
- data/lib/voruby/resources/openskynode/openskynode_v0_1.rb +54 -0
- data/lib/voruby/resources/sia/loader.rb +5 -0
- data/lib/voruby/resources/sia/sia.rb +9 -0
- data/lib/voruby/resources/sia/sia_v0_6.rb +90 -0
- data/lib/voruby/resources/sia/sia_v0_7.rb +89 -0
- data/lib/voruby/resources/sia/sia_v1_0.rb +122 -0
- data/lib/voruby/resources/stsci.rb +59 -0
- data/lib/voruby/resources/vodataservice/coverage_v0_2.rb +195 -0
- data/lib/voruby/resources/vodataservice/coverage_v0_3.rb +158 -0
- data/lib/voruby/resources/vodataservice/loader.rb +5 -0
- data/lib/voruby/resources/vodataservice/vodataservice.rb +9 -0
- data/lib/voruby/resources/vodataservice/vodataservice_v0_4.rb +189 -0
- data/lib/voruby/resources/vodataservice/vodataservice_v0_5.rb +163 -0
- data/lib/voruby/resources/vodataservice/vodataservice_v1_0.rb +221 -0
- data/lib/voruby/resources/voregistry/loader.rb +4 -0
- data/lib/voruby/resources/voregistry/voregistry.rb +9 -0
- data/lib/voruby/resources/voregistry/voregistry_v0_2.rb +40 -0
- data/lib/voruby/resources/voregistry/voregistry_v0_3.rb +30 -0
- data/lib/voruby/resources/voregistry/voregistry_v1_0.rb +86 -0
- data/lib/voruby/resources/voresource/loader.rb +17 -0
- data/lib/voruby/resources/voresource/voresource.rb +9 -0
- data/lib/voruby/resources/voresource/voresource_v0_10.rb +322 -0
- data/lib/voruby/resources/voresource/voresource_v0_9.rb +405 -0
- data/lib/voruby/resources/voresource/voresource_v1_0.rb +230 -0
- data/lib/voruby/services/ext.rb +11 -0
- data/lib/voruby/services/gestalt/footprint.rb +95 -0
- data/lib/voruby/services/gestalt/wcs_fixer.rb +105 -0
- data/lib/voruby/services/gestalt/wesix.rb +155 -0
- data/lib/voruby/services/loader.rb +7 -0
- data/lib/voruby/services/registry/registry.rb +53 -0
- data/lib/voruby/services/resolver/resolver.rb +35 -0
- data/lib/voruby/sesame/loader.rb +6 -0
- data/lib/voruby/sesame/sesame_v1_0.rb +64 -0
- data/lib/voruby/simple/loader.rb +6 -0
- data/lib/voruby/simple/parameters.rb +196 -0
- data/lib/voruby/simple/sap.rb +446 -0
- data/lib/voruby/spacetime/loader.rb +3 -0
- data/lib/voruby/spacetime/spacetime.rb +607 -0
- data/lib/voruby/stc/coords_v1_20.rb +900 -0
- data/lib/voruby/stc/loader.rb +55 -0
- data/lib/voruby/stc/region_v1_20.rb +274 -0
- data/lib/voruby/stc/stc_v1_20.rb +1196 -0
- data/lib/voruby/util.rb +27 -0
- data/lib/voruby/voevent/loader.rb +7 -0
- data/lib/voruby/voevent/voevent_v1_0.rb +213 -0
- data/lib/voruby/voevent/voevent_v1_1.rb +196 -0
- data/lib/voruby/votables/chandra.rb +410 -0
- data/lib/voruby/votables/cnoc.rb +393 -0
- data/lib/voruby/votables/data.rb +179 -0
- data/lib/voruby/votables/galex.rb +390 -0
- data/lib/voruby/votables/hst.rb +391 -0
- data/lib/voruby/votables/int.rb +391 -0
- data/lib/voruby/votables/libxml_parser.rb +411 -0
- data/lib/voruby/votables/libxml_votable.rb +67 -0
- data/lib/voruby/votables/loader.rb +10 -0
- data/lib/voruby/votables/meta.rb +763 -0
- data/lib/voruby/votables/misc.rb +51 -0
- data/lib/voruby/votables/nsa.rb +393 -0
- data/lib/voruby/votables/nsar3.rb +410 -0
- data/lib/voruby/votables/rexml_parser.rb +408 -0
- data/lib/voruby/votables/rexml_votable.rb +67 -0
- data/lib/voruby/votables/sdss.rb +393 -0
- data/lib/voruby/votables/transforms.rb +388 -0
- data/lib/voruby/votables/tree.rb +45 -0
- data/lib/voruby/votables/types.rb +391 -0
- data/lib/voruby/votables/votable.rb +630 -0
- data/lib/voruby/votables/xmm.rb +394 -0
- data/test/adql/test1.adql +49 -0
- data/test/adql/test2.adql +51 -0
- data/test/adql/test3.adql +81 -0
- data/test/adql/test4.adql +53 -0
- data/test/adql/test5.adql +55 -0
- data/test/adql/test6.adql +18 -0
- data/test/adql/test7.adql +48 -0
- data/test/adql/unittest.rb +1672 -0
- data/test/plastic/test.rb +44 -0
- data/test/plastic/test.vot +5385 -0
- data/test/plastic/unittest.rb +66 -0
- data/test/resources/conesearch/conesearch_v0_3.xml +31 -0
- data/test/resources/conesearch/conesearch_v1_0.xml +86 -0
- data/test/resources/conesearch/unittest_v0_3.rb +22 -0
- data/test/resources/conesearch/unittest_v1_0.rb +24 -0
- data/test/resources/openskynode/open_sky_node_v0_1.xml +32 -0
- data/test/resources/openskynode/unittest_v0_1.rb +31 -0
- data/test/resources/sia/simple_image_access_v0_7.xml +36 -0
- data/test/resources/sia/simple_image_access_v1_0.xml +122 -0
- data/test/resources/sia/unittest_v0_7.rb +24 -0
- data/test/resources/sia/unittest_v1_0.rb +29 -0
- data/test/resources/stsci.xml +336 -0
- data/test/resources/unittest_stsci.rb +25 -0
- data/test/resources/vodataservice/catalog_service_resource_v1_0.xml +128 -0
- data/test/resources/vodataservice/data_collection_resource_v0_5.xml +54 -0
- data/test/resources/vodataservice/data_collection_resource_v1_0.xml +117 -0
- data/test/resources/vodataservice/data_service_resource_v1_0.xml +115 -0
- data/test/resources/vodataservice/sky_service_resource_v0_10.xml +45 -0
- data/test/resources/vodataservice/table_service_resource_v1_0.xml +122 -0
- data/test/resources/vodataservice/tabular_sky_service_resource_v0_10.xml +60 -0
- data/test/resources/vodataservice/unittest_v0_5.rb +126 -0
- data/test/resources/vodataservice/unittest_v1_0.rb +151 -0
- data/test/resources/voregistry/authority_resource_v0_3.xml +20 -0
- data/test/resources/voregistry/authority_resource_v1_0.xml +82 -0
- data/test/resources/voregistry/registry_service_v0_3.xml +20 -0
- data/test/resources/voregistry/registry_service_v1_0.xml +107 -0
- data/test/resources/voregistry/unittest_v0_3.rb +31 -0
- data/test/resources/voregistry/unittest_v1_0.rb +34 -0
- data/test/resources/voresource/organisation_resource_v1_0.xml +90 -0
- data/test/resources/voresource/resource_organisation_v0_10.xml +22 -0
- data/test/resources/voresource/resource_service_v0_10.xml +19 -0
- data/test/resources/voresource/resource_v0_10.xml +19 -0
- data/test/resources/voresource/resource_v1_0.xml +79 -0
- data/test/resources/voresource/service_resource_v1_0.xml +91 -0
- data/test/resources/voresource/unittest_v0_10.rb +61 -0
- data/test/resources/voresource/unittest_v0_9.rb +4 -0
- data/test/resources/voresource/unittest_v1_0.rb +190 -0
- data/test/services/gestalt/unittest.rb +74 -0
- data/test/services/registry/unittest.rb +34 -0
- data/test/services/resolver/unittest.rb +38 -0
- data/test/simple/unittest.rb +46 -0
- data/test/spacetime/unittest.rb +39 -0
- data/test/stc/catalog_entry_location_v1_20.xml +112 -0
- data/test/stc/obs_data_location_v1_20.xml +108 -0
- data/test/stc/search_location_v1_20.xml +54 -0
- data/test/stc/stc_resource_profile_v1_20.xml +60 -0
- data/test/stc/unittest_v1_20.rb +620 -0
- data/test/voevent/unittest_v1_0.rb +79 -0
- data/test/voevent/unittest_v1_1.rb +70 -0
- data/test/voevent/voevent_v1_0.xml +96 -0
- data/test/voevent/voevent_v1_1.xml +76 -0
- data/test/votables/test.vot +366 -0
- data/test/votables/unittest.rb +54 -0
- metadata +256 -0
@@ -0,0 +1,630 @@
|
|
1
|
+
require 'voruby/votables/loader'
|
2
|
+
|
3
|
+
# A set of classes designed to read and manipulate VOTables[http://www.ivoa.net/Documents/latest/VOT.html].
|
4
|
+
# In practice you are most likely interested in the TreeParsedVOTable.
|
5
|
+
module VORuby
|
6
|
+
module VOTables
|
7
|
+
|
8
|
+
module VOTable
|
9
|
+
# An implementation of a standard VOTable based on the VOTable XML-Schema
|
10
|
+
# available at the US-VO[http://www.us-vo.org/VOTable/]. Typically one
|
11
|
+
# wouldn't construct this object directly, but rather use something like
|
12
|
+
# VOTable::TreeParsedVOTable to do so from an XML file.
|
13
|
+
class VOTable
|
14
|
+
attr_accessor :description, :definitions, :coosys, :params, :info, :resources,
|
15
|
+
:id, :version
|
16
|
+
|
17
|
+
# [_id_:]
|
18
|
+
# The VOTable's ID attribute.
|
19
|
+
# [_version_:]
|
20
|
+
# The VOTable version.
|
21
|
+
# [_description_:]
|
22
|
+
# The VOTable DESCRIPTION element (type: VOTABLE::META::Description).
|
23
|
+
# [_definitions_:]
|
24
|
+
# The VOTable DEFINITIONS element (type: VOTABLE::META::Definitions).
|
25
|
+
# [_coosys_:]
|
26
|
+
# The coordinate system (COOSYS) definitions for the the VOTable
|
27
|
+
# (type: VOTABLE::META::CooSys).
|
28
|
+
# [_params_:]
|
29
|
+
# The PARAM elements for the VOTable (type: VOTABLE::META::Param).
|
30
|
+
# [_info_:]
|
31
|
+
# The INFO elements for the VOTable (type: VOTABLE::META::Info).
|
32
|
+
# [_resources_:]
|
33
|
+
# The RESOURCE elements for the VOTable (type: VOTABLE::META::Resource).
|
34
|
+
def initialize(id=nil, version='1.1', description=nil,
|
35
|
+
definitions=nil, coosys=[],
|
36
|
+
params=[], info=[], resources=[])
|
37
|
+
|
38
|
+
@id = id
|
39
|
+
@version = version
|
40
|
+
|
41
|
+
Misc::TypeCheck.new(description, Meta::Description).check()
|
42
|
+
@description = description
|
43
|
+
|
44
|
+
Misc::TypeCheck.new(definitions, Meta::Definitions).check()
|
45
|
+
@definitions = definitions
|
46
|
+
|
47
|
+
coosys.each{ |sys|
|
48
|
+
Misc::TypeCheck.new(sys, Meta::CooSys).check()
|
49
|
+
}
|
50
|
+
@coosys = coosys
|
51
|
+
|
52
|
+
params.each{ |param|
|
53
|
+
Misc::TypeCheck.new(param, Meta::Param).check()
|
54
|
+
}
|
55
|
+
@params = params
|
56
|
+
|
57
|
+
info.each{ |inf|
|
58
|
+
Misc::TypeCheck.new(inf, Meta::Info).check()
|
59
|
+
}
|
60
|
+
@info = info
|
61
|
+
|
62
|
+
resources.each{ |res|
|
63
|
+
Misc::TypeCheck.new(res, Meta::Resource).check()
|
64
|
+
}
|
65
|
+
@resources = resources
|
66
|
+
end
|
67
|
+
|
68
|
+
# Get the compact string representation of the VOTable.
|
69
|
+
def to_s
|
70
|
+
coosys = @coosys.each{|x| x.to_s}.join('|')
|
71
|
+
params = @params.each{|x| x.to_s}.join('|')
|
72
|
+
info = @info.each{|x| x.to_s}.join('|')
|
73
|
+
resources = @resources.each{|x| x.to_s}.join('|')
|
74
|
+
|
75
|
+
return "{id=#{@id};version=#{@version};" +
|
76
|
+
"description=#{@description};definitions=#{@definitions};" +
|
77
|
+
"coosys=#{coosys};params=#{params};info=#{info};" +
|
78
|
+
"resources=#{resources}}"
|
79
|
+
end
|
80
|
+
|
81
|
+
# A convenience method for accessing the fields of a votable,
|
82
|
+
# rather than having to iterate through each resource and table
|
83
|
+
# manually.
|
84
|
+
# Returns a list of VOTABLE::META::Field objects.
|
85
|
+
# [_res_:]
|
86
|
+
# The resource from which to extract the table in question.
|
87
|
+
# [_tbl_:]
|
88
|
+
# The resource from which to extract the table in question.
|
89
|
+
def fields(res=0, tbl=0)
|
90
|
+
@resources[res].tables()[tbl].fields() if @resources[res]
|
91
|
+
end
|
92
|
+
|
93
|
+
# A convenience method for determining the number of columns in
|
94
|
+
# a votable.
|
95
|
+
# [_res_:]
|
96
|
+
# The resource from which to extract the table in question.
|
97
|
+
# [_tbl_:]
|
98
|
+
# The resource from which to extract the table in question.
|
99
|
+
def number_of_fields(res=0, tbl=0)
|
100
|
+
return fields(res, tbl).length() || []
|
101
|
+
end
|
102
|
+
|
103
|
+
# A convenience method for accessing the row data of a votable.
|
104
|
+
# Returns a list of VOTABLE::DATA::TR objects.
|
105
|
+
# [_res_:]
|
106
|
+
# The resource from which to extract the table in question.
|
107
|
+
# [_tbl_:]
|
108
|
+
# The resource from which to extract the table in question.
|
109
|
+
def rows(res=0, tbl=0)
|
110
|
+
@resources[res].tables()[tbl].data().format().trs()
|
111
|
+
end
|
112
|
+
|
113
|
+
# A convenience method for determining the number of data rows
|
114
|
+
# in a votable.
|
115
|
+
# [_res_:]
|
116
|
+
# The resource from which to extract the table in question.
|
117
|
+
# [_tbl_:]
|
118
|
+
# The resource from which to extract the table in question.
|
119
|
+
def number_of_rows(res=0, tbl=0)
|
120
|
+
return rows(res, tbl).length()
|
121
|
+
end
|
122
|
+
|
123
|
+
# Find the main positional right ascension and declination
|
124
|
+
# fields in a votable using UCDs. This should work for both
|
125
|
+
# version 1 and 1+ UCDs.
|
126
|
+
# Returns a hash with the keys "ra" and "dec".
|
127
|
+
# [_res_:]
|
128
|
+
# The resource from which to extract the table in question.
|
129
|
+
# [_tbl_:]
|
130
|
+
# The resource from which to extract the table in question.
|
131
|
+
def main_positional_fields(res=0, tbl=0)
|
132
|
+
main_pos = {}
|
133
|
+
|
134
|
+
field_count = 0
|
135
|
+
fields(res, tbl).each do |field|
|
136
|
+
if field.ucd() != nil
|
137
|
+
ucd = field.ucd()
|
138
|
+
# Determine if the UCD is of intereset.
|
139
|
+
if ucd.value() == 'POS_EQ_RA_MAIN' or ucd.value() == 'pos.eq.ra;meta.main' # RA
|
140
|
+
main_pos["ra"] = [field_count, field]
|
141
|
+
elsif ucd.value() == 'POS_EQ_DEC_MAIN' or ucd.value() == 'pos.eq.dec;meta.main' # Dec
|
142
|
+
main_pos["dec"] = [field_count, field]
|
143
|
+
end
|
144
|
+
end
|
145
|
+
field_count = field_count + 1
|
146
|
+
end
|
147
|
+
return main_pos
|
148
|
+
end
|
149
|
+
|
150
|
+
# Find positional fields in a votable using UCDs. This should work
|
151
|
+
# for both version 1 and 1+ UCDs.
|
152
|
+
# Returns a hash of the positions of the fields and their
|
153
|
+
# corresponding VOTABLE::META::Field object.
|
154
|
+
# [_res_:]
|
155
|
+
# The resource from which to extract the table in question.
|
156
|
+
# [_tbl_:]
|
157
|
+
# The resource from which to extract the table in question.
|
158
|
+
def positional_fields(res=0, tbl=0)
|
159
|
+
pos = {}
|
160
|
+
|
161
|
+
field_count = 0
|
162
|
+
fields(res, tbl).each do |field|
|
163
|
+
if field.ucd() != nil
|
164
|
+
ucd = field.ucd()
|
165
|
+
# Determine if the UCD is of interest
|
166
|
+
if ucd.value() =~ /^POS.*/ or ucd.value() =~ /^pos\..*/
|
167
|
+
pos[field_count] = field
|
168
|
+
end
|
169
|
+
end
|
170
|
+
field_count = field_count + 1
|
171
|
+
end
|
172
|
+
return pos
|
173
|
+
end
|
174
|
+
|
175
|
+
# Find the date of observation fields in a votable using UCDs.
|
176
|
+
# This should work for both version 1 and 1+ UCDs, including
|
177
|
+
# experimental (e.g. VOX) ones.
|
178
|
+
# Returns a hash of the positions of the fields and their
|
179
|
+
# corresponding VOTABLE::META::Field object.
|
180
|
+
# [_res_:]
|
181
|
+
# The resource from which to extract the table in question.
|
182
|
+
# [_tbl_:]
|
183
|
+
# The resource from which to extract the table in question.
|
184
|
+
def date_of_observation_fields(res=0, tbl=0)
|
185
|
+
date_obs = {}
|
186
|
+
|
187
|
+
field_count = 0
|
188
|
+
fields(res, tbl).each do |field|
|
189
|
+
if field.ucd() != nil
|
190
|
+
ucd = field.ucd()
|
191
|
+
dt = field.datatype()
|
192
|
+
# Determine if the UCD is of interest.
|
193
|
+
if ucd.value() == 'VOX:Image_MJDateObs' or
|
194
|
+
(dt.value() == 'double' and (ucd.value() == 'TIME_DATE' or ucd.value() == 'time.epoch'))
|
195
|
+
date_obs[field_count] = field
|
196
|
+
end
|
197
|
+
end
|
198
|
+
field_count = field_count + 1
|
199
|
+
end
|
200
|
+
return date_obs
|
201
|
+
end
|
202
|
+
|
203
|
+
# Find time fields in a votable using UCDs. This should work
|
204
|
+
# for both version 1 and 1+ UCDs, including experimental (e.g. VOX) ones.
|
205
|
+
# Returns a hash of the positions of the fields and their
|
206
|
+
# corresponding VOTABLE::META::Field object.
|
207
|
+
# [_res_:]
|
208
|
+
# The resource from which to extract the table in question.
|
209
|
+
# [_tbl_:]
|
210
|
+
# The resource from which to extract the table in question.
|
211
|
+
def time_fields(res=0, tbl=0)
|
212
|
+
times = {}
|
213
|
+
field_count = 0
|
214
|
+
fields(res, tbl).each do |field|
|
215
|
+
if field.ucd() != nil
|
216
|
+
ucd = field.ucd()
|
217
|
+
if ucd.value() =~ /^TIME.*/ or ucd.value() =~ /time\..*/ or ucd.value() == 'VOX:Image_MJDateObs'
|
218
|
+
times[field_count] = field
|
219
|
+
end
|
220
|
+
end
|
221
|
+
field_count = field_count + 1
|
222
|
+
end
|
223
|
+
return times
|
224
|
+
end
|
225
|
+
|
226
|
+
# Find the column number(s) associated with a UCD.
|
227
|
+
# Returns a list of column positions.
|
228
|
+
# [_res_:]
|
229
|
+
# The resource from which to extract the table in question.
|
230
|
+
# [_tbl_:]
|
231
|
+
# The resource from which to extract the table in question.
|
232
|
+
def find_columns(ucd, res=0, tbl=0)
|
233
|
+
columns = []
|
234
|
+
|
235
|
+
col_count = 0
|
236
|
+
fields = fields(res, tbl)
|
237
|
+
if fields
|
238
|
+
fields.each do |field|
|
239
|
+
if field.ucd() != nil
|
240
|
+
tbl_ucd = field.ucd()
|
241
|
+
columns.push(col_count) if tbl_ucd.value() == ucd
|
242
|
+
end
|
243
|
+
col_count += 1
|
244
|
+
end
|
245
|
+
end
|
246
|
+
return columns
|
247
|
+
end
|
248
|
+
|
249
|
+
# Find the column number(s) associated with the
|
250
|
+
# VOX:imageAccessReference UCD.
|
251
|
+
# Returns a list of column positions.
|
252
|
+
def image_access_reference_columns
|
253
|
+
# The following is correct
|
254
|
+
# find_columns('VOX:Image_AccessReference').first
|
255
|
+
# The following is cause XMM ticks me off (not valid SIAP).
|
256
|
+
if find_columns('VOX:Image_AccessReference').first != nil
|
257
|
+
find_columns('VOX:Image_AccessReference').first
|
258
|
+
else
|
259
|
+
find_columns('DATA_LINK').first
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
263
|
+
def image_ra_columns
|
264
|
+
if find_columns('POS_EQ_RA_MAIN').first != nil
|
265
|
+
find_columns('POS_EQ_RA_MAIN').first
|
266
|
+
elsif find_columns('pos.eq.ra;meta.main').first != nil
|
267
|
+
find_columns('pos.eq.ra;meta.main').first
|
268
|
+
end
|
269
|
+
end
|
270
|
+
|
271
|
+
def image_dec_columns
|
272
|
+
if find_columns('POS_EQ_DEC_MAIN').first != nil
|
273
|
+
find_columns('POS_EQ_DEC_MAIN').first
|
274
|
+
elsif find_columns('pos.eq.dec;meta.main').first != nil
|
275
|
+
find_columns('pos.eq.dec;meta.main').first
|
276
|
+
end
|
277
|
+
end
|
278
|
+
|
279
|
+
def image_filter_columns
|
280
|
+
if find_columns('VOX:BandPass_ID').first != nil
|
281
|
+
find_columns('VOX:BandPass_ID').first
|
282
|
+
elsif find_columns('instr.filter').first != nil
|
283
|
+
find_columns('instr.filter').first
|
284
|
+
end
|
285
|
+
end
|
286
|
+
|
287
|
+
def image_date_obs_columns
|
288
|
+
if find_columns('time.obs.start').first != nil
|
289
|
+
find_columns('time.obs.start').first
|
290
|
+
end
|
291
|
+
end
|
292
|
+
|
293
|
+
def image_telescope_columns
|
294
|
+
if find_columns('instr.tel').first != nil
|
295
|
+
find_columns('instr.tel').first
|
296
|
+
end
|
297
|
+
end
|
298
|
+
|
299
|
+
def image_survey_columns
|
300
|
+
if find_columns('VOX:Image_Title').first != nil
|
301
|
+
find_columns('VOX:Image_Title').first
|
302
|
+
elsif find_columns('ID_SURVEY').first != nil
|
303
|
+
find_columns('ID_SURVEY').first
|
304
|
+
end
|
305
|
+
end
|
306
|
+
|
307
|
+
def image_instrument_columns
|
308
|
+
if find_columns('VOX:INST_ID').first != nil
|
309
|
+
find_columns('VOX:INST_ID').first
|
310
|
+
elsif find_columns('INST_ID').first != nil
|
311
|
+
find_columns('INST_ID').first
|
312
|
+
elsif find_columns('instr').first != nil
|
313
|
+
find_columns('instr').first
|
314
|
+
end
|
315
|
+
end
|
316
|
+
|
317
|
+
def image_sky_columns
|
318
|
+
if find_columns('instr.skyLevel').first != nil
|
319
|
+
find_columns('instr.skyLevel').first
|
320
|
+
end
|
321
|
+
end
|
322
|
+
|
323
|
+
def image_zeropoint_columns
|
324
|
+
if find_columns('arith.zp;phot').first != nil
|
325
|
+
find_columns('arith.zp;phot').first
|
326
|
+
end
|
327
|
+
end
|
328
|
+
|
329
|
+
def image_seeing_columns
|
330
|
+
if find_columns('instr.obsty.seeing').first != nil
|
331
|
+
find_columns('instr.obsty.seeing').first
|
332
|
+
end
|
333
|
+
end
|
334
|
+
|
335
|
+
def image_depth_columns
|
336
|
+
#if find_columns('').first != nil
|
337
|
+
# find_columns('').first
|
338
|
+
#end
|
339
|
+
end
|
340
|
+
|
341
|
+
def image_exptime_columns
|
342
|
+
if find_columns('time.expo').first != nil
|
343
|
+
find_columns('time.expo').first
|
344
|
+
end
|
345
|
+
end
|
346
|
+
|
347
|
+
# Create headers for HTML table
|
348
|
+
# [_res_:]
|
349
|
+
# The resource from which to extract the table in question.
|
350
|
+
# [_tbl_:]
|
351
|
+
# The table inside the resource from which to extract the rows in question.
|
352
|
+
# [_infer_add_to_cart_ref_:]
|
353
|
+
#
|
354
|
+
# [_add_to_cart_header_value_:]
|
355
|
+
#
|
356
|
+
# [_infer_access_ref_:]
|
357
|
+
# Link the access reference URL associated with a row.
|
358
|
+
# [_access_ref_header_value_:]
|
359
|
+
# For the access reference column, place this value in the header.
|
360
|
+
# [_access_ref_col_:]
|
361
|
+
# A valid SIA VOTable will only ever have one VOX:Image_AccessReference.
|
362
|
+
# [_header_class_:]
|
363
|
+
# The class to assign the header of the HTML table.
|
364
|
+
def create_headers(res, tbl,
|
365
|
+
infer_add_to_cart_ref, add_to_cart_header_value,
|
366
|
+
infer_access_ref, access_ref_header_value, access_ref_col,
|
367
|
+
header_class)
|
368
|
+
|
369
|
+
headers = Array.new
|
370
|
+
thead = "<thead class=\"#{header_class}\">\n"
|
371
|
+
|
372
|
+
thead << "<tr>\n"
|
373
|
+
if infer_add_to_cart_ref
|
374
|
+
thead << "<th>#{add_to_cart_header_value}</th>\n"
|
375
|
+
headers.push(' ')
|
376
|
+
end
|
377
|
+
if infer_access_ref
|
378
|
+
thead << "<th>#{access_ref_header_value}</th>\n"
|
379
|
+
headers.push(' ')
|
380
|
+
end
|
381
|
+
col_count = 0
|
382
|
+
fields(res, tbl).each do |field|
|
383
|
+
if infer_access_ref and col_count == access_ref_col
|
384
|
+
headers[1] = field.ucd.value
|
385
|
+
else
|
386
|
+
thead << "<th>#{field.name}</th>\n"
|
387
|
+
headers.push(field.ucd.value)
|
388
|
+
end
|
389
|
+
col_count += 1
|
390
|
+
end
|
391
|
+
thead << " </tr>\n"
|
392
|
+
|
393
|
+
thead << "<tr>\n"
|
394
|
+
headers.each do |h|
|
395
|
+
thead << "<th>#{h}</th>\n"
|
396
|
+
end
|
397
|
+
thead << "</tr>\n"
|
398
|
+
|
399
|
+
thead << "</thead>"
|
400
|
+
|
401
|
+
return thead
|
402
|
+
end
|
403
|
+
|
404
|
+
def create_add_to_cart_link(link_ref, columns)
|
405
|
+
access_ref_col = image_access_reference_columns()
|
406
|
+
link_ref << '&resource=' + CGI.escape(columns[access_ref_col].value).to_s if access_ref_col
|
407
|
+
ra_col = image_ra_columns()
|
408
|
+
link_ref << '&rac=' + columns[ra_col].value.to_s if ra_col
|
409
|
+
dec_col = image_dec_columns()
|
410
|
+
link_ref << '&decc=' + columns[dec_col].value.to_s if dec_col
|
411
|
+
filter_col = image_filter_columns()
|
412
|
+
link_ref << '&filter=' + columns[filter_col].value.to_s if filter_col
|
413
|
+
date_obs_col = image_date_obs_columns()
|
414
|
+
link_ref << '&date_obs=' + columns[date_obs_col].value.to_s if date_obs_col
|
415
|
+
teles_col = image_telescope_columns()
|
416
|
+
link_ref << '&telescop=' + columns[teles_col].value.to_s if teles_col
|
417
|
+
survey_col = image_survey_columns()
|
418
|
+
link_ref << '&survey=' + columns[survey_col].value.to_s if survey_col
|
419
|
+
instrum_col = image_instrument_columns()
|
420
|
+
link_ref << '&instrument=' + columns[instrum_col].value.to_s if instrum_col
|
421
|
+
sky_col = image_sky_columns()
|
422
|
+
link_ref << '&sky=' + columns[sky_col].value.to_s if sky_col
|
423
|
+
zerop_col = image_zeropoint_columns()
|
424
|
+
link_ref << '&zeropoint=' + columns[zerop_col].value.to_s if zerop_col
|
425
|
+
seeing_col = image_seeing_columns()
|
426
|
+
link_ref << '&seeing=' + columns[seeing_col].value.to_s if seeing_col
|
427
|
+
depth_col = image_depth_columns()
|
428
|
+
link_ref << '&depth=' + columns[depth_col].value.to_s if depth_col
|
429
|
+
exptime_col = image_exptime_columns()
|
430
|
+
link_ref << '&exptime=' + columns[exptime_col].value.to_s if exptime_col
|
431
|
+
|
432
|
+
return link_ref
|
433
|
+
end
|
434
|
+
|
435
|
+
# Create body for HTML table
|
436
|
+
# [_res_:]
|
437
|
+
# The resource from which to extract the table in question.
|
438
|
+
# [_tbl_:]
|
439
|
+
# The table inside the resource from which to extract the rows in question.
|
440
|
+
# [_infer_add_to_cart_ref_:]
|
441
|
+
#
|
442
|
+
# [_add_to_cart_link_value_:]
|
443
|
+
#
|
444
|
+
# [_add_to_cart_link_ref_:]
|
445
|
+
#
|
446
|
+
# [_infer_access_ref_:]
|
447
|
+
# Link the access reference URL associated with a row.
|
448
|
+
# [_access_ref_link_value_:]
|
449
|
+
# For the access reference column, link this word.
|
450
|
+
# [_access_ref_col_:]
|
451
|
+
# A valid SIA VOTable will only ever have one VOX:Image_AccessReference.
|
452
|
+
# [_body_class_:]
|
453
|
+
# The class to assign the body of the HTML table.
|
454
|
+
# [_row_classes_:]
|
455
|
+
# The class to assign the HTML table body rows.
|
456
|
+
def create_body(res, tbl,
|
457
|
+
infer_add_to_cart_ref, add_to_cart_link_value, add_to_cart_link_ref,
|
458
|
+
infer_access_ref, access_ref_link_value, access_ref_col,
|
459
|
+
body_class, row_classes)
|
460
|
+
|
461
|
+
tbody = "<tbody class=\"#{body_class}\">\n"
|
462
|
+
row_count = 0
|
463
|
+
rows(res, tbl).each do |tr|
|
464
|
+
tbody << "<tr class=\"#{row_classes[row_count % 2]}\">\n"
|
465
|
+
|
466
|
+
# Specially mark up the first column to link to the image.
|
467
|
+
columns = tr.tds()
|
468
|
+
|
469
|
+
if infer_add_to_cart_ref
|
470
|
+
archive = add_to_cart_link_ref.slice(add_to_cart_link_ref.index('&archive='), add_to_cart_link_ref.length)
|
471
|
+
archive = archive.slice('&archive='.length, archive.length)
|
472
|
+
archive = archive.slice(0, archive.index('&')) if archive.index('&')
|
473
|
+
link_id = 'add_' + archive.to_s + '_' + row_count.to_s
|
474
|
+
url = create_add_to_cart_link(add_to_cart_link_ref, columns)
|
475
|
+
js = "new Ajax.Request('#{url}', " +
|
476
|
+
" {method: 'post', " +
|
477
|
+
" onComplete: function(request){Element.hide('#{link_id}');}});"
|
478
|
+
tbody << "<td><a id=\"#{link_id}\" href=\"javascript:void(0);\" " +
|
479
|
+
"onclick=\"#{js};return false;\"" +
|
480
|
+
">#{add_to_cart_link_value}</a></td>\n"
|
481
|
+
end
|
482
|
+
if infer_access_ref
|
483
|
+
link_ref = columns[access_ref_col].value
|
484
|
+
tbody << "<td><a href=\"#{link_ref}\">#{access_ref_link_value}</a></td>\n"
|
485
|
+
end
|
486
|
+
|
487
|
+
col_count = 0
|
488
|
+
columns.each do |td|
|
489
|
+
tbody << "<td>#{td.value}</td>\n" if infer_access_ref and col_count != access_ref_col
|
490
|
+
col_count += 1
|
491
|
+
end
|
492
|
+
tbody << "</tr>\n"
|
493
|
+
row_count += 1
|
494
|
+
end
|
495
|
+
tbody << "</tbody>"
|
496
|
+
|
497
|
+
return tbody
|
498
|
+
end
|
499
|
+
|
500
|
+
# Create table for HTML VOTable
|
501
|
+
# [_id_:]
|
502
|
+
# The ID to assign to the HTML table as a whole.
|
503
|
+
# [_show_border_:]
|
504
|
+
# The boolean value to show HTML table border.
|
505
|
+
# [_table_class_:]
|
506
|
+
# The class to assign the HTML table as a whole.
|
507
|
+
# [_thead_:]
|
508
|
+
# The class to assign the HTML table thead.
|
509
|
+
# [_tbody_:]
|
510
|
+
# The class to assign the HTML table tbody.
|
511
|
+
def create_table(id, show_border, table_class, thead, tbody)
|
512
|
+
table = "<table class=\"#{table_class}\""
|
513
|
+
table << " id=\"#{id}\"" if id
|
514
|
+
table << " border=\"1\"" if show_border
|
515
|
+
table << " width=\"100%\">\n"
|
516
|
+
table << "#{thead}\n#{tbody}\n</table>"
|
517
|
+
return table
|
518
|
+
end
|
519
|
+
|
520
|
+
# Convert the specified table in the specified resource into an HTML
|
521
|
+
# table.
|
522
|
+
# [_id_:]
|
523
|
+
# The ID to assign to the HTML table as a whole.
|
524
|
+
# [_add_to_cart_link_ref_:]
|
525
|
+
#
|
526
|
+
# [_res_:]
|
527
|
+
# The resource from which to extract the table in question.
|
528
|
+
# [_tbl_:]
|
529
|
+
# The table inside the resource from which to extract the rows in question.
|
530
|
+
# [_infer_add_to_cart_ref_:]
|
531
|
+
#
|
532
|
+
# [_add_to_cart_header_value_:]
|
533
|
+
#
|
534
|
+
# [_add_to_cart_link_value_:]
|
535
|
+
#
|
536
|
+
# [_infer_access_ref_:]
|
537
|
+
# Link the access reference URL associated with a row.
|
538
|
+
# [_access_ref_header_value_:]
|
539
|
+
# For the access reference column, place this value in the header.
|
540
|
+
# [_access_ref_link_value_:]
|
541
|
+
# For the access reference column, link this word.
|
542
|
+
# [_show_border_:]
|
543
|
+
# The boolean value to show HTML table border
|
544
|
+
# [_table_class_:]
|
545
|
+
# The class to assign the HTML table as a whole.
|
546
|
+
# [_header_class_:]
|
547
|
+
# The class to assign the header of the HTML table.
|
548
|
+
# [_body_class_:]
|
549
|
+
# The class to assign the body of the HTML table.
|
550
|
+
# [_row_classes_:]
|
551
|
+
# The class to assign the HTML table body rows.
|
552
|
+
def to_html(id=nil, add_to_cart_link_ref=nil, res=0, tbl=0,
|
553
|
+
infer_add_to_cart_ref=true,
|
554
|
+
add_to_cart_header_value='Add to Cart',
|
555
|
+
add_to_cart_link_value='Add',
|
556
|
+
infer_access_ref=true,
|
557
|
+
access_ref_header_value='URL',
|
558
|
+
access_ref_link_value='Retrieve',
|
559
|
+
show_border=false,
|
560
|
+
table_class='votable',
|
561
|
+
header_class='header',
|
562
|
+
body_class='body',
|
563
|
+
row_classes=['row1', 'row2'])
|
564
|
+
begin
|
565
|
+
# A valid SIA VOTable will only ever have one VOX:Image_AccessReference.
|
566
|
+
access_ref_col = image_access_reference_columns()
|
567
|
+
|
568
|
+
if access_ref_col
|
569
|
+
# Create headers
|
570
|
+
thead = create_headers(res, tbl,
|
571
|
+
infer_add_to_cart_ref, add_to_cart_header_value,
|
572
|
+
infer_access_ref, access_ref_header_value, access_ref_col,
|
573
|
+
header_class)
|
574
|
+
|
575
|
+
# Create body
|
576
|
+
tbody = create_body(res, tbl,
|
577
|
+
infer_add_to_cart_ref, add_to_cart_link_value, add_to_cart_link_ref,
|
578
|
+
infer_access_ref, access_ref_link_value, access_ref_col,
|
579
|
+
body_class, row_classes)
|
580
|
+
|
581
|
+
return create_table(id, show_border, table_class, thead, tbody)
|
582
|
+
else
|
583
|
+
title = 'No Data'
|
584
|
+
message = 'VOTable not contains data.'
|
585
|
+
return create_message_table(table_class, header_class,
|
586
|
+
body_class, row_classes, title, message)
|
587
|
+
end
|
588
|
+
|
589
|
+
rescue Exception => e
|
590
|
+
title = 'Error'
|
591
|
+
message = e.backtrace#@resources[0].info[0].text().to_s()
|
592
|
+
table = create_message_table(table_class, header_class,
|
593
|
+
body_class, row_classes, title, message)
|
594
|
+
end
|
595
|
+
end
|
596
|
+
|
597
|
+
def create_message_table(table_class, header_class, body_class,
|
598
|
+
row_classes, title, message)
|
599
|
+
table = "<table class=\"#{table_class}\" width=\"100%\">\n"
|
600
|
+
|
601
|
+
table << " <thead class=\"#{header_class}\">\n"
|
602
|
+
table << " <tr>\n"
|
603
|
+
table << " <th>#{title}</th>\n"
|
604
|
+
table << " </tr>\n"
|
605
|
+
table << " </thead>\n"
|
606
|
+
|
607
|
+
table << " <tbody class=\"#{body_class}\">\n"
|
608
|
+
table << " <tr class=\"#{row_classes[0]}\">\n"
|
609
|
+
table << " <td align=\"center\"><label>VOTable message: #{message}" +
|
610
|
+
"</label></td>\n"
|
611
|
+
table << " </tr>\n"
|
612
|
+
table << " </tbody>\n"
|
613
|
+
|
614
|
+
table << "</table>"
|
615
|
+
|
616
|
+
return table
|
617
|
+
end
|
618
|
+
|
619
|
+
def self._find_attr_value(attributes, name)
|
620
|
+
attributes.each do |qname, value|
|
621
|
+
return value if qname.name == name
|
622
|
+
end
|
623
|
+
|
624
|
+
return nil
|
625
|
+
end
|
626
|
+
end
|
627
|
+
end
|
628
|
+
|
629
|
+
end
|
630
|
+
end
|