# A set of classes designed to read and manipulate
# especific VOTables[http://www.ivoa.net/Documents/latest/VOT.html].
# This class represents a GALEX VOTable.
require 'voruby/votables/votable'
module VORuby
module VOTables
module VOTable
class GALEXVOTable < VOTable
# Our object's contructor
# [_votable:_]
# The VOTable object
def initialize(votable)
super(votable.id, votable.version, votable.description,
votable.definitions, votable.coosys, votable.params,
votable.info, votable.resources)
end
# Find a field in GALEX configuration file given a key.
# Returns a hash with the field's attributes
# [_key_:]
# The key indexing on field's attribute
def find_field_in_conf_file(key)
galex_field = {'id'=> nil, 'name'=> nil, 'ucd'=> nil}
if key != nil
GALEX_ARCHIVE_CONFIG.each do |archive|
archive['votable_fields'].each do |field|
if field['key'] == key
galex_field['id'] = field['id'] if field['id'] != 'nil'
galex_field['name'] = field['name'] if field['name'] != 'nil'
galex_field['ucd'] = field['ucd'] if field['ucd'] != 'nil'
break
end
end
end
end
return galex_field
end
# Find the column number(s) associated with the
# VOX:imageAccessReference UCD.
# Returns a list of column positions.
def image_access_reference_columns()
ucd_access = find_field_in_conf_file('VOX:Image_AccessReference')['ucd']
if find_columns(ucd_access).first != nil
find_columns(ucd_access).first
end
end
def image_ra_columns
ucd_ra = find_field_in_conf_file('POS_EQ_RA_MAIN')['ucd']
if find_columns(ucd_ra).first != nil
find_columns(ucd_ra).first
end
end
def image_dec_columns
ucd_dec = find_field_in_conf_file('POS_EQ_DEC_MAIN')['ucd']
if find_columns(ucd_dec).first != nil
find_columns(ucd_dec).first
end
end
def image_filter_columns
ucd_filter = find_field_in_conf_file('VOX:BandPass_ID')['ucd']
if find_columns(ucd_filter).first != nil
find_columns(ucd_filter).first
end
end
def image_date_obs_columns
#ucd_date_obs = find_field_in_conf_file('')['ucd']
#if find_columns(ucd_date_obs).first != nil
# find_columns(ucd_date_obs).first
#end
end
def image_telescope_columns
#ucd_telescope = find_field_in_conf_file('')['ucd']
#if find_columns(ucd_telescope).first != nil
# find_columns(ucd_telescope).first
#end
end
def image_survey_columns
ucd_survey = find_field_in_conf_file('VOX:Image_Title')['ucd']
if find_columns(ucd_survey).first != nil
find_columns(ucd_survey).first
end
end
def image_instrument_columns
ucd_instrument = find_field_in_conf_file('VOX:INST_ID')['ucd']
if find_columns(ucd_instrument).first != nil
find_columns(ucd_instrument).first
end
end
def image_sky_columns
#ucd_sky = find_field_in_conf_file('')['ucd']
#if find_columns(ucd_sky).first != nil
# find_columns(ucd_sky).first
#end
end
def image_zeropoint_columns
#ucd_zeropoint = find_field_in_conf_file('')['ucd']
#if find_columns(ucd_zeropoint).first != nil
# find_columns(ucd_zeropoint).first
#end
end
def image_seeing_columns
#ucd_seeing = find_field_in_conf_file('')['ucd']
#if find_columns(ucd_seeing).first != nil
# find_columns(ucd_seeing).first
#end
end
def image_depth_columns
#ucd_depth = find_field_in_conf_file('')['ucd']
#if find_columns(ucd_depth).first != nil
# find_columns(ucd_depth).first
#end
end
def image_exptime_columns
#ucd_exptime = find_field_in_conf_file('')['ucd']
#if find_columns(ucd_exptime).first != nil
# find_columns(ucd_exptime).first
#end
end
# Create headers for HTML table
# [_res_:]
# The resource from which to extract the table in question.
# [_tbl_:]
# The table inside the resource from which to extract the rows in question.
# [_infer_add_to_cart_ref_:]
#
# [_add_to_cart_header_value_:]
#
# [_infer_access_ref_:]
# Link the access reference URL associated with a row.
# [_access_ref_header_value_:]
# For the access reference column, place this value in the header.
# [_access_ref_col_:]
# A valid SIA VOTable will only ever have one VOX:Image_AccessReference.
# [_header_class_:]
# The class to assign the header of the HTML table.
def create_headers(res, tbl,
infer_add_to_cart_ref, add_to_cart_header_value,
infer_access_ref, access_ref_header_value, access_ref_col,
header_class, id=nil)
headers = Array.new
thead = "\n"
thead << "\n"
if infer_add_to_cart_ref
thead << " \n"
thead << "#{add_to_cart_header_value} \n"
headers.push("*")
end
if infer_access_ref
thead << "#{access_ref_header_value} \n"
headers.push(' ')
end
col_count = 0
fields(res, tbl).each do |field|
field_archive = find_field_in_conf_file(field.ucd.value())
field_ucd = field_archive['ucd']
if infer_access_ref and col_count == access_ref_col
headers[1] = field_ucd if field_ucd != 'nil'
else
thead << "#{field_archive['name']} \n"
if field_ucd != 'nil'
headers.push(field_ucd)
else
headers.push(' ')
end
end
col_count += 1
end
thead << " \n"
headers.each do |h|
thead << " \n"
thead << ""
return thead
end
def create_add_to_cart_link(link_ref, columns)
access_ref_col = image_access_reference_columns()
link_ref << '&resource=' + CGI.escape(columns[access_ref_col].value).to_s if access_ref_col
ra_col = image_ra_columns()
link_ref << '&rac=' + columns[ra_col].value.to_s if ra_col
dec_col = image_dec_columns()
link_ref << '&decc=' + columns[dec_col].value.to_s if dec_col
filter_col = image_filter_columns()
link_ref << '&filter=' + columns[filter_col].value.to_s if filter_col
date_obs_col = image_date_obs_columns()
link_ref << '&date_obs=' + columns[date_obs_col].value.to_s if date_obs_col
teles_col = image_telescope_columns()
link_ref << '&telescop=' + columns[teles_col].value.to_s if teles_col
survey_col = image_survey_columns()
link_ref << '&survey=' + columns[survey_col].value.to_s if survey_col
instrum_col = image_instrument_columns()
link_ref << '&instrument=' + columns[instrum_col].value.to_s if instrum_col
sky_col = image_sky_columns()
link_ref << '&sky=' + columns[sky_col].value.to_s if sky_col
zerop_col = image_zeropoint_columns()
link_ref << '&zeropoint=' + columns[zerop_col].value.to_s if zerop_col
seeing_col = image_seeing_columns()
link_ref << '&seeing=' + columns[seeing_col].value.to_s if seeing_col
depth_col = image_depth_columns()
link_ref << '&depth=' + columns[depth_col].value.to_s if depth_col
exptime_col = image_exptime_columns()
link_ref << '&exptime=' + columns[exptime_col].value.to_s if exptime_col
return link_ref
end
# Create body for HTML table
# [_res_:]
# The resource from which to extract the table in question.
# [_tbl_:]
# The table inside the resource from which to extract the rows in question.
# [_infer_add_to_cart_ref_:]
#
# [_add_to_cart_link_value_:]
#
# [_add_to_cart_link_ref_:]
#
# [_infer_access_ref_:]
# Link the access reference URL associated with a row.
# [_access_ref_link_value_:]
# For the access reference column, link this word.
# [_access_ref_col_:]
# A valid SIA VOTable will only ever have one VOX:Image_AccessReference.
# [_body_class_:]
# The class to assign the body of the HTML table.
# [_row_classes_:]
# The class to assign the HTML table body rows.
def create_body(res, tbl,
infer_add_to_cart_ref, add_to_cart_link_value, add_to_cart_link_ref,
infer_access_ref, access_ref_link_value, access_ref_col,
body_class, row_classes)
tbody = "#{h} \n"
end
thead << "