voruby 1.1.1 → 2.0.0
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/Rakefile.rb +107 -224
- data/lib/misc.rb +1 -0
- data/lib/misc/misc.rb +60 -0
- data/lib/misc/propertyfile.rb +31 -0
- data/lib/symphony.rb +1 -0
- data/lib/symphony/symphony.rb +247 -0
- data/lib/voruby.rb +186 -0
- data/lib/voruby/active_votable/active_votable.rb +468 -347
- data/lib/voruby/adql/1.0/adql.rb +2418 -0
- data/lib/voruby/adql/support.rb +2 -0
- data/lib/voruby/misc.rb +351 -0
- data/lib/voruby/misc/connection_monitor.rb +97 -0
- data/lib/voruby/misc/libxml_ext.rb +121 -0
- data/lib/voruby/misc/rexml_ext.rb +223 -0
- data/lib/voruby/resolver/resolver.rb +12 -0
- data/lib/voruby/resolver/sesame.rb +299 -0
- data/lib/voruby/sky_query/sky_query.rb +192 -0
- data/lib/voruby/stc/1.10/coords.rb +2272 -0
- data/lib/voruby/stc/1.10/region.rb +892 -0
- data/lib/voruby/stc/1.10/stc.rb +3271 -0
- data/lib/voruby/stc/1.30/stc.rb +8666 -0
- data/lib/voruby/stc/support.rb +2 -0
- data/lib/voruby/ucd/ucd.rb +173 -0
- data/lib/voruby/voevent/1.1/voevent.rb +1124 -0
- data/lib/voruby/voevent/support.rb +5 -0
- data/lib/voruby/votable/1.0/votable.rb +1807 -0
- data/lib/voruby/votable/1.1/votable.rb +2100 -0
- data/lib/voruby/votable/votable.rb +305 -0
- data/lib/voruby/wesix/wesix.rb +491 -0
- data/lib/voruby/xlink/1.2/xlink.rb +21 -0
- data/test/voruby/active_votable/complex.vot +60 -0
- data/test/voruby/active_votable/error.vot +6 -0
- data/test/voruby/active_votable/large.vot +130040 -0
- data/test/voruby/active_votable/simple1.vot +38 -0
- data/test/voruby/active_votable/simple2.vot +38 -0
- data/test/voruby/active_votable/test.rb +193 -0
- data/test/voruby/adql/1.0/adql-alias.sql +1 -0
- data/test/voruby/adql/1.0/adql-alias.xml +26 -0
- data/test/voruby/adql/1.0/adql-avg.sql +1 -0
- data/test/voruby/adql/1.0/adql-avg.xml +31 -0
- data/test/voruby/adql/1.0/adql-circle.sql +1 -0
- data/test/voruby/adql/1.0/adql-circle.xml +46 -0
- data/test/voruby/adql/1.0/adql-expr.sql +1 -0
- data/test/voruby/adql/1.0/adql-expr.xml +34 -0
- data/test/voruby/adql/1.0/adql-function.sql +1 -0
- data/test/voruby/adql/1.0/adql-function.xml +41 -0
- data/test/voruby/adql/1.0/adql-group.sql +1 -0
- data/test/voruby/adql/1.0/adql-group.xml +51 -0
- data/test/voruby/adql/1.0/adql-having.sql +1 -0
- data/test/voruby/adql/1.0/adql-having.xml +25 -0
- data/test/voruby/adql/1.0/adql-like.sql +1 -0
- data/test/voruby/adql/1.0/adql-like.xml +17 -0
- data/test/voruby/adql/1.0/adql-order.sql +1 -0
- data/test/voruby/adql/1.0/adql-order.xml +37 -0
- data/test/voruby/adql/1.0/adql-simple.sql +1 -0
- data/test/voruby/adql/1.0/adql-simple.xml +12 -0
- data/test/voruby/adql/1.0/adql-top.sql +1 -0
- data/test/voruby/adql/1.0/adql-top.xml +33 -0
- data/test/voruby/adql/1.0/test.rb +2220 -0
- data/test/voruby/misc/test.rb +32 -0
- data/test/voruby/resolver/sesame/test.rb +56 -0
- data/test/voruby/sky_query/test.rb +107 -0
- data/test/voruby/stc/1.10/coords_test.rb +3704 -0
- data/test/voruby/stc/1.10/region_test.rb +993 -0
- data/test/voruby/stc/1.10/stc-catalog-entry-location.xml +112 -0
- data/test/voruby/stc/1.10/stc-obs-data-location.xml +126 -0
- data/test/voruby/stc/1.10/stc-region-circle.xml +5 -0
- data/test/voruby/stc/1.10/stc-region-convex.xml +11 -0
- data/test/voruby/stc/1.10/stc-region-convexhull.xml +5 -0
- data/test/voruby/stc/1.10/stc-region-ellipse.xml +7 -0
- data/test/voruby/stc/1.10/stc-region-intersection.xml +25 -0
- data/test/voruby/stc/1.10/stc-region-negation.xml +7 -0
- data/test/voruby/stc/1.10/stc-region-polygon.xml +13 -0
- data/test/voruby/stc/1.10/stc-region-sector.xml +6 -0
- data/test/voruby/stc/1.10/stc-region-union.xml +25 -0
- data/test/voruby/stc/1.10/stc-resource-profile.xml +60 -0
- data/test/voruby/stc/1.10/stc-search-location.xml +54 -0
- data/test/voruby/stc/1.10/stc_test.rb +4626 -0
- data/test/voruby/stc/1.30/stc-catalog-entry-location.xml +210 -0
- data/test/voruby/stc/1.30/stc-obs-data-location-arecibo.xml +353 -0
- data/test/voruby/stc/1.30/stc-obs-data-location-fits.xml +250 -0
- data/test/voruby/stc/1.30/stc-obs-data-location-xlink.xml +63 -0
- data/test/voruby/stc/1.30/stc-obs-data-location.xml +216 -0
- data/test/voruby/stc/1.30/stc-resource-profile-unusual-ref-pos.xml +39 -0
- data/test/voruby/stc/1.30/stc-resource-profile.xml +129 -0
- data/test/voruby/stc/1.30/stc-search-location-arecibo.xml +86 -0
- data/test/voruby/stc/1.30/stc-search-location.xml +101 -0
- data/test/voruby/stc/1.30/test.rb +6274 -0
- data/test/voruby/ucd/test.rb +48 -0
- data/test/voruby/voevent/1.1/test.rb +812 -0
- data/test/{voevent/voevent_v1_1.xml → voruby/voevent/1.1/voevent.xml} +2 -2
- data/test/voruby/voregistry/0.3/test.rb +137 -0
- data/test/voruby/votable/1.0/test.rb +714 -0
- data/test/voruby/votable/1.0/votable.basic.xml +660 -0
- data/test/voruby/votable/1.0/votable.html +86 -0
- data/test/voruby/votable/1.0/votable.ns.xml +56 -0
- data/test/voruby/votable/1.1/test.rb +785 -0
- data/test/voruby/votable/1.1/votable.basic.xml +38 -0
- data/test/voruby/votable/1.1/votable.html +86 -0
- data/test/voruby/votable/1.1/votable.ns.xml +56 -0
- data/test/voruby/votable/test.rb +15 -0
- data/test/voruby/wesix/test.rb +268 -0
- data/test/voruby/wesix/testr.fits +28 -0
- metadata +234 -247
- data/REQUIREMENTS +0 -6
- data/lib/voruby/active_votable/loader.rb +0 -5
- data/lib/voruby/adql/adql.rb +0 -2787
- data/lib/voruby/adql/ext.rb +0 -14
- data/lib/voruby/adql/loader.rb +0 -6
- data/lib/voruby/adql/operations.rb +0 -54
- data/lib/voruby/adql/parser.rb +0 -160
- data/lib/voruby/adql/transforms.rb +0 -573
- data/lib/voruby/ext.rb +0 -17
- data/lib/voruby/loader.rb +0 -4
- data/lib/voruby/misc/propertyfile.rb +0 -36
- data/lib/voruby/plastic/applications.rb +0 -174
- data/lib/voruby/plastic/constants.rb +0 -30
- data/lib/voruby/plastic/loader.rb +0 -10
- data/lib/voruby/plastic/plastic.rb +0 -1
- data/lib/voruby/resources/conesearch/conesearch.rb +0 -9
- data/lib/voruby/resources/conesearch/conesearch_v0_2.rb +0 -55
- data/lib/voruby/resources/conesearch/conesearch_v0_3.rb +0 -50
- data/lib/voruby/resources/conesearch/conesearch_v1_0.rb +0 -72
- data/lib/voruby/resources/conesearch/loader.rb +0 -4
- data/lib/voruby/resources/loader.rb +0 -50
- data/lib/voruby/resources/nodes.rb +0 -190
- data/lib/voruby/resources/openskynode/loader.rb +0 -4
- data/lib/voruby/resources/openskynode/openskynode.rb +0 -9
- data/lib/voruby/resources/openskynode/openskynode_v0_1.rb +0 -54
- data/lib/voruby/resources/sia/loader.rb +0 -5
- data/lib/voruby/resources/sia/sia.rb +0 -9
- data/lib/voruby/resources/sia/sia_v0_6.rb +0 -90
- data/lib/voruby/resources/sia/sia_v0_7.rb +0 -89
- data/lib/voruby/resources/sia/sia_v1_0.rb +0 -122
- data/lib/voruby/resources/stsci.rb +0 -59
- data/lib/voruby/resources/vodataservice/coverage_v0_2.rb +0 -195
- data/lib/voruby/resources/vodataservice/coverage_v0_3.rb +0 -158
- data/lib/voruby/resources/vodataservice/loader.rb +0 -5
- data/lib/voruby/resources/vodataservice/vodataservice.rb +0 -9
- data/lib/voruby/resources/vodataservice/vodataservice_v0_4.rb +0 -189
- data/lib/voruby/resources/vodataservice/vodataservice_v0_5.rb +0 -163
- data/lib/voruby/resources/vodataservice/vodataservice_v1_0.rb +0 -221
- data/lib/voruby/resources/voregistry/loader.rb +0 -4
- data/lib/voruby/resources/voregistry/voregistry.rb +0 -9
- data/lib/voruby/resources/voregistry/voregistry_v0_2.rb +0 -40
- data/lib/voruby/resources/voregistry/voregistry_v0_3.rb +0 -30
- data/lib/voruby/resources/voregistry/voregistry_v1_0.rb +0 -86
- data/lib/voruby/resources/voresource/loader.rb +0 -17
- data/lib/voruby/resources/voresource/voresource.rb +0 -9
- data/lib/voruby/resources/voresource/voresource_v0_10.rb +0 -327
- data/lib/voruby/resources/voresource/voresource_v0_9.rb +0 -405
- data/lib/voruby/resources/voresource/voresource_v1_0.rb +0 -230
- data/lib/voruby/services/ext.rb +0 -11
- data/lib/voruby/services/gestalt/footprint.rb +0 -95
- data/lib/voruby/services/gestalt/wcs_fixer.rb +0 -105
- data/lib/voruby/services/gestalt/wesix.rb +0 -155
- data/lib/voruby/services/loader.rb +0 -7
- data/lib/voruby/services/registry/registry.rb +0 -53
- data/lib/voruby/services/resolver/resolver.rb +0 -35
- data/lib/voruby/services/schema/schema.rb +0 -644
- data/lib/voruby/sesame/loader.rb +0 -6
- data/lib/voruby/sesame/sesame_v1_0.rb +0 -64
- data/lib/voruby/simple/loader.rb +0 -6
- data/lib/voruby/simple/parameters.rb +0 -196
- data/lib/voruby/simple/sap.rb +0 -446
- data/lib/voruby/spacetime/loader.rb +0 -3
- data/lib/voruby/spacetime/spacetime.rb +0 -607
- data/lib/voruby/stc/coords_v1_20.rb +0 -900
- data/lib/voruby/stc/loader.rb +0 -55
- data/lib/voruby/stc/region_v1_20.rb +0 -274
- data/lib/voruby/stc/stc_v1_20.rb +0 -1196
- data/lib/voruby/util.rb +0 -27
- data/lib/voruby/voevent/loader.rb +0 -7
- data/lib/voruby/voevent/voevent_v1_0.rb +0 -213
- data/lib/voruby/voevent/voevent_v1_1.rb +0 -196
- data/lib/voruby/votables/chandra.rb +0 -373
- data/lib/voruby/votables/data.rb +0 -179
- data/lib/voruby/votables/galex.rb +0 -377
- data/lib/voruby/votables/int.rb +0 -354
- data/lib/voruby/votables/libxml_parser.rb +0 -411
- data/lib/voruby/votables/libxml_votable.rb +0 -67
- data/lib/voruby/votables/loader.rb +0 -10
- data/lib/voruby/votables/meta.rb +0 -763
- data/lib/voruby/votables/misc.rb +0 -51
- data/lib/voruby/votables/nsa.rb +0 -410
- data/lib/voruby/votables/rexml_parser.rb +0 -408
- data/lib/voruby/votables/rexml_votable.rb +0 -67
- data/lib/voruby/votables/sdss.rb +0 -356
- data/lib/voruby/votables/transforms.rb +0 -388
- data/lib/voruby/votables/tree.rb +0 -45
- data/lib/voruby/votables/types.rb +0 -391
- data/lib/voruby/votables/votable.rb +0 -687
- data/test/active_votable/database.yml +0 -6
- data/test/active_votable/test.vot +0 -168492
- data/test/active_votable/unittest.rb +0 -41
- data/test/adql/test1.adql +0 -49
- data/test/adql/test2.adql +0 -51
- data/test/adql/test3.adql +0 -81
- data/test/adql/test4.adql +0 -53
- data/test/adql/test5.adql +0 -55
- data/test/adql/test6.adql +0 -18
- data/test/adql/test7.adql +0 -48
- data/test/adql/unittest.rb +0 -1672
- data/test/plastic/test.rb +0 -44
- data/test/plastic/test.vot +0 -5385
- data/test/plastic/unittest.rb +0 -66
- data/test/resources/conesearch/conesearch_v0_3.xml +0 -31
- data/test/resources/conesearch/conesearch_v1_0.xml +0 -86
- data/test/resources/conesearch/unittest_v0_3.rb +0 -22
- data/test/resources/conesearch/unittest_v1_0.rb +0 -24
- data/test/resources/openskynode/open_sky_node_v0_1.xml +0 -32
- data/test/resources/openskynode/unittest_v0_1.rb +0 -31
- data/test/resources/sia/simple_image_access_v0_7.xml +0 -36
- data/test/resources/sia/simple_image_access_v1_0.xml +0 -122
- data/test/resources/sia/unittest_v0_7.rb +0 -24
- data/test/resources/sia/unittest_v1_0.rb +0 -29
- data/test/resources/stsci.xml +0 -336
- data/test/resources/unittest_stsci.rb +0 -25
- data/test/resources/vodataservice/catalog_service_resource_v1_0.xml +0 -128
- data/test/resources/vodataservice/data_collection_resource_v0_5.xml +0 -54
- data/test/resources/vodataservice/data_collection_resource_v1_0.xml +0 -117
- data/test/resources/vodataservice/data_service_resource_v1_0.xml +0 -115
- data/test/resources/vodataservice/sky_service_resource_v0_10.xml +0 -45
- data/test/resources/vodataservice/table_service_resource_v1_0.xml +0 -122
- data/test/resources/vodataservice/tabular_sky_service_resource_v0_10.xml +0 -60
- data/test/resources/vodataservice/unittest_v0_5.rb +0 -126
- data/test/resources/vodataservice/unittest_v1_0.rb +0 -151
- data/test/resources/voregistry/authority_resource_v0_3.xml +0 -20
- data/test/resources/voregistry/authority_resource_v1_0.xml +0 -82
- data/test/resources/voregistry/registry_service_v0_3.xml +0 -20
- data/test/resources/voregistry/registry_service_v1_0.xml +0 -107
- data/test/resources/voregistry/unittest_v0_3.rb +0 -31
- data/test/resources/voregistry/unittest_v1_0.rb +0 -34
- data/test/resources/voresource/organisation_resource_v1_0.xml +0 -90
- data/test/resources/voresource/resource_organisation_v0_10.xml +0 -22
- data/test/resources/voresource/resource_service_v0_10.xml +0 -19
- data/test/resources/voresource/resource_v0_10.xml +0 -19
- data/test/resources/voresource/resource_v1_0.xml +0 -79
- data/test/resources/voresource/service_resource_v1_0.xml +0 -91
- data/test/resources/voresource/unittest_v0_10.rb +0 -61
- data/test/resources/voresource/unittest_v0_9.rb +0 -4
- data/test/resources/voresource/unittest_v1_0.rb +0 -190
- data/test/services/gestalt/unittest.rb +0 -74
- data/test/services/registry/unittest.rb +0 -34
- data/test/services/resolver/unittest.rb +0 -38
- data/test/simple/unittest.rb +0 -46
- data/test/spacetime/unittest.rb +0 -39
- data/test/stc/catalog_entry_location_v1_20.xml +0 -112
- data/test/stc/obs_data_location_v1_20.xml +0 -108
- data/test/stc/search_location_v1_20.xml +0 -54
- data/test/stc/stc_resource_profile_v1_20.xml +0 -60
- data/test/stc/unittest_v1_20.rb +0 -620
- data/test/voevent/unittest_v1_0.rb +0 -79
- data/test/voevent/unittest_v1_1.rb +0 -70
- data/test/voevent/voevent_v1_0.xml +0 -96
- data/test/votables/test.vot +0 -366
- data/test/votables/unittest.rb +0 -54
data/lib/voruby/votables/tree.rb
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
module VORuby
|
2
|
-
module VOTables
|
3
|
-
module VOTable
|
4
|
-
|
5
|
-
# A VOTable parsed from a file using a DOM-like implementation of
|
6
|
-
# an XML parser. For example:
|
7
|
-
# tree_votable = VOTable::TreeParsedVOTable.new('my_votable.xml', 'rexml')
|
8
|
-
# real_votable = tree_votable.votable # Get the VOTable
|
9
|
-
# As you can see, TreeParsedVOTable is basically a wrapper for
|
10
|
-
# VOTable.
|
11
|
-
class TreeParsedVOTable
|
12
|
-
attr_reader :path, :votable, :lib
|
13
|
-
|
14
|
-
# [_path_:]
|
15
|
-
# The path to a valid VOTable XML file.
|
16
|
-
# [_lib_:]
|
17
|
-
# The underlying library used to parse the XML. Current options are
|
18
|
-
# 'rexml' and 'libxml'. Rexml is Ruby's all-native XML parsing solution
|
19
|
-
# and is therefore shipped with every ruby release. It's very convenient
|
20
|
-
# but slow on large files. Ruby also has available[http://rubyforge.org/projects/xml-tools/]
|
21
|
-
# to it libxml2 bindings which can be installed separately. This is the
|
22
|
-
# recommended configuration for production systems as it is *much* faster.
|
23
|
-
def initialize(path, lib='rexml')
|
24
|
-
@path = path
|
25
|
-
@lib = lib
|
26
|
-
|
27
|
-
@votable = nil
|
28
|
-
if lib == 'libxml' # For a faster alternative, use libxml2
|
29
|
-
require 'voruby/votables/libxml_votable'
|
30
|
-
@votable = LibxmlParsedVOTable.new(@path)
|
31
|
-
else # By default, we'll use Ruby's built-in native XML parser
|
32
|
-
require 'voruby/votables/rexml_votable'
|
33
|
-
@votable = RexmlParsedVOTable.new(@path)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
# Convert the TreeParsedVOTable to a string representation.
|
38
|
-
def to_s
|
39
|
-
"{lib=#{@lib};#{@votable}}"
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
end
|
45
|
-
end
|
@@ -1,391 +0,0 @@
|
|
1
|
-
require 'uri'
|
2
|
-
|
3
|
-
module VORuby
|
4
|
-
module VOTables
|
5
|
-
module VOTable
|
6
|
-
|
7
|
-
# Types of input that go into a VOTable. Typically these enforce restrictions
|
8
|
-
# on string input formats and what not.
|
9
|
-
module Type
|
10
|
-
|
11
|
-
# A class that represents a vanilla-flavoured string.
|
12
|
-
class AnyText
|
13
|
-
attr_reader :value
|
14
|
-
|
15
|
-
# [_txt_:]
|
16
|
-
# The text of the string.
|
17
|
-
def initialize(txt=nil)
|
18
|
-
@value = txt
|
19
|
-
end
|
20
|
-
|
21
|
-
def to_s
|
22
|
-
"{#{@value}}"
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
# A class representing a valid astronomical year.
|
27
|
-
class AstroYear
|
28
|
-
attr_reader :value
|
29
|
-
@@pattern = '^[JB]?[0-9]+([.][0-9]*)?$'
|
30
|
-
|
31
|
-
# [_txt_:]
|
32
|
-
# An astronomical year. The allowed pattern is:
|
33
|
-
# [JB]?[0-9]+([.][0-9]*)?$
|
34
|
-
# i.e. 2001, J2001, B2001, 2001.2 etc.
|
35
|
-
def initialize(txt=nil)
|
36
|
-
if txt and txt.match(@@pattern)
|
37
|
-
@value = txt
|
38
|
-
else
|
39
|
-
raise "Astro year '#{txt}' does not match #{@@pattern}"
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def to_s
|
44
|
-
"{#{@value}}"
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
# A class representing a UCD, including UCD1+.
|
49
|
-
class UCDType
|
50
|
-
attr_reader :value
|
51
|
-
@@pattern = '^[A-Za-z0-9_.:;\-]*$'
|
52
|
-
|
53
|
-
# [_txt_:]
|
54
|
-
# A UCD. The allowed pattern is:
|
55
|
-
# ^[A-Za-z0-9_.:;\-]*$
|
56
|
-
# i.e. phot.mag;em.opt.V, PHOT_JHN_V etc.
|
57
|
-
def initialize(txt=nil)
|
58
|
-
if txt and txt.match(@@pattern)
|
59
|
-
@value = txt
|
60
|
-
else
|
61
|
-
raise "UCD type '#{txt}' does not match #{@@pattern}"
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
def to_s
|
66
|
-
"{#{@value}}"
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
# A class representing a definition of an array size.
|
71
|
-
class ArrayDef
|
72
|
-
attr_reader :value
|
73
|
-
@@pattern = '^([0-9]+x)*[0-9]*[*]?(s\W)?$'
|
74
|
-
|
75
|
-
# [_txt_:]
|
76
|
-
# The text of the array size definition. The allowed pattern is:
|
77
|
-
# ^([0-9]+x)*[0-9]*[*]?(s\W)?$
|
78
|
-
# i.e. *, 64x64x10*, etc.
|
79
|
-
def initialize(txt=nil)
|
80
|
-
if txt and txt.match(@@pattern)
|
81
|
-
@value = txt
|
82
|
-
else
|
83
|
-
raise "Array definition '#{txt}' does not match #{@@pattern}"
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
def to_s
|
88
|
-
"{#{@value}}"
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
# A class representing the encoding method of a document.
|
93
|
-
class EncodingType
|
94
|
-
attr_reader :value
|
95
|
-
@@types = ['gzip', 'base64', 'dynamic', 'none']
|
96
|
-
|
97
|
-
# [_txt_:]
|
98
|
-
# The encoding type. Choices: gzip, base64, dynamic, none.
|
99
|
-
def initialize(txt=nil)
|
100
|
-
txt = 'none' if !txt
|
101
|
-
if @@types.include?(txt)
|
102
|
-
@value = txt
|
103
|
-
else
|
104
|
-
raise "Encoding type '#{txt}' is not valid. Use one of: " +
|
105
|
-
@@types.join(', ')
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
def to_s
|
110
|
-
"{#{@value}}"
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
# A class representing a datatype.
|
115
|
-
class DataType
|
116
|
-
attr_reader :value
|
117
|
-
@@types = ['boolean', 'bit', 'unsignedByte', 'short', 'int',
|
118
|
-
'long', 'char', 'unicodeChar', 'float', 'double',
|
119
|
-
'floatComplex', 'doubleComplex']
|
120
|
-
|
121
|
-
# [_txt_:]
|
122
|
-
# The datatype. Choices: boolean, bit, unsignedByte, short, int
|
123
|
-
# long, char, unicodeChar, float, double, floatComplex, doubleComplex.
|
124
|
-
def initialize(txt=nil)
|
125
|
-
if txt and @@types.include?(txt)
|
126
|
-
@value = txt
|
127
|
-
else
|
128
|
-
raise "Data type '#{txt}' is not valid. Use one of: " +
|
129
|
-
@@types.join(', ')
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
def to_s
|
134
|
-
"{#{@value}}"
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
# A class representing a precision type.
|
139
|
-
class PrecisionType
|
140
|
-
attr_reader :value
|
141
|
-
@@pattern = '^[EF]?[1-9][0-9]*$'
|
142
|
-
|
143
|
-
# [_txt_:]
|
144
|
-
# The precision type. The allowed pattern is:
|
145
|
-
# ^[EF]?[1-9][0-9]*$
|
146
|
-
# i.e. F3, 5 etc.
|
147
|
-
def initialize(txt=nil)
|
148
|
-
if txt and txt.match(@@pattern)
|
149
|
-
@value = txt
|
150
|
-
else
|
151
|
-
raise "Precision type '#{txt}' does not match #{@@pattern}"
|
152
|
-
end
|
153
|
-
end
|
154
|
-
|
155
|
-
def to_s
|
156
|
-
"{#{@value}}"
|
157
|
-
end
|
158
|
-
end
|
159
|
-
|
160
|
-
# A class representing 'yes' or 'no'.
|
161
|
-
class YesNo
|
162
|
-
attr_reader :value
|
163
|
-
|
164
|
-
# [_txt_:]
|
165
|
-
# A text string with the value 'yes' or 'no'.
|
166
|
-
def initialize(txt=nil)
|
167
|
-
if txt and (txt.downcase == 'yes' or txt.downcase == 'no')
|
168
|
-
@value = txt.downcase
|
169
|
-
else
|
170
|
-
raise "YesNo '#{txt}' is not valid. Use one of: yes, no"
|
171
|
-
end
|
172
|
-
end
|
173
|
-
|
174
|
-
def to_s
|
175
|
-
"{#{@value}}"
|
176
|
-
end
|
177
|
-
end
|
178
|
-
|
179
|
-
# A class representing the type of coordinate system.
|
180
|
-
class CoordSystemType
|
181
|
-
attr_reader :value
|
182
|
-
@@systems = ['eq_FK4', 'eq_FK5', 'ICRS', 'ecl_FK4', 'ecl_FK5',
|
183
|
-
'galactic', 'supergalactic', 'xy', 'barycentric',
|
184
|
-
'geo_app']
|
185
|
-
|
186
|
-
# [_txt_:]
|
187
|
-
# The coordinate system type. Choices: eq_FK4, ICRS, ecl_FK4,
|
188
|
-
# ecl_FK5, galactic, supergalactic, xy, barycentric, geo_app.
|
189
|
-
def initialize(txt='eq_FK5')
|
190
|
-
if txt and @@systems.include?(txt)
|
191
|
-
@value = txt
|
192
|
-
else
|
193
|
-
raise "Coordinate system type '#{txt}' is not valid. Use one of: " +
|
194
|
-
@@systems.join(', ')
|
195
|
-
end
|
196
|
-
end
|
197
|
-
|
198
|
-
def to_s
|
199
|
-
"{#{@value}}"
|
200
|
-
end
|
201
|
-
end
|
202
|
-
|
203
|
-
# A class representing a valid URI.
|
204
|
-
class AnyURI
|
205
|
-
attr_reader :value
|
206
|
-
|
207
|
-
# [_txt_:]
|
208
|
-
# A string representing a _valid_ URI (e.g. one that Ruby's URI.parse
|
209
|
-
# method recognizes.
|
210
|
-
def initialize(txt=nil)
|
211
|
-
begin
|
212
|
-
@value = URI.parse(URI.escape(txt))
|
213
|
-
rescue
|
214
|
-
raise "URI '#{txt}' is not valid: #{$!}"
|
215
|
-
end
|
216
|
-
end
|
217
|
-
|
218
|
-
def to_s
|
219
|
-
"{#{@value.to_s}}"
|
220
|
-
end
|
221
|
-
end
|
222
|
-
|
223
|
-
# A class representing the content role of a document.
|
224
|
-
class ContentRole
|
225
|
-
attr_reader :value
|
226
|
-
@@roles = ['query', 'hints', 'doc', 'location']
|
227
|
-
|
228
|
-
# [_txt_:]
|
229
|
-
# The content role. Choices: query, hints, doc, location.
|
230
|
-
def initialize(txt=nil)
|
231
|
-
if txt and @@roles.include?(txt)
|
232
|
-
@value = txt
|
233
|
-
else
|
234
|
-
raise "Content role '#{txt}' is not valid. Use one of: " +
|
235
|
-
@@roles.join(', ')
|
236
|
-
end
|
237
|
-
end
|
238
|
-
|
239
|
-
def to_s
|
240
|
-
"{#{@value}}"
|
241
|
-
end
|
242
|
-
end
|
243
|
-
|
244
|
-
# A class representing a type of stream.
|
245
|
-
class StreamType
|
246
|
-
attr_reader :value
|
247
|
-
@@types = ['locator', 'other']
|
248
|
-
|
249
|
-
# [_txt_:]
|
250
|
-
# The stream type. Choices: locator, other.
|
251
|
-
def initialize(txt=nil)
|
252
|
-
if txt and @@types.include?(txt)
|
253
|
-
@value = txt
|
254
|
-
else
|
255
|
-
raise "Stream type '#{txt}' is not valid. Use one of: " +
|
256
|
-
@@types.join(', ')
|
257
|
-
end
|
258
|
-
end
|
259
|
-
|
260
|
-
def to_s
|
261
|
-
"{#{@value}}"
|
262
|
-
end
|
263
|
-
end
|
264
|
-
|
265
|
-
# A class representing an actuator event.
|
266
|
-
class Actuate
|
267
|
-
attr_reader :value
|
268
|
-
@@events = ['onLoad', 'onRequest', 'other', 'none']
|
269
|
-
|
270
|
-
# [_txt_:]
|
271
|
-
# The event. Choices: onLoad, onRequest, other, none.
|
272
|
-
def initialize(txt=nil)
|
273
|
-
if txt and @@events.include?(txt)
|
274
|
-
@value = txt
|
275
|
-
else
|
276
|
-
raise "Actuate event '#{txt}' is not valid: " +
|
277
|
-
@@events.join(', ')
|
278
|
-
end
|
279
|
-
end
|
280
|
-
|
281
|
-
def to_s
|
282
|
-
"{#{@value}}"
|
283
|
-
end
|
284
|
-
end
|
285
|
-
|
286
|
-
# A class representing a positive integer.
|
287
|
-
class PositiveInteger
|
288
|
-
attr_reader :value
|
289
|
-
|
290
|
-
# [_num_:]
|
291
|
-
# An integer > 0.
|
292
|
-
def initialize(num=nil)
|
293
|
-
if num and num > 0
|
294
|
-
@value = num
|
295
|
-
else
|
296
|
-
raise "Positive integer #{num} must be > 0"
|
297
|
-
end
|
298
|
-
end
|
299
|
-
|
300
|
-
def to_s
|
301
|
-
"{#{@value.to_s}}"
|
302
|
-
end
|
303
|
-
end
|
304
|
-
|
305
|
-
# A class representing 0 or a positive integer.
|
306
|
-
class NonNegativeInteger
|
307
|
-
attr_reader :value
|
308
|
-
|
309
|
-
# [_num_:]
|
310
|
-
# An integer >= 0.
|
311
|
-
def initialize(num=nil)
|
312
|
-
if num and num >= 0
|
313
|
-
@value = num
|
314
|
-
else
|
315
|
-
raise "Non-negative integer #{num} must be >= 0"
|
316
|
-
end
|
317
|
-
end
|
318
|
-
|
319
|
-
def to_s
|
320
|
-
"{#{@value.to_s}}"
|
321
|
-
end
|
322
|
-
end
|
323
|
-
|
324
|
-
# A class representing a values type.
|
325
|
-
class ValuesType
|
326
|
-
attr_reader :value
|
327
|
-
@@types = ['legal', 'actual']
|
328
|
-
|
329
|
-
# [_txt_:]
|
330
|
-
# The type of values. Choices: legal, actual.
|
331
|
-
def initialize(txt=nil)
|
332
|
-
if txt and @@types.include?(txt)
|
333
|
-
@value = txt
|
334
|
-
else
|
335
|
-
raise "Values type '#{txt}' is not valid. Use one of: " +
|
336
|
-
@@types.join(', ')
|
337
|
-
end
|
338
|
-
end
|
339
|
-
|
340
|
-
def to_s
|
341
|
-
"{#{@value}}"
|
342
|
-
end
|
343
|
-
end
|
344
|
-
|
345
|
-
# A class representing a resource type.
|
346
|
-
class ResourceType
|
347
|
-
attr_reader :value
|
348
|
-
@@types = ['results', 'meta']
|
349
|
-
|
350
|
-
# [_txt_:]
|
351
|
-
# The type of resource. Choices: results, meta.
|
352
|
-
def initialize(txt=nil)
|
353
|
-
if txt and @@types.include?(txt)
|
354
|
-
@value = txt
|
355
|
-
else
|
356
|
-
raise "Resource type '#{txt}' is not valid. Use one of: " +
|
357
|
-
@@types.join(', ')
|
358
|
-
end
|
359
|
-
end
|
360
|
-
|
361
|
-
def to_s
|
362
|
-
"{#{@value}}"
|
363
|
-
end
|
364
|
-
end
|
365
|
-
|
366
|
-
# A class representing a field type.
|
367
|
-
class FieldType
|
368
|
-
attr_reader :value
|
369
|
-
@@types = ['hidden', 'no_query', 'trigger', 'location']
|
370
|
-
|
371
|
-
# [_txt_:]
|
372
|
-
# The field type. Choices: hidden, no_query, trigger, location.
|
373
|
-
def initialize(txt=nil)
|
374
|
-
if txt and @@types.include?(txt)
|
375
|
-
@value = txt
|
376
|
-
else
|
377
|
-
raise "Field type '#{txt}' is not valid. Use one of: " +
|
378
|
-
@@types.join(', ')
|
379
|
-
end
|
380
|
-
end
|
381
|
-
|
382
|
-
def to_s
|
383
|
-
"{#{@value}}"
|
384
|
-
end
|
385
|
-
end
|
386
|
-
|
387
|
-
end
|
388
|
-
end
|
389
|
-
|
390
|
-
end
|
391
|
-
end
|
@@ -1,687 +0,0 @@
|
|
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: Meta::Description).
|
23
|
-
# [_definitions_:]
|
24
|
-
# The VOTable DEFINITIONS element (type: Meta::Definitions).
|
25
|
-
# [_coosys_:]
|
26
|
-
# The coordinate system (COOSYS) definitions for the the VOTable
|
27
|
-
# (type: Meta::CooSys).
|
28
|
-
# [_params_:]
|
29
|
-
# The PARAM elements for the VOTable (type: Meta::Param).
|
30
|
-
# [_info_:]
|
31
|
-
# The INFO elements for the VOTable (type: Meta::Info).
|
32
|
-
# [_resources_:]
|
33
|
-
# The RESOURCE elements for the VOTable (type: 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 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 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() if @resources[res].tables()[tbl].data()
|
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 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 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 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
|
-
# Creates the header for the cart links
|
348
|
-
# [_options_:]
|
349
|
-
#
|
350
|
-
def create_header_cart_links(options)
|
351
|
-
thead_2row = Array.new
|
352
|
-
thead = "<thead class=\"#{options[:header_class]}\">\n"
|
353
|
-
|
354
|
-
thead << "<tr>\n"
|
355
|
-
|
356
|
-
if options[:infer_add_to_cart_ref]
|
357
|
-
js = "function addSelectedRowsToCart(){" +
|
358
|
-
" tbody = $$('#' + '#{options[:id]}' + ' tbody').first();" +
|
359
|
-
" $A(tbody.rows).each(function(row){" +
|
360
|
-
" checkbox = row.cells[0].childNodes[0];" +
|
361
|
-
" if(checkbox.checked){" +
|
362
|
-
" new Ajax.Request(" +
|
363
|
-
" '#{options[:add_to_cart_url]}?' + checkbox.value," +
|
364
|
-
" {method: 'post', " +
|
365
|
-
" onLoading: function(request){" +
|
366
|
-
" $('#{options[:throbber_id]}').style.display = 'inline';" +
|
367
|
-
" $('#{options[:flash_notice_id]}').innerHTML = 'Adding selected rows to cart...';" +
|
368
|
-
" }.bind(this), " +
|
369
|
-
" onComplete: function(request){" +
|
370
|
-
" $('#{options[:throbber_id]}').style.display = 'none';" +
|
371
|
-
" $('#{options[:flash_notice_id]}').innerHTML = 'Selected rows added to cart.';" +
|
372
|
-
" }.bind(this)" +
|
373
|
-
" });" +
|
374
|
-
" }" +
|
375
|
-
" });"
|
376
|
-
js << " new #{options[:on_complete]};" if options[:on_complete]
|
377
|
-
js << "}"
|
378
|
-
thead << "<th><a href=\"javascript:void(0);\" onclick=\"new #{js};return false;\">#{options[:add_to_cart_header_label]}</a></th>\n"
|
379
|
-
|
380
|
-
js = "function selectAllRows(){" +
|
381
|
-
" tbody = $$('#' + '#{options[:id]}' + ' tbody').first();" +
|
382
|
-
" $A(tbody.rows).each(function(row){" +
|
383
|
-
" checkbox = row.cells[0].childNodes[0];" +
|
384
|
-
" if(!checkbox.checked){" +
|
385
|
-
" checkbox.checked = true;" +
|
386
|
-
" }" +
|
387
|
-
" });" +
|
388
|
-
"}"
|
389
|
-
buttons_text = " <a href=\"javascript:void(0);\" title=\"Select all rows\" onclick=\"new #{js};return false;\">+</a> "
|
390
|
-
|
391
|
-
js = "function deselectAllRows(){" +
|
392
|
-
" tbody = $$('#' + '#{options[:id]}' + ' tbody').first();" +
|
393
|
-
" $A(tbody.rows).each(function(row){" +
|
394
|
-
" checkbox = row.cells[0].childNodes[0];" +
|
395
|
-
" if(checkbox.checked){" +
|
396
|
-
" checkbox.checked = false;" +
|
397
|
-
" }" +
|
398
|
-
" });" +
|
399
|
-
"}"
|
400
|
-
buttons_text << " <a href=\"javascript:void(0);\" title=\"Deselect all rows\" onclick=\"new #{js};return false;\">-</a> "
|
401
|
-
thead_2row.push(buttons_text)
|
402
|
-
end
|
403
|
-
|
404
|
-
return [thead, thead_2row]
|
405
|
-
end
|
406
|
-
|
407
|
-
# Create the headers for HTML table
|
408
|
-
# [_access_ref_index_:]
|
409
|
-
# A valid SIA VOTable will only ever have one VOX:Image_AccessReference.
|
410
|
-
# [_options_:]
|
411
|
-
#
|
412
|
-
def create_headers(access_ref_index, options)
|
413
|
-
thead, thead_2row = create_header_cart_links(options)
|
414
|
-
|
415
|
-
if options[:infer_access_ref] and access_ref_index
|
416
|
-
thead << "<th>#{options[:access_ref_header_label]}</th>\n"
|
417
|
-
thead_2row.push(' ')
|
418
|
-
end
|
419
|
-
|
420
|
-
col_count = 0
|
421
|
-
fields(options[:res], options[:tbl]).each do |field|
|
422
|
-
ucd_value = ' '
|
423
|
-
ucd_value = field.ucd.value if field.ucd
|
424
|
-
if options[:infer_access_ref] and access_ref_index and col_count == access_ref_index
|
425
|
-
thead_2row[1] = ucd_value
|
426
|
-
else
|
427
|
-
thead << "<th>#{field.name}</th>\n"
|
428
|
-
thead_2row.push(ucd_value)
|
429
|
-
end
|
430
|
-
col_count += 1
|
431
|
-
end
|
432
|
-
|
433
|
-
thead << " </tr>\n"
|
434
|
-
|
435
|
-
thead << "<tr>\n"
|
436
|
-
thead_2row.each do |h|
|
437
|
-
thead << "<th>#{h}</th>\n"
|
438
|
-
end
|
439
|
-
thead << "</tr>\n"
|
440
|
-
|
441
|
-
thead << "</thead>"
|
442
|
-
|
443
|
-
return thead
|
444
|
-
end
|
445
|
-
|
446
|
-
# Convert hms of right ascension to decimal degrees.
|
447
|
-
# [_ra:_]
|
448
|
-
#
|
449
|
-
def convert_ra_to_degrees(ra)
|
450
|
-
hours, min, sec = ra.split(':')
|
451
|
-
degrees = (hours.to_f() * 15.0) +
|
452
|
-
(min.to_f() * 15.0 / 60.0) +
|
453
|
-
(sec.to_f() * 15.0 / (60.0 * 60.0))
|
454
|
-
end
|
455
|
-
|
456
|
-
# Convert dms of declination to degrees
|
457
|
-
# [_dec:_]
|
458
|
-
#
|
459
|
-
def convert_dec_to_degrees(dec)
|
460
|
-
degree, arcmin, arcsec = dec.split(':')
|
461
|
-
degree_f = degree.to_f()
|
462
|
-
arcmin_f = (arcmin.to_f() / 60.0)
|
463
|
-
arcsec_f = (arcsec.to_f() / (60.0 * 60.0))
|
464
|
-
return (degree_f - arcmin_f - arcsec_f) if degree_f < 0
|
465
|
-
return degree_f + arcmin_f + arcsec_f
|
466
|
-
end
|
467
|
-
|
468
|
-
# Creates the cart parameters
|
469
|
-
# [_cart_params:_]
|
470
|
-
#
|
471
|
-
# [_columns:_]
|
472
|
-
#
|
473
|
-
def create_item_cart_params(cart_params, columns)
|
474
|
-
link_ref_array = []
|
475
|
-
|
476
|
-
cart_params.each do |key, value|
|
477
|
-
link_ref_array.push("#{key}=#{value}")
|
478
|
-
end
|
479
|
-
|
480
|
-
access_ref_index = image_access_reference_columns()
|
481
|
-
link_ref_array.push("resource=#{CGI.escape(columns[access_ref_index].value).to_s}") if access_ref_index
|
482
|
-
ra_index = image_ra_columns()
|
483
|
-
link_ref_array.push("rac=#{columns[ra_index].value.to_s}") if ra_index
|
484
|
-
dec_index = image_dec_columns()
|
485
|
-
link_ref_array.push("decc=#{columns[dec_index].value.to_s}") if dec_index
|
486
|
-
filter_index = image_filter_columns()
|
487
|
-
link_ref_array.push("filter=#{columns[filter_index].value.to_s}") if filter_index
|
488
|
-
date_obs_index = image_date_obs_columns()
|
489
|
-
link_ref_array.push("date_obs=#{columns[date_obs_index].value.to_s}") if date_obs_index
|
490
|
-
teles_index = image_telescope_columns()
|
491
|
-
link_ref_array.push("telescop=#{columns[teles_index].value.to_s}") if teles_index
|
492
|
-
survey_index = image_survey_columns()
|
493
|
-
link_ref_array.push("survey=#{columns[survey_index].value.to_s}") if survey_index
|
494
|
-
instrum_index = image_instrument_columns()
|
495
|
-
link_ref_array.push("instrument=#{columns[instrum_index].value.to_s}") if instrum_index
|
496
|
-
sky_index = image_sky_columns()
|
497
|
-
link_ref_array.push("sky=#{columns[sky_index].value.to_s}") if sky_index
|
498
|
-
zerop_index = image_zeropoint_columns()
|
499
|
-
link_ref_array.push("zeropoint=#{columns[zerop_index].value.to_s}") if zerop_index
|
500
|
-
seeing_index = image_seeing_columns()
|
501
|
-
link_ref_array.push("seeing=#{columns[seeing_index].value.to_s}") if seeing_index
|
502
|
-
depth_index = image_depth_columns()
|
503
|
-
link_ref_array.push("depth=#{columns[depth_index].value.to_s}") if depth_index
|
504
|
-
exptime_index = image_exptime_columns()
|
505
|
-
link_ref_array.push("exptime=#{columns[exptime_index].value.to_s}") if exptime_index
|
506
|
-
|
507
|
-
return link_ref_array.join('&')
|
508
|
-
end
|
509
|
-
|
510
|
-
# Create body for HTML table
|
511
|
-
# [_access_ref_index_:]
|
512
|
-
# A valid SIA VOTable will only ever have one VOX:Image_AccessReference.
|
513
|
-
# [_options_:]
|
514
|
-
#
|
515
|
-
def create_body(access_ref_index, options)
|
516
|
-
tbody = "<tbody class=\"#{options[:body_class]}\" align=\"center\">\n"
|
517
|
-
row_count = 0
|
518
|
-
rows_data = rows(options[:res], options[:tbl])
|
519
|
-
if rows_data
|
520
|
-
rows_data.each do |tr|
|
521
|
-
tbody << "<tr class=\"#{options[:row_classes][row_count % 2]}\">\n"
|
522
|
-
|
523
|
-
# Specially mark up the first column to link to the image.
|
524
|
-
columns = tr.tds()
|
525
|
-
|
526
|
-
if options[:infer_add_to_cart_ref] and access_ref_index
|
527
|
-
tbody << "<td><input type=\"checkbox\" " +
|
528
|
-
"id=\"checkbox_add_#{options[:cart_params][:archive]}_#{row_count.to_s}\" " +
|
529
|
-
"value=\"#{create_item_cart_params(options[:cart_params], columns)}\"/></td>\n"
|
530
|
-
end
|
531
|
-
|
532
|
-
if options[:infer_access_ref] and access_ref_index
|
533
|
-
tbody << "<td><a href=\"#{columns[access_ref_index].value}\">#{options[:access_ref_link_label]}</a></td>\n"
|
534
|
-
end
|
535
|
-
|
536
|
-
col_count = 0
|
537
|
-
#ra_index = image_ra_columns()
|
538
|
-
#dec_index = image_dec_columns()
|
539
|
-
columns.each do |td|
|
540
|
-
if col_count != access_ref_index
|
541
|
-
#if ra_index and col_count == ra_index
|
542
|
-
# tbody << "<td>#{convert_ra_to_degrees(td.value)}</td>\n"
|
543
|
-
#elsif dec_index and col_count == dec_index
|
544
|
-
# tbody << "<td>#{convert_dec_to_degrees(td.value)}</td>\n"
|
545
|
-
#else
|
546
|
-
tbody << "<td>#{td.value}</td>\n"
|
547
|
-
#end
|
548
|
-
end
|
549
|
-
col_count += 1
|
550
|
-
end
|
551
|
-
|
552
|
-
tbody << "</tr>\n"
|
553
|
-
row_count += 1
|
554
|
-
end
|
555
|
-
end
|
556
|
-
tbody << "</tbody>"
|
557
|
-
|
558
|
-
return tbody
|
559
|
-
end
|
560
|
-
|
561
|
-
# Create table for HTML VOTable
|
562
|
-
# [_thead_:]
|
563
|
-
# The class to assign the HTML table thead.
|
564
|
-
# [_tbody_:]
|
565
|
-
# The class to assign the HTML table tbody.
|
566
|
-
# [_options_:]
|
567
|
-
# The options for this VOTable.
|
568
|
-
def create_votable(thead, tbody, options)
|
569
|
-
votable = "<img class=\"#{options[:throbber_class]}\" " +
|
570
|
-
" id=\"#{options[:throbber_id]}\" " +
|
571
|
-
" src=\"#{options[:throbber_src]}\" " +
|
572
|
-
" size=\"#{options[:throbber_size]}\"/> " +
|
573
|
-
"<span class=\"#{options[:flash_notice_class]}\" " +
|
574
|
-
" id=\"#{options[:flash_notice_id]}\"></span><br>\n"
|
575
|
-
votable << "<table class=\"#{options[:table_class]}\""
|
576
|
-
votable << " id=\"#{options[:id]}\"" if options[:id]
|
577
|
-
votable << " border=\"1\"" if options[:show_border]
|
578
|
-
votable << " width=\"100%\">\n"
|
579
|
-
votable << "#{thead}\n#{tbody}\n</table>"
|
580
|
-
|
581
|
-
return votable
|
582
|
-
end
|
583
|
-
|
584
|
-
# Convert the specified table in the specified resource into an HTML
|
585
|
-
# table.
|
586
|
-
# [_options_:]
|
587
|
-
# The options for this VOTable.
|
588
|
-
def to_html(options={})
|
589
|
-
# The ID to assign to the HTML table as a whole.
|
590
|
-
options[:id] = options[:id] || "#{votable}_#{Time.now.to_i}_#{rand(10000)}"
|
591
|
-
|
592
|
-
options[:infer_add_to_cart_ref] = true if options[:infer_add_to_cart_ref] == nil
|
593
|
-
options[:add_to_cart_header_label] = options[:add_to_cart_header_label] || 'Add to Cart'
|
594
|
-
options[:cart_params] = {} if options[:cart_params] == nil
|
595
|
-
#options[:add_to_cart_url] = options[:add_to_cart_url] || nil
|
596
|
-
|
597
|
-
options[:throbber_src] = options[:throbber_src] || '/images/general/indicator.gif'
|
598
|
-
options[:throbber_size] = options[:throbber_size] || '16x16'
|
599
|
-
options[:throbber_class] = options[:throbber_class] || 'throbber'
|
600
|
-
options[:throbber_id] = options[:throbber_id] || "#{options[:id]}_throbber_id"
|
601
|
-
|
602
|
-
options[:flash_notice_class] = options[:flash_notice_class] || 'flash_notice'
|
603
|
-
options[:flash_notice_id] = options[:flash_notice_id] || "#{options[:id]}_flash_notice_id"
|
604
|
-
|
605
|
-
# Link the access reference URL associated with a row.
|
606
|
-
options[:infer_access_ref] = true if options[:infer_access_ref] == nil
|
607
|
-
#options[:retrieve_link_ref] = options[:retrieve_link_ref] || nil
|
608
|
-
# For the access reference column, place this value in the header.
|
609
|
-
options[:access_ref_header_label] = options[:access_ref_header_label] || 'URL'
|
610
|
-
# For the access reference column, link this word.
|
611
|
-
options[:access_ref_link_label] = options[:access_ref_link_label] || 'Retrieve'
|
612
|
-
options[:ssl] = false if options[:ssl] == nil
|
613
|
-
#options[:resource_link] = options[:resource_link]
|
614
|
-
|
615
|
-
# The resource from which to extract the table in question.
|
616
|
-
options[:res] = options[:res] || 0
|
617
|
-
# The table inside the resource from which to extract the rows in question.
|
618
|
-
options[:tbl] = options[:tbl] || 0
|
619
|
-
|
620
|
-
# The boolean value to show HTML table border
|
621
|
-
options[:show_border] = false if options[:show_border] == nil
|
622
|
-
# The class to assign the HTML table as a whole.
|
623
|
-
options[:table_class] = options[:table_class] || 'votable'
|
624
|
-
# The class to assign the header of the HTML table.
|
625
|
-
options[:header_class] = options[:header_class] || 'header'
|
626
|
-
# The class to assign the body of the HTML table.
|
627
|
-
options[:body_class] = options[:body_class] || 'body'
|
628
|
-
# The class to assign the HTML table body rows.
|
629
|
-
options[:row_classes] = options[:row_classes] || ['row1', 'row2']
|
630
|
-
|
631
|
-
begin
|
632
|
-
# A valid SIA VOTable will only ever have one VOX:Image_AccessReference.
|
633
|
-
access_ref_index = image_access_reference_columns()
|
634
|
-
|
635
|
-
return create_votable(create_headers(access_ref_index, options),
|
636
|
-
create_body(access_ref_index, options),
|
637
|
-
options)
|
638
|
-
|
639
|
-
rescue Exception => e
|
640
|
-
title = 'Error...'
|
641
|
-
message = "VORuby error: #{e.message}<br>#{e.backtrace}"
|
642
|
-
message << "<br>#{@resources[0].info[0].text().to_s()}" if @resources[0].info[0]
|
643
|
-
create_message(title, message, options)
|
644
|
-
end
|
645
|
-
end
|
646
|
-
|
647
|
-
# Creates a message
|
648
|
-
# [_title_:]
|
649
|
-
#
|
650
|
-
# [_message_:]
|
651
|
-
#
|
652
|
-
# [_options_:]
|
653
|
-
# The options for this VOTable.
|
654
|
-
def create_message(title, message, options)
|
655
|
-
table = "<table class=\"#{options[:table_class]}\" width=\"100%\">\n" +
|
656
|
-
" <thead class=\"#{options[:header_class]}\">\n" +
|
657
|
-
" <tr>\n" +
|
658
|
-
" <th>#{title}</th>\n" +
|
659
|
-
" </tr>\n" +
|
660
|
-
" </thead>\n" +
|
661
|
-
" <tbody class=\"#{options[:body_class]}\">\n" +
|
662
|
-
" <tr class=\"#{options[:row_classes][0]}\">\n" +
|
663
|
-
" <td align=\"center\"><label>VOTable message: #{message}</label></td>\n" +
|
664
|
-
" </tr>\n" +
|
665
|
-
" </tbody>\n" +
|
666
|
-
"</table>"
|
667
|
-
|
668
|
-
return table
|
669
|
-
end
|
670
|
-
|
671
|
-
#
|
672
|
-
# [_attributes_:]
|
673
|
-
#
|
674
|
-
# [_name_:]
|
675
|
-
#
|
676
|
-
def self._find_attr_value(attributes, name)
|
677
|
-
attributes.each do |qname, value|
|
678
|
-
return value if qname.name == name
|
679
|
-
end
|
680
|
-
|
681
|
-
return nil
|
682
|
-
end
|
683
|
-
end
|
684
|
-
end
|
685
|
-
|
686
|
-
end
|
687
|
-
end
|