voruby 1.1.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (257) hide show
  1. data/Rakefile.rb +107 -224
  2. data/lib/misc.rb +1 -0
  3. data/lib/misc/misc.rb +60 -0
  4. data/lib/misc/propertyfile.rb +31 -0
  5. data/lib/symphony.rb +1 -0
  6. data/lib/symphony/symphony.rb +247 -0
  7. data/lib/voruby.rb +186 -0
  8. data/lib/voruby/active_votable/active_votable.rb +468 -347
  9. data/lib/voruby/adql/1.0/adql.rb +2418 -0
  10. data/lib/voruby/adql/support.rb +2 -0
  11. data/lib/voruby/misc.rb +351 -0
  12. data/lib/voruby/misc/connection_monitor.rb +97 -0
  13. data/lib/voruby/misc/libxml_ext.rb +121 -0
  14. data/lib/voruby/misc/rexml_ext.rb +223 -0
  15. data/lib/voruby/resolver/resolver.rb +12 -0
  16. data/lib/voruby/resolver/sesame.rb +299 -0
  17. data/lib/voruby/sky_query/sky_query.rb +192 -0
  18. data/lib/voruby/stc/1.10/coords.rb +2272 -0
  19. data/lib/voruby/stc/1.10/region.rb +892 -0
  20. data/lib/voruby/stc/1.10/stc.rb +3271 -0
  21. data/lib/voruby/stc/1.30/stc.rb +8666 -0
  22. data/lib/voruby/stc/support.rb +2 -0
  23. data/lib/voruby/ucd/ucd.rb +173 -0
  24. data/lib/voruby/voevent/1.1/voevent.rb +1124 -0
  25. data/lib/voruby/voevent/support.rb +5 -0
  26. data/lib/voruby/votable/1.0/votable.rb +1807 -0
  27. data/lib/voruby/votable/1.1/votable.rb +2100 -0
  28. data/lib/voruby/votable/votable.rb +305 -0
  29. data/lib/voruby/wesix/wesix.rb +491 -0
  30. data/lib/voruby/xlink/1.2/xlink.rb +21 -0
  31. data/test/voruby/active_votable/complex.vot +60 -0
  32. data/test/voruby/active_votable/error.vot +6 -0
  33. data/test/voruby/active_votable/large.vot +130040 -0
  34. data/test/voruby/active_votable/simple1.vot +38 -0
  35. data/test/voruby/active_votable/simple2.vot +38 -0
  36. data/test/voruby/active_votable/test.rb +193 -0
  37. data/test/voruby/adql/1.0/adql-alias.sql +1 -0
  38. data/test/voruby/adql/1.0/adql-alias.xml +26 -0
  39. data/test/voruby/adql/1.0/adql-avg.sql +1 -0
  40. data/test/voruby/adql/1.0/adql-avg.xml +31 -0
  41. data/test/voruby/adql/1.0/adql-circle.sql +1 -0
  42. data/test/voruby/adql/1.0/adql-circle.xml +46 -0
  43. data/test/voruby/adql/1.0/adql-expr.sql +1 -0
  44. data/test/voruby/adql/1.0/adql-expr.xml +34 -0
  45. data/test/voruby/adql/1.0/adql-function.sql +1 -0
  46. data/test/voruby/adql/1.0/adql-function.xml +41 -0
  47. data/test/voruby/adql/1.0/adql-group.sql +1 -0
  48. data/test/voruby/adql/1.0/adql-group.xml +51 -0
  49. data/test/voruby/adql/1.0/adql-having.sql +1 -0
  50. data/test/voruby/adql/1.0/adql-having.xml +25 -0
  51. data/test/voruby/adql/1.0/adql-like.sql +1 -0
  52. data/test/voruby/adql/1.0/adql-like.xml +17 -0
  53. data/test/voruby/adql/1.0/adql-order.sql +1 -0
  54. data/test/voruby/adql/1.0/adql-order.xml +37 -0
  55. data/test/voruby/adql/1.0/adql-simple.sql +1 -0
  56. data/test/voruby/adql/1.0/adql-simple.xml +12 -0
  57. data/test/voruby/adql/1.0/adql-top.sql +1 -0
  58. data/test/voruby/adql/1.0/adql-top.xml +33 -0
  59. data/test/voruby/adql/1.0/test.rb +2220 -0
  60. data/test/voruby/misc/test.rb +32 -0
  61. data/test/voruby/resolver/sesame/test.rb +56 -0
  62. data/test/voruby/sky_query/test.rb +107 -0
  63. data/test/voruby/stc/1.10/coords_test.rb +3704 -0
  64. data/test/voruby/stc/1.10/region_test.rb +993 -0
  65. data/test/voruby/stc/1.10/stc-catalog-entry-location.xml +112 -0
  66. data/test/voruby/stc/1.10/stc-obs-data-location.xml +126 -0
  67. data/test/voruby/stc/1.10/stc-region-circle.xml +5 -0
  68. data/test/voruby/stc/1.10/stc-region-convex.xml +11 -0
  69. data/test/voruby/stc/1.10/stc-region-convexhull.xml +5 -0
  70. data/test/voruby/stc/1.10/stc-region-ellipse.xml +7 -0
  71. data/test/voruby/stc/1.10/stc-region-intersection.xml +25 -0
  72. data/test/voruby/stc/1.10/stc-region-negation.xml +7 -0
  73. data/test/voruby/stc/1.10/stc-region-polygon.xml +13 -0
  74. data/test/voruby/stc/1.10/stc-region-sector.xml +6 -0
  75. data/test/voruby/stc/1.10/stc-region-union.xml +25 -0
  76. data/test/voruby/stc/1.10/stc-resource-profile.xml +60 -0
  77. data/test/voruby/stc/1.10/stc-search-location.xml +54 -0
  78. data/test/voruby/stc/1.10/stc_test.rb +4626 -0
  79. data/test/voruby/stc/1.30/stc-catalog-entry-location.xml +210 -0
  80. data/test/voruby/stc/1.30/stc-obs-data-location-arecibo.xml +353 -0
  81. data/test/voruby/stc/1.30/stc-obs-data-location-fits.xml +250 -0
  82. data/test/voruby/stc/1.30/stc-obs-data-location-xlink.xml +63 -0
  83. data/test/voruby/stc/1.30/stc-obs-data-location.xml +216 -0
  84. data/test/voruby/stc/1.30/stc-resource-profile-unusual-ref-pos.xml +39 -0
  85. data/test/voruby/stc/1.30/stc-resource-profile.xml +129 -0
  86. data/test/voruby/stc/1.30/stc-search-location-arecibo.xml +86 -0
  87. data/test/voruby/stc/1.30/stc-search-location.xml +101 -0
  88. data/test/voruby/stc/1.30/test.rb +6274 -0
  89. data/test/voruby/ucd/test.rb +48 -0
  90. data/test/voruby/voevent/1.1/test.rb +812 -0
  91. data/test/{voevent/voevent_v1_1.xml → voruby/voevent/1.1/voevent.xml} +2 -2
  92. data/test/voruby/voregistry/0.3/test.rb +137 -0
  93. data/test/voruby/votable/1.0/test.rb +714 -0
  94. data/test/voruby/votable/1.0/votable.basic.xml +660 -0
  95. data/test/voruby/votable/1.0/votable.html +86 -0
  96. data/test/voruby/votable/1.0/votable.ns.xml +56 -0
  97. data/test/voruby/votable/1.1/test.rb +785 -0
  98. data/test/voruby/votable/1.1/votable.basic.xml +38 -0
  99. data/test/voruby/votable/1.1/votable.html +86 -0
  100. data/test/voruby/votable/1.1/votable.ns.xml +56 -0
  101. data/test/voruby/votable/test.rb +15 -0
  102. data/test/voruby/wesix/test.rb +268 -0
  103. data/test/voruby/wesix/testr.fits +28 -0
  104. metadata +234 -247
  105. data/REQUIREMENTS +0 -6
  106. data/lib/voruby/active_votable/loader.rb +0 -5
  107. data/lib/voruby/adql/adql.rb +0 -2787
  108. data/lib/voruby/adql/ext.rb +0 -14
  109. data/lib/voruby/adql/loader.rb +0 -6
  110. data/lib/voruby/adql/operations.rb +0 -54
  111. data/lib/voruby/adql/parser.rb +0 -160
  112. data/lib/voruby/adql/transforms.rb +0 -573
  113. data/lib/voruby/ext.rb +0 -17
  114. data/lib/voruby/loader.rb +0 -4
  115. data/lib/voruby/misc/propertyfile.rb +0 -36
  116. data/lib/voruby/plastic/applications.rb +0 -174
  117. data/lib/voruby/plastic/constants.rb +0 -30
  118. data/lib/voruby/plastic/loader.rb +0 -10
  119. data/lib/voruby/plastic/plastic.rb +0 -1
  120. data/lib/voruby/resources/conesearch/conesearch.rb +0 -9
  121. data/lib/voruby/resources/conesearch/conesearch_v0_2.rb +0 -55
  122. data/lib/voruby/resources/conesearch/conesearch_v0_3.rb +0 -50
  123. data/lib/voruby/resources/conesearch/conesearch_v1_0.rb +0 -72
  124. data/lib/voruby/resources/conesearch/loader.rb +0 -4
  125. data/lib/voruby/resources/loader.rb +0 -50
  126. data/lib/voruby/resources/nodes.rb +0 -190
  127. data/lib/voruby/resources/openskynode/loader.rb +0 -4
  128. data/lib/voruby/resources/openskynode/openskynode.rb +0 -9
  129. data/lib/voruby/resources/openskynode/openskynode_v0_1.rb +0 -54
  130. data/lib/voruby/resources/sia/loader.rb +0 -5
  131. data/lib/voruby/resources/sia/sia.rb +0 -9
  132. data/lib/voruby/resources/sia/sia_v0_6.rb +0 -90
  133. data/lib/voruby/resources/sia/sia_v0_7.rb +0 -89
  134. data/lib/voruby/resources/sia/sia_v1_0.rb +0 -122
  135. data/lib/voruby/resources/stsci.rb +0 -59
  136. data/lib/voruby/resources/vodataservice/coverage_v0_2.rb +0 -195
  137. data/lib/voruby/resources/vodataservice/coverage_v0_3.rb +0 -158
  138. data/lib/voruby/resources/vodataservice/loader.rb +0 -5
  139. data/lib/voruby/resources/vodataservice/vodataservice.rb +0 -9
  140. data/lib/voruby/resources/vodataservice/vodataservice_v0_4.rb +0 -189
  141. data/lib/voruby/resources/vodataservice/vodataservice_v0_5.rb +0 -163
  142. data/lib/voruby/resources/vodataservice/vodataservice_v1_0.rb +0 -221
  143. data/lib/voruby/resources/voregistry/loader.rb +0 -4
  144. data/lib/voruby/resources/voregistry/voregistry.rb +0 -9
  145. data/lib/voruby/resources/voregistry/voregistry_v0_2.rb +0 -40
  146. data/lib/voruby/resources/voregistry/voregistry_v0_3.rb +0 -30
  147. data/lib/voruby/resources/voregistry/voregistry_v1_0.rb +0 -86
  148. data/lib/voruby/resources/voresource/loader.rb +0 -17
  149. data/lib/voruby/resources/voresource/voresource.rb +0 -9
  150. data/lib/voruby/resources/voresource/voresource_v0_10.rb +0 -327
  151. data/lib/voruby/resources/voresource/voresource_v0_9.rb +0 -405
  152. data/lib/voruby/resources/voresource/voresource_v1_0.rb +0 -230
  153. data/lib/voruby/services/ext.rb +0 -11
  154. data/lib/voruby/services/gestalt/footprint.rb +0 -95
  155. data/lib/voruby/services/gestalt/wcs_fixer.rb +0 -105
  156. data/lib/voruby/services/gestalt/wesix.rb +0 -155
  157. data/lib/voruby/services/loader.rb +0 -7
  158. data/lib/voruby/services/registry/registry.rb +0 -53
  159. data/lib/voruby/services/resolver/resolver.rb +0 -35
  160. data/lib/voruby/services/schema/schema.rb +0 -644
  161. data/lib/voruby/sesame/loader.rb +0 -6
  162. data/lib/voruby/sesame/sesame_v1_0.rb +0 -64
  163. data/lib/voruby/simple/loader.rb +0 -6
  164. data/lib/voruby/simple/parameters.rb +0 -196
  165. data/lib/voruby/simple/sap.rb +0 -446
  166. data/lib/voruby/spacetime/loader.rb +0 -3
  167. data/lib/voruby/spacetime/spacetime.rb +0 -607
  168. data/lib/voruby/stc/coords_v1_20.rb +0 -900
  169. data/lib/voruby/stc/loader.rb +0 -55
  170. data/lib/voruby/stc/region_v1_20.rb +0 -274
  171. data/lib/voruby/stc/stc_v1_20.rb +0 -1196
  172. data/lib/voruby/util.rb +0 -27
  173. data/lib/voruby/voevent/loader.rb +0 -7
  174. data/lib/voruby/voevent/voevent_v1_0.rb +0 -213
  175. data/lib/voruby/voevent/voevent_v1_1.rb +0 -196
  176. data/lib/voruby/votables/chandra.rb +0 -373
  177. data/lib/voruby/votables/data.rb +0 -179
  178. data/lib/voruby/votables/galex.rb +0 -377
  179. data/lib/voruby/votables/int.rb +0 -354
  180. data/lib/voruby/votables/libxml_parser.rb +0 -411
  181. data/lib/voruby/votables/libxml_votable.rb +0 -67
  182. data/lib/voruby/votables/loader.rb +0 -10
  183. data/lib/voruby/votables/meta.rb +0 -763
  184. data/lib/voruby/votables/misc.rb +0 -51
  185. data/lib/voruby/votables/nsa.rb +0 -410
  186. data/lib/voruby/votables/rexml_parser.rb +0 -408
  187. data/lib/voruby/votables/rexml_votable.rb +0 -67
  188. data/lib/voruby/votables/sdss.rb +0 -356
  189. data/lib/voruby/votables/transforms.rb +0 -388
  190. data/lib/voruby/votables/tree.rb +0 -45
  191. data/lib/voruby/votables/types.rb +0 -391
  192. data/lib/voruby/votables/votable.rb +0 -687
  193. data/test/active_votable/database.yml +0 -6
  194. data/test/active_votable/test.vot +0 -168492
  195. data/test/active_votable/unittest.rb +0 -41
  196. data/test/adql/test1.adql +0 -49
  197. data/test/adql/test2.adql +0 -51
  198. data/test/adql/test3.adql +0 -81
  199. data/test/adql/test4.adql +0 -53
  200. data/test/adql/test5.adql +0 -55
  201. data/test/adql/test6.adql +0 -18
  202. data/test/adql/test7.adql +0 -48
  203. data/test/adql/unittest.rb +0 -1672
  204. data/test/plastic/test.rb +0 -44
  205. data/test/plastic/test.vot +0 -5385
  206. data/test/plastic/unittest.rb +0 -66
  207. data/test/resources/conesearch/conesearch_v0_3.xml +0 -31
  208. data/test/resources/conesearch/conesearch_v1_0.xml +0 -86
  209. data/test/resources/conesearch/unittest_v0_3.rb +0 -22
  210. data/test/resources/conesearch/unittest_v1_0.rb +0 -24
  211. data/test/resources/openskynode/open_sky_node_v0_1.xml +0 -32
  212. data/test/resources/openskynode/unittest_v0_1.rb +0 -31
  213. data/test/resources/sia/simple_image_access_v0_7.xml +0 -36
  214. data/test/resources/sia/simple_image_access_v1_0.xml +0 -122
  215. data/test/resources/sia/unittest_v0_7.rb +0 -24
  216. data/test/resources/sia/unittest_v1_0.rb +0 -29
  217. data/test/resources/stsci.xml +0 -336
  218. data/test/resources/unittest_stsci.rb +0 -25
  219. data/test/resources/vodataservice/catalog_service_resource_v1_0.xml +0 -128
  220. data/test/resources/vodataservice/data_collection_resource_v0_5.xml +0 -54
  221. data/test/resources/vodataservice/data_collection_resource_v1_0.xml +0 -117
  222. data/test/resources/vodataservice/data_service_resource_v1_0.xml +0 -115
  223. data/test/resources/vodataservice/sky_service_resource_v0_10.xml +0 -45
  224. data/test/resources/vodataservice/table_service_resource_v1_0.xml +0 -122
  225. data/test/resources/vodataservice/tabular_sky_service_resource_v0_10.xml +0 -60
  226. data/test/resources/vodataservice/unittest_v0_5.rb +0 -126
  227. data/test/resources/vodataservice/unittest_v1_0.rb +0 -151
  228. data/test/resources/voregistry/authority_resource_v0_3.xml +0 -20
  229. data/test/resources/voregistry/authority_resource_v1_0.xml +0 -82
  230. data/test/resources/voregistry/registry_service_v0_3.xml +0 -20
  231. data/test/resources/voregistry/registry_service_v1_0.xml +0 -107
  232. data/test/resources/voregistry/unittest_v0_3.rb +0 -31
  233. data/test/resources/voregistry/unittest_v1_0.rb +0 -34
  234. data/test/resources/voresource/organisation_resource_v1_0.xml +0 -90
  235. data/test/resources/voresource/resource_organisation_v0_10.xml +0 -22
  236. data/test/resources/voresource/resource_service_v0_10.xml +0 -19
  237. data/test/resources/voresource/resource_v0_10.xml +0 -19
  238. data/test/resources/voresource/resource_v1_0.xml +0 -79
  239. data/test/resources/voresource/service_resource_v1_0.xml +0 -91
  240. data/test/resources/voresource/unittest_v0_10.rb +0 -61
  241. data/test/resources/voresource/unittest_v0_9.rb +0 -4
  242. data/test/resources/voresource/unittest_v1_0.rb +0 -190
  243. data/test/services/gestalt/unittest.rb +0 -74
  244. data/test/services/registry/unittest.rb +0 -34
  245. data/test/services/resolver/unittest.rb +0 -38
  246. data/test/simple/unittest.rb +0 -46
  247. data/test/spacetime/unittest.rb +0 -39
  248. data/test/stc/catalog_entry_location_v1_20.xml +0 -112
  249. data/test/stc/obs_data_location_v1_20.xml +0 -108
  250. data/test/stc/search_location_v1_20.xml +0 -54
  251. data/test/stc/stc_resource_profile_v1_20.xml +0 -60
  252. data/test/stc/unittest_v1_20.rb +0 -620
  253. data/test/voevent/unittest_v1_0.rb +0 -79
  254. data/test/voevent/unittest_v1_1.rb +0 -70
  255. data/test/voevent/voevent_v1_0.xml +0 -96
  256. data/test/votables/test.vot +0 -366
  257. data/test/votables/unittest.rb +0 -54
@@ -1,354 +0,0 @@
1
- # A set of classes designed to read and manipulate
2
- # especific VOTables[http://www.ivoa.net/Documents/latest/VOT.html].
3
- # This class represents a INT VOTable.
4
-
5
- require 'voruby/votables/votable'
6
-
7
- module VORuby
8
- module VOTables
9
-
10
- module VOTable
11
- class INTVOTable < VOTable
12
-
13
- # Our object's contructor
14
- # [_votable:_]
15
- # The VOTable object
16
- def initialize(votable)
17
- super(votable.id, votable.version, votable.description,
18
- votable.definitions, votable.coosys, votable.params,
19
- votable.info, votable.resources)
20
- end
21
-
22
- # Find a field in INT configuration file given a key.
23
- # Returns a hash with the field's attributes
24
- # [_key_:]
25
- # The key indexing on field's attribute
26
- def find_field_in_conf_file(key)
27
- int_field = {'id'=> nil, 'name'=> nil, 'ucd'=> nil}
28
-
29
- if key != nil
30
- INT_ARCHIVE_CONFIG.each do |archive|
31
- archive['votable_fields'].each do |field|
32
- if field['key'] == key
33
- int_field['id'] = field['id'] if field['id'] != 'nil'
34
- int_field['name'] = field['name'] if field['name'] != 'nil'
35
- int_field['ucd'] = field['ucd'] if field['ucd'] != 'nil'
36
- break
37
- end
38
- end
39
- end
40
- end
41
- return int_field
42
- end
43
-
44
- # Find the column number(s) associated with the
45
- # VOX:imageAccessReference UCD.
46
- # Returns a list of column positions.
47
- def image_access_reference_columns()
48
- ucd_access = find_field_in_conf_file('VOX:Image_AccessReference')['ucd']
49
-
50
- if find_columns(ucd_access).first != nil
51
- find_columns(ucd_access).first
52
- end
53
- end
54
-
55
- def image_ra_columns
56
- ucd_ra = find_field_in_conf_file('POS_EQ_RA_MAIN')['ucd']
57
-
58
- if find_columns(ucd_ra).first != nil
59
- find_columns(ucd_ra).first
60
- end
61
- end
62
-
63
- def image_dec_columns
64
- ucd_dec = find_field_in_conf_file('POS_EQ_DEC_MAIN')['ucd']
65
-
66
- if find_columns(ucd_dec).first != nil
67
- find_columns(ucd_dec).first
68
- end
69
- end
70
-
71
- def image_filter_columns
72
- ucd_filter = find_field_in_conf_file('VOX:BandPass_ID')['ucd']
73
-
74
- if find_columns(ucd_filter).first != nil
75
- find_columns(ucd_filter).first
76
- end
77
- end
78
-
79
- def image_date_obs_columns
80
- #ucd_date_obs = find_field_in_conf_file('')['ucd']
81
-
82
- #if find_columns(ucd_date_obs).first != nil
83
- # find_columns(ucd_date_obs).first
84
- #end
85
- end
86
-
87
- def image_telescope_columns
88
- #ucd_telescope = find_field_in_conf_file('')['ucd']
89
-
90
- #if find_columns(ucd_telescope).first != nil
91
- # find_columns(ucd_telescope).first
92
- #end
93
- end
94
-
95
- def image_survey_columns
96
- ucd_survey = find_field_in_conf_file('VOX:Image_title')['ucd']
97
-
98
- if find_columns(ucd_survey).first != nil
99
- find_columns(ucd_survey).first
100
- end
101
- end
102
-
103
- def image_instrument_columns
104
- ucd_instrument = find_field_in_conf_file('VOX:INST_ID')['ucd']
105
-
106
- if find_columns(ucd_instrument).first != nil
107
- find_columns(ucd_instrument).first
108
- end
109
- end
110
-
111
- def image_sky_columns
112
- #ucd_sky = find_field_in_conf_file('')['ucd']
113
-
114
- #if find_columns(ucd_sky).first != nil
115
- # find_columns(ucd_sky).first
116
- #end
117
- end
118
-
119
- def image_zeropoint_columns
120
- #ucd_zeropoint = find_field_in_conf_file('')['ucd']
121
-
122
- #if find_columns(ucd_zeropoint).first != nil
123
- # find_columns(ucd_zeropoint).first
124
- #end
125
- end
126
-
127
- def image_seeing_columns
128
- #ucd_seeing = find_field_in_conf_file('')['ucd']
129
-
130
- #if find_columns(ucd_seeing).first != nil
131
- # find_columns(ucd_seeing).first
132
- #end
133
- end
134
-
135
- def image_depth_columns
136
- #ucd_depth = find_field_in_conf_file('')['ucd']
137
-
138
- #if find_columns(ucd_depth).first != nil
139
- # find_columns(ucd_depth).first
140
- #end
141
- end
142
-
143
- def image_exptime_columns
144
- #ucd_exptime = find_field_in_conf_file('')['ucd']
145
-
146
- #if find_columns(ucd_exptime).first != nil
147
- # find_columns(ucd_exptime).first
148
- #end
149
- end
150
-
151
- # Create the headers for HTML table
152
- # [_access_ref_index_:]
153
- # A valid SIA VOTable will only ever have one VOX:Image_AccessReference.
154
- # [_options_:]
155
- #
156
- def create_headers(access_ref_index, options)
157
- thead, thead_2row = create_header_cart_links(options)
158
-
159
- if options[:infer_access_ref] and access_ref_index
160
- thead << "<th>#{options[:access_ref_header_label]}</th>\n"
161
- thead_2row.push('&nbsp;')
162
- end
163
-
164
- col_count = 0
165
- fields(options[:res], options[:tbl]).each do |field|
166
- field_archive = find_field_in_conf_file(field.ucd.value())
167
- field_ucd = field_archive['ucd']
168
- if options[:infer_access_ref] and col_count == access_ref_index
169
- thead_2row[1] = field_ucd if field_ucd != 'nil'
170
- else
171
- thead << "<th>#{field_archive['name']}</th>\n"
172
- if field_ucd != 'nil'
173
- thead_2row.push(field_ucd)
174
- else
175
- thead_2row.push('&nbsp')
176
- end
177
- end
178
- col_count += 1
179
- end
180
-
181
- thead << " </tr>\n"
182
-
183
- thead << "<tr>\n"
184
- thead_2row.each do |h|
185
- thead << "<th>#{h}</th>\n"
186
- end
187
- thead << "</tr>\n"
188
-
189
- thead << "</thead>"
190
-
191
- return thead
192
- end
193
-
194
- # Creates the cart parameters
195
- # [_cart_params:_]
196
- #
197
- # [_columns:_]
198
- #
199
- def create_item_cart_params(cart_params, columns)
200
- link_ref_array = []
201
-
202
- cart_params.each do |key, value|
203
- link_ref_array.push("#{key}=#{value}")
204
- end
205
-
206
- access_ref_index = image_access_reference_columns()
207
- link_ref_array.push("resource=#{CGI.escape(columns[access_ref_index].value).to_s}") if access_ref_index
208
- ra_index = image_ra_columns()
209
- link_ref_array.push("rac=#{columns[ra_index].value.to_s}") if ra_index
210
- dec_index = image_dec_columns()
211
- link_ref_array.push("decc=#{columns[dec_index].value.to_s}") if dec_index
212
- filter_index = image_filter_columns()
213
- link_ref_array.push("filter=#{columns[filter_index].value.to_s}") if filter_index
214
- date_obs_index = image_date_obs_columns()
215
- link_ref_array.push("date_obs=#{columns[date_obs_index].value.to_s}") if date_obs_index
216
- teles_index = image_telescope_columns()
217
- link_ref_array.push("telescop=#{columns[teles_index].value.to_s}") if teles_index
218
- survey_index = image_survey_columns()
219
- link_ref_array.push("survey=#{columns[survey_index].value.to_s}") if survey_index
220
- instrum_index = image_instrument_columns()
221
- link_ref_array.push("instrument=#{columns[instrum_index].value.to_s}") if instrum_index
222
- sky_index = image_sky_columns()
223
- link_ref_array.push("sky=#{columns[sky_index].value.to_s}") if sky_index
224
- zerop_index = image_zeropoint_columns()
225
- link_ref_array.push("zeropoint=#{columns[zerop_index].value.to_s}") if zerop_index
226
- seeing_index = image_seeing_columns()
227
- link_ref_array.push("seeing=#{columns[seeing_index].value.to_s}") if seeing_index
228
- depth_index = image_depth_columns()
229
- link_ref_array.push("depth=#{columns[depth_index].value.to_s}") if depth_index
230
- exptime_index = image_exptime_columns()
231
- link_ref_array.push("exptime=#{columns[exptime_index].value.to_s}") if exptime_index
232
-
233
- return link_ref_array.join('&')
234
- end
235
-
236
- # Create body for HTML table
237
- # [_access_ref_index_:]
238
- # A valid SIA VOTable will only ever have one VOX:Image_AccessReference.
239
- # [_options_:]
240
- #
241
- def create_body(access_ref_index, options)
242
- tbody = "<tbody class=\"#{options[:body_class]}\" align=\"center\">\n"
243
- row_count = 0
244
- rows_data = rows(options[:res], options[:tbl])
245
- if rows_data
246
- rows_data.each do |tr|
247
- tbody << "<tr class=\"#{options[:row_classes][row_count % 2]}\">\n"
248
-
249
- # Specially mark up the first column to link to the image.
250
- columns = tr.tds()
251
-
252
- if options[:infer_add_to_cart_ref] and access_ref_index
253
- tbody << "<td><input type=\"checkbox\" " +
254
- "id=\"checkbox_add_#{options[:cart_params][:archive]}_#{row_count.to_s}\" " +
255
- "value=\"#{create_item_cart_params(options[:cart_params], columns)}\"/></td>\n"
256
- end
257
-
258
- if options[:infer_access_ref] and access_ref_index
259
- tbody << "<td><a href=\"#{columns[access_ref_index].value}\">#{options[:access_ref_link_label]}</a></td>\n"
260
- end
261
-
262
- col_count = 0
263
- #ra_index = image_ra_columns()
264
- #dec_index = image_dec_columns()
265
- columns.each do |td|
266
- if col_count != access_ref_index
267
- #if ra_index and col_count == ra_index
268
- # tbody << "<td>#{convert_ra_to_degrees(td.value)}</td>\n"
269
- #elsif dec_index and col_count == dec_index
270
- # tbody << "<td>#{convert_dec_to_degrees(td.value)}</td>\n"
271
- #else
272
- tbody << "<td>#{td.value}</td>\n"
273
- #end
274
- end
275
- col_count += 1
276
- end
277
-
278
- tbody << "</tr>\n"
279
- row_count += 1
280
- end
281
- end
282
- tbody << "</tbody>"
283
-
284
- return tbody
285
- end
286
-
287
- # Convert the specified table in the specified resource into an HTML
288
- # table.
289
- # [_options_:]
290
- # The options for this VOTable.
291
- def to_html(options={})
292
- # The ID to assign to the HTML table as a whole.
293
- options[:id] = options[:id] || "#{votable}_#{Time.now.to_i}_#{rand(10000)}"
294
-
295
- options[:infer_add_to_cart_ref] = true if options[:infer_add_to_cart_ref] == nil
296
- options[:add_to_cart_header_label] = options[:add_to_cart_header_label] || 'Add to Cart'
297
- options[:cart_params] = {} if options[:cart_params] == nil
298
- #options[:add_to_cart_url] = options[:add_to_cart_url] || nil
299
-
300
- options[:throbber_src] = options[:throbber_src] || '/images/general/indicator.gif'
301
- options[:throbber_size] = options[:throbber_size] || '16x16'
302
- options[:throbber_class] = options[:throbber_class] || 'throbber'
303
- options[:throbber_id] = options[:throbber_id] || "#{options[:id]}_throbber_id"
304
-
305
- options[:flash_notice_class] = options[:flash_notice_class] || 'flash_notice'
306
- options[:flash_notice_id] = options[:flash_notice_id] || "#{options[:id]}_flash_notice_id"
307
-
308
- # Link the access reference URL associated with a row.
309
- options[:infer_access_ref] = true if options[:infer_access_ref] == nil
310
- #options[:retrieve_link_ref] = options[:retrieve_link_ref] || nil
311
- # For the access reference column, place this value in the header.
312
- options[:access_ref_header_label] = options[:access_ref_header_label] || 'URL'
313
- # For the access reference column, link this word.
314
- options[:access_ref_link_label] = options[:access_ref_link_label] || 'Retrieve'
315
- options[:ssl] = false if options[:ssl] == nil
316
- #options[:resource_link] = options[:resource_link]
317
-
318
- # The resource from which to extract the table in question.
319
- options[:res] = options[:res] || 0
320
- # The table inside the resource from which to extract the rows in question.
321
- options[:tbl] = options[:tbl] || 0
322
-
323
- # The boolean value to show HTML table border
324
- options[:show_border] = false if options[:show_border] == nil
325
- # The class to assign the HTML table as a whole.
326
- options[:table_class] = options[:table_class] || 'votable'
327
- # The class to assign the header of the HTML table.
328
- options[:header_class] = options[:header_class] || 'header'
329
- # The class to assign the body of the HTML table.
330
- options[:body_class] = options[:body_class] || 'body'
331
- # The class to assign the HTML table body rows.
332
- options[:row_classes] = options[:row_classes] || ['row1', 'row2']
333
-
334
- begin
335
- # A valid SIA VOTable will only ever have one VOX:Image_AccessReference.
336
- access_ref_index = image_access_reference_columns()
337
-
338
- return create_votable(create_headers(access_ref_index, options),
339
- create_body(access_ref_index, options),
340
- options)
341
-
342
- rescue Exception => e
343
- title = 'Error...'
344
- message = "VORuby error: #{e.message}<br>#{e.backtrace}"
345
- message << "<br>#{@resources[0].info[0].text().to_s()}" if @resources[0].info[0]
346
- create_message(title, message, options)
347
- end
348
- end
349
-
350
- end
351
- end
352
-
353
- end
354
- end
@@ -1,411 +0,0 @@
1
- module VORuby
2
- module VOTables
3
- module VOTable
4
- require 'xml/libxml'
5
-
6
- module Meta
7
-
8
- class Description
9
- def self.from_xml(node)
10
- return Meta::Description.new(node.to_s)
11
- end
12
- end
13
-
14
- class Definitions
15
- def self.from_xml(node)
16
- systems = []
17
- node.find('COOSYS').each { |sysNode|
18
- systems.push(Meta::CooSys.from_xml(sysNode))
19
- }
20
-
21
- params = []
22
- node.find('PARAM').each { |paramNode|
23
- params.push(Meta::Param.from_xml(paramNode))
24
- }
25
-
26
- return self.new(systems, params)
27
- end
28
- end
29
-
30
- class CooSys
31
- def self.from_xml(node)
32
- id = node['ID']
33
- equinox = Type::AstroYear.new(node['equinox']) if node['equinox']
34
- epoch = Type::AstroYear.new(node['epoch']) if node['epoch']
35
- system = Type::CoordSystemType.new(node['system']) if node['system']
36
-
37
- return self.new(id, equinox, epoch, system)
38
- end
39
- end
40
-
41
- class Link
42
- def self.from_xml(node)
43
- id = node['ID']
44
- content_role = Type::ContentRole.new(node['content-role']) if node['content-role']
45
- content_type = node['content-type']
46
- title = node['title']
47
- value = node['value']
48
- href = Type::AnyURI.new(node['href']) if node['href']
49
- gref = node['gref']
50
- action = Type::AnyURI.new(node['action']) if node['action']
51
-
52
- return self.new(href, value, title, action, id, content_type, content_role, gref)
53
- end
54
- end
55
-
56
- class Values
57
- def self.from_xml(node)
58
- # Attributes
59
- id = node['ID'] if node['ID']
60
- type = Type::ValuesType.new(node['type']) if node['type']
61
- null = node['null'] if node['null']
62
- ref = node['ref'] if node['ref']
63
-
64
- # Elements
65
- min = Meta::Min.from_xml(node.find('MIN').to_a.first) if node.find('MIN').length > 0
66
- max = Meta::Max.from_xml(node.find('MAX').to_a.first) if node.find('MAX').length > 0
67
-
68
- options = []
69
- node.find('OPTION').each { |optNode|
70
- options.push(Meta::Option.from_xml(optNode))
71
- }
72
-
73
- return self.new(min, max, options, id, type, null, ref)
74
- end
75
- end
76
-
77
- class FieldRef
78
- def self.from_xml(node)
79
- ref = node['ref'] if node['ref']
80
-
81
- return self.new(ref)
82
- end
83
- end
84
-
85
- class ParamRef
86
- def self.from_xml(node)
87
- ref = node['ref'] if node['ref']
88
-
89
- return self.new(ref)
90
- end
91
- end
92
-
93
- class Group
94
- def self.from_xml(node)
95
- # Attributes
96
- id = node['ID'] if node['ID']
97
- name = node['name'] if node['name']
98
- ref = node['ref'] if node['ref']
99
- ucd = UCDType.new(node['ucd']) if node['ucd']
100
- utype = node['utype'] if node['utype']
101
-
102
- # Elements
103
- description =
104
- Meta::Description.from_xml(node.find('DESCRIPTION').to_a.first) if node.find('DESCRIPTION').length > 0
105
-
106
- fieldrefs = []
107
- node.find('FIELDref').each { |fref|
108
- fieldrefs.push(Meta::FieldRef.from_xml(fref))
109
- }
110
-
111
- paramrefs = []
112
- node.find('PARAMref').each { |pref|
113
- paramrefs.push(Meta::ParamRef.from_xml(pref))
114
- }
115
-
116
- params = []
117
- node.find('PARAM').each { |param|
118
- params.push(Meta::Param.from_xml(param))
119
- }
120
-
121
- groups = []
122
- node.find('GROUP').each { |group|
123
- groups.push(Meta::Group.from_xml(group))
124
- }
125
-
126
- return self.new(name, ucd, description, fieldrefs, paramrefs, params, groups,
127
- id, ref, utype)
128
- end
129
- end
130
-
131
- class Param
132
- def self.from_xml(node)
133
- # Attributes
134
- id = node['ID'] if node['ID']
135
- unit = node['unit'] if node['unit']
136
- datatype = Type::DataType.new(node['datatype']) if node['datatype']
137
- precision = Type::PrecisionType.new(node['precision']) if node['precision']
138
- width = Type::PositiveInteger.new(node['width'].to_i) if node['width']
139
- ref = node['ref'] if node['ref']
140
- name = node['name'] if node['name']
141
- ucd = Type::UCDType.new(node['ucd']) if node['ucd']
142
- utype = node['utype'] if node['utype']
143
- value = node['value'] if node['value']
144
- arraysize = Type::ArrayDef.new(node['arraysize']) if node['arraysize']
145
-
146
- # Elements
147
- description =
148
- Meta::Description.from_xml(node.find('DESCRIPTION').to_a.first) if node.find('DESCRIPTION').length > 0
149
- values =
150
- Meta::Values.from_xml(node.find('VALUES').to_a.first) if node.find('VALUES').length > 0
151
-
152
- links = []
153
- node.find('LINK').each { |linkNode|
154
- links.push(Meta::Link.from_xml(linkNode))
155
- }
156
-
157
- return self.new(name, datatype, value, ucd, unit, description, values, links,
158
- id, precision, utype, width, ref, arraysize)
159
- end
160
- end
161
-
162
- class Field
163
- def self.from_xml(node)
164
- # Attributes
165
- id = node['ID'] if node['ID']
166
- unit = node['unit'] if node['unit']
167
- datatype = Type::DataType.new(node['datatype']) if node['datatype']
168
- precision = Type::PrecisionType.new(node['precision']) if node['precision']
169
- width = Type::PositiveInteger.new(node['width'].to_i) if node['width']
170
- ref = node['ref'] if node['ref']
171
- name = node['name'] if node['name']
172
- ucd = Type::UCDType.new(node['ucd']) if node['ucd']
173
- arraysize = Type::ArrayDef.new(node['arraysize']) if node['arraysize']
174
- type = Type::FieldType.new(node['type']) if node['type']
175
- utype = node['utype'] if node['utype']
176
-
177
- # Elements
178
- description =
179
- Meta::Description.from_xml(node.find('DESCRIPTION').to_a.first) if node.find('DESCRIPTION').length > 0
180
- values =
181
- Meta::Values.from_xml(node.find('VALUES').to_a.first) if node.find('VALUES').length > 0
182
-
183
- links = []
184
- node.find('LINK').each { |link|
185
- links.push(Meta::Link.from_xml(link))
186
- }
187
-
188
- return self.new(name, datatype, ucd, unit, description, values,
189
- links, id, precision, utype, width, ref, arraysize, type)
190
- end
191
- end
192
-
193
- class Info
194
- def self.from_xml(node)
195
- id = node['ID']
196
- name = node['name']
197
- value = node['value']
198
-
199
- return self.new(name, value, id)
200
- end
201
- end
202
-
203
- class Table
204
- def self.from_xml(node)
205
- # Attributes
206
- id = node['ID'] if node['ID']
207
- name = node['name'] if node['name']
208
- ref = node['ref'] if node['ref']
209
- ucd = UCDType.new(node['ucd']) if node['ucd']
210
- utype = node['utype'] if node['utype']
211
- nrows = NonNegativeInteger.new(node['nrows'].to_i) if node['nrows']
212
-
213
- # Elements
214
- description =
215
- Meta::Description.from_xml(node.find('DESCRIPTION').to_a.first) if node.find('DESCRIPTION').length > 0
216
-
217
- fields = []
218
- node.find('FIELD').each { |fieldNode|
219
- fields.push(Meta::Field.from_xml(fieldNode))
220
- }
221
-
222
- params = []
223
- node.find('PARAM').each { |paramNode|
224
- params.push(Meta::Param.from_xml(paramNode))
225
- }
226
-
227
- groups = []
228
- node.find('GROUP').each { |groupNode|
229
- params.push(Meta::Group.from_xml(groupNode))
230
- }
231
-
232
- links = []
233
- node.find('LINK').each { |linkNode|
234
- params.push(Meta::Link.from_xml(linkNode))
235
- }
236
-
237
- data = Data::Data.from_xml(node.find('DATA').to_a.first) if node.find('DATA').length > 0
238
-
239
- return self.new(name, id, ucd, utype, ref, nrows, description,
240
- fields, params, groups, links, data)
241
- end
242
- end
243
-
244
- class Resource
245
- def self.from_xml(node)
246
- # Attributes
247
- name = node['name'] if node['name']
248
- id = node['ID'] if node['ID']
249
- utype = node['utype'] if node['utype']
250
- type = Type::ResourceType.new(node['type']) if node['type']
251
-
252
- # Elements
253
- description =
254
- Meta::Description.from_xml(node.find('DESCRIPTION').to_a.first) if node.find('DESCRIPTION').length > 0
255
-
256
- info = []
257
- node.find('INFO').each { |infoNode|
258
- info.push(Meta::Info.from_xml(infoNode))
259
- }
260
-
261
- systems = []
262
- node.find('COOSYS').each { |sysNode|
263
- systems.push(Meta::CooSys.from_xml(sysNode))
264
- }
265
-
266
- params = []
267
- node.find('PARAM').each { |paramNode|
268
- params.push(Meta::Param.from_xml(paramNode))
269
- }
270
-
271
- resources = []
272
- node.find('RESOURCE').each { |resNode|
273
- resources.push(Meta::Resource.from_xml(resNode))
274
- }
275
-
276
- links = []
277
- node.find('LINK').each { |linkNode|
278
- links.push(Meta::Link.from_xml(linkNode))
279
- }
280
-
281
- tables = []
282
- node.find('TABLE').each { |tblNode|
283
- tables.push(Meta::Table.from_xml(tblNode))
284
- }
285
-
286
- return self.new(name, id, utype, type, description,
287
- info, systems, params, links, tables, resources)
288
- end
289
- end
290
-
291
- class Option
292
- def self.from_xml(node)
293
- value = node['value'] if node['value']
294
- name = node['name'] if node['name']
295
-
296
- options = []
297
- node.find('OPTION').each { |optNode|
298
- options.push(Meta::Option.from_xml(optNode))
299
- }
300
-
301
- return self.new(value, name, options)
302
- end
303
- end
304
-
305
- class Max
306
- def self.from_xml(node)
307
- value = node['node'] if node['node']
308
- inclusive = Type::YesNo.new(node['inclusive']) if node['inclusive']
309
-
310
- return self.new(value, inclusive)
311
- end
312
- end
313
-
314
- class Min
315
- def self.from_xml(node)
316
- value = node['node'] if node['node']
317
- inclusive = Type::YesNo.new(node['inclusive']) if node['inclusive']
318
-
319
- return self.new(value, inclusive)
320
- end
321
- end
322
-
323
- end
324
-
325
- module Data
326
-
327
- class Stream
328
- def self.from_xml(node)
329
- href = Type::AnyURI.new(node['href']) if node['href']
330
- expires = DateTime.parse(node['expires']) if node['expires']
331
- rights = node['rights']
332
- type = Type::StreamType.new(node['type']) if node['type']
333
- actuate = Actuate.new(node['actuate']) if node['actuate']
334
- encoding = Type::EncodingType.new(node['encoding']) if node['encoding']
335
-
336
- return self.new(href, expires, rights, type, actuate, encoding)
337
- end
338
- end
339
-
340
- class BinaryStream
341
- def self.from_xml(node)
342
- stream = Stream.from_xml(node.find('STREAM').to_a.first)
343
-
344
- return self.new(stream)
345
- end
346
- end
347
-
348
- class FITSStream
349
- def self.from_xml(node)
350
- stream = Stream.from_xml(node.find('STREAM').to_a.first)
351
- extnum = Type::PositiveInteger.new(node['extnum'].to_i) if node['extnum']
352
-
353
- return self.new(stream, extnum)
354
- end
355
- end
356
-
357
- class TD
358
- def self.from_xml(node)
359
- value = node.to_s
360
- encoding = Type::EncodingType.new(node['encoding']) if node['encoding']
361
-
362
- return self.new(value, encoding)
363
- end
364
- end
365
-
366
- class TR
367
- def self.from_xml(node)
368
- tds = []
369
- node.find('TD').each { |tdNode|
370
- tds.push(TD.from_xml(tdNode))
371
- }
372
-
373
- return self.new(tds)
374
- end
375
- end
376
-
377
- class TableData
378
- def self.from_xml(node)
379
- trs = []
380
- node.find('TR').each { |trNode|
381
- trs.push(TR.from_xml(trNode))
382
- }
383
-
384
- return self.new(trs)
385
- end
386
- end
387
-
388
- class Data
389
- def self.from_xml(node)
390
- format = nil
391
- node.find('FITS').each { |fnode|
392
- format = FITSStream.from_xml(fnode)
393
- }
394
-
395
- node.find('BINARY').each { |bnode|
396
- format = BinaryStream.from_xml(bode)
397
- }
398
-
399
- node.find('TABLEDATA').each { |tnode|
400
- format = TableData.from_xml(tnode)
401
- }
402
-
403
- return self.new(format)
404
- end
405
- end
406
-
407
- end
408
- end
409
-
410
- end
411
- end