| 1 | package Astro::Catalog::Query::Vizier; | ||||||||||
| 2 | |||||||||||
| 3 | =head1 NAME | ||||||||||
| 4 | |||||||||||
| 5 | Astro::Catalog::Query::Vizier - A query request to the Vizier catalogs | ||||||||||
| 6 | |||||||||||
| 7 | =head1 SYNOPSIS | ||||||||||
| 8 | |||||||||||
| 9 | $gsc = new Astro::Catalog::Query::2MASS( | ||||||||||
| 10 | Catalog => '2MASS', | ||||||||||
| 11 | RA => $ra, | ||||||||||
| 12 | Dec => $dec, | ||||||||||
| 13 | Radius => $radius, | ||||||||||
| 14 | Nout => $number_out, | ||||||||||
| 15 | Target => $object, | ||||||||||
| 16 | ); | ||||||||||
| 17 | |||||||||||
| 18 | my $catalog = $gsc->querydb(); | ||||||||||
| 19 | |||||||||||
| 20 | =head1 DESCRIPTION | ||||||||||
| 21 | |||||||||||
| 22 | The module is an object orientated interface to the online | ||||||||||
| 23 | Vizier catalogs. Multiple catalogs can be specified using a | ||||||||||
| 24 | comma-separated list. | ||||||||||
| 25 | |||||||||||
| 26 | Stores information about an prospective query and allows the query to | ||||||||||
| 27 | be made, returning an Astro::Catalog::Query::Vizier object. | ||||||||||
| 28 | |||||||||||
| 29 | The object will by default pick up the proxy information from the HTTP_PROXY | ||||||||||
| 30 | and NO_PROXY environment variables, see the LWP::UserAgent documentation for | ||||||||||
| 31 | details. | ||||||||||
| 32 | |||||||||||
| 33 | See L<Astro::Catalog::Query> for the catalog-independent methods. | ||||||||||
| 34 | |||||||||||
| 35 | =cut | ||||||||||
| 36 | |||||||||||
| 37 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 38 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 39 | 1 | ▶ | use base qw/Astro::Catalog::Transport::REST/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 40 | |||||||||||
| 41 | 1 | ▶ | use File::Spec; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 42 | 1 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 43 | |||||||||||
| 44 | 1 | ▶ | use Astro::Catalog; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 45 | 1 | ▶ | use Astro::Catalog::Item; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 46 | |||||||||||
| 47 | 1 | our $VERSION = '4.38'; | |||||||||
| 48 | 1 | our $DEBUG = 0; | |||||||||
| 49 | |||||||||||
| 50 | =begin __PRIVATE_METHODS__ | ||||||||||
| 51 | |||||||||||
| 52 | =head2 Private methods | ||||||||||
| 53 | |||||||||||
| 54 | These methods are for internal use only. | ||||||||||
| 55 | |||||||||||
| 56 | =over 4 | ||||||||||
| 57 | |||||||||||
| 58 | =item B<_default_remote_host> | ||||||||||
| 59 | |||||||||||
| 60 | Need to allow the host to be specified. | ||||||||||
| 61 | |||||||||||
| 62 | =cut | ||||||||||
| 63 | |||||||||||
| 64 | 0 | ▶ | sub _default_remote_host { | ||||||||
|
Subroutine
_default_remote_host: not called CC=1 SCAR=6.9
| |||||||||||
| 65 | 0 | return "vizier.u-strasbg.fr"; | |||||||||
| 66 | } | ||||||||||
| 67 | |||||||||||
| 68 | =item B<_default_url_path> | ||||||||||
| 69 | |||||||||||
| 70 | asu-acl will generate TST format catalogs. asu-xml will generate | ||||||||||
| 71 | AstroRes format XML. We assume TST for the moment. | ||||||||||
| 72 | |||||||||||
| 73 | =cut | ||||||||||
| 74 | |||||||||||
| 75 | 0 | ▶ | sub _default_url_path { | ||||||||
|
Subroutine
_default_url_path: not called CC=1 SCAR=6.9
| |||||||||||
| 76 | 0 | return "viz-bin/asu-acl?"; | |||||||||
| 77 | } | ||||||||||
| 78 | |||||||||||
| 79 | =item B<_get_allowed_options> | ||||||||||
| 80 | |||||||||||
| 81 | Returns a hash with keys, being the internal options supported | ||||||||||
| 82 | by this subclass, and values being the key name actually required | ||||||||||
| 83 | by the remote system (and to be included in the query). | ||||||||||
| 84 | |||||||||||
| 85 | =cut | ||||||||||
| 86 | |||||||||||
| 87 | 0 | ▶ | sub _get_allowed_options { | ||||||||
|
Subroutine
_get_allowed_options: not called CC=1 SCAR=6.9
| |||||||||||
| 88 | 0 | my $self = shift; | |||||||||
| 89 | # Need to add magfaint and magbright | ||||||||||
| 90 | return ( | ||||||||||
| 91 | 0 | ra => '-c.ra', | |||||||||
| 92 | dec => '-c.dec', | ||||||||||
| 93 | radmax => '-c.rm', | ||||||||||
| 94 | radmin => '-c.rm.min', # _from_radmin combines this into c.rm: no c.rm.min parameter | ||||||||||
| 95 | nout => '-out.max', | ||||||||||
| 96 | # sort => '-sort', | ||||||||||
| 97 | object => '-c.obj', | ||||||||||
| 98 | |||||||||||
| 99 | catalog => '-source', | ||||||||||
| 100 | # outcols => '-out.all', | ||||||||||
| 101 | ); | ||||||||||
| 102 | } | ||||||||||
| 103 | |||||||||||
| 104 | =item B<_get_default_options> | ||||||||||
| 105 | |||||||||||
| 106 | Get the default query state. | ||||||||||
| 107 | |||||||||||
| 108 | =cut | ||||||||||
| 109 | |||||||||||
| 110 | 0 | ▶ | sub _get_default_options { | ||||||||
|
Subroutine
_get_default_options: not called CC=1 SCAR=6.9
| |||||||||||
| 111 | return ( | ||||||||||
| 112 | # Internal | ||||||||||
| 113 | 0 | catalog => '2MASS', | |||||||||
| 114 | |||||||||||
| 115 | # Target information | ||||||||||
| 116 | ra => undef, | ||||||||||
| 117 | dec => undef, | ||||||||||
| 118 | object => undef, | ||||||||||
| 119 | |||||||||||
| 120 | # Limits | ||||||||||
| 121 | radmin => 0, | ||||||||||
| 122 | radmax => 5, | ||||||||||
| 123 | nout => 20000, | ||||||||||
| 124 | # sort => 'RA', # do not know the allowed options | ||||||||||
| 125 | |||||||||||
| 126 | # outcols => '', # need to check | ||||||||||
| 127 | ); | ||||||||||
| 128 | } | ||||||||||
| 129 | |||||||||||
| 130 | # Combine radmax and radmin into c.rm parameter. | ||||||||||
| 131 | |||||||||||
| 132 | 0 | ▶ | sub _from_radmax { | ||||||||
|
Subroutine
_from_radmax: not called CC=2 SCAR=17.9
| |||||||||||
| 133 | 0 | my $self = shift; | |||||||||
| 134 | 0 | my $radmax = $self->query_options('radmax'); | |||||||||
| 135 | 0 | my $radmin = $self->query_options('radmin'); | |||||||||
| 136 | 0 | my %allow = $self->_get_allowed_options(); | |||||||||
| 137 | |||||||||||
| 138 | 0 | ▶ | my $param = $radmin ? (join '+', $radmin, $radmax) : $radmax; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 139 | |||||||||||
| 140 | 0 | return ($allow{'radmax'}, $param); | |||||||||
| 141 | } | ||||||||||
| 142 | |||||||||||
| 143 | # (Note: this just sets radmax again...) | ||||||||||
| 144 | |||||||||||
| 145 | 0 | ▶ | sub _from_radmin { | ||||||||
|
Subroutine
_from_radmin: not called CC=1 SCAR=6.9
| |||||||||||
| 146 | 0 | my $self = shift; | |||||||||
| 147 | 0 | return $self->_from_radmax; | |||||||||
| 148 | } | ||||||||||
| 149 | |||||||||||
| 150 | =item B<_parse_query> | ||||||||||
| 151 | |||||||||||
| 152 | Private function used to parse the results returned in an GSC query. | ||||||||||
| 153 | Should not be called directly. Instead use the querydb() assessor method to | ||||||||||
| 154 | make and parse the results. | ||||||||||
| 155 | |||||||||||
| 156 | =cut | ||||||||||
| 157 | |||||||||||
| 158 | 0 | ▶ | sub _parse_query { | ||||||||
|
Subroutine
_parse_query: not called CC=2 SCAR=17.9
| |||||||||||
| 159 | 0 | my $self = shift; | |||||||||
| 160 | |||||||||||
| 161 | 0 | ▶ | print $self->{BUFFER} if $DEBUG; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 162 | return new Astro::Catalog( | ||||||||||
| 163 | Format => 'TST', | ||||||||||
| 164 | Data => $self->{BUFFER}, | ||||||||||
| 165 | 0 | Origin => 'Vizier', | |||||||||
| 166 | ReadOpt => { | ||||||||||
| 167 | id_col => 0, | ||||||||||
| 168 | ra_col => 1, | ||||||||||
| 169 | dec_col => 2, | ||||||||||
| 170 | }); | ||||||||||
| 171 | } | ||||||||||
| 172 | |||||||||||
| 173 | =back | ||||||||||
| 174 | |||||||||||
| 175 | =head2 Translation Methods | ||||||||||
| 176 | |||||||||||
| 177 | The query options stored internally in the object are not necessarily | ||||||||||
| 178 | the form required for a query to a remote server. Methods for converting | ||||||||||
| 179 | from the internal representation to the external query format are | ||||||||||
| 180 | provided in the form of _from_$opt. ie: | ||||||||||
| 181 | |||||||||||
| 182 | ($outkey, $outvalue) = $q->_from_ra(); | ||||||||||
| 183 | ($outkey, $outvalue) = $q->_from_object(); | ||||||||||
| 184 | |||||||||||
| 185 | The base class only includes one to one mappings. | ||||||||||
| 186 | |||||||||||
| 187 | =over 4 | ||||||||||
| 188 | |||||||||||
| 189 | =item B<_translate_one_to_one> | ||||||||||
| 190 | |||||||||||
| 191 | Return a list of internal options (as defined in C<_get_allowed_options>) | ||||||||||
| 192 | that are known to support a one-to-one mapping of the internal value | ||||||||||
| 193 | to the external value. | ||||||||||
| 194 | |||||||||||
| 195 | %one = $q->_translate_one_to_one(); | ||||||||||
| 196 | |||||||||||
| 197 | Returns a hash with keys and no values (this makes it easy to | ||||||||||
| 198 | check for the option). | ||||||||||
| 199 | |||||||||||
| 200 | This method also returns, the values from the parent class. | ||||||||||
| 201 | |||||||||||
| 202 | =cut | ||||||||||
| 203 | |||||||||||
| 204 | 0 | ▶ | sub _translate_one_to_one { | ||||||||
|
Subroutine
_translate_one_to_one: not called CC=1 SCAR=6.9
| |||||||||||
| 205 | 0 | my $self = shift; | |||||||||
| 206 | # convert to a hash-list | ||||||||||
| 207 | return ($self->SUPER::_translate_one_to_one, | ||||||||||
| 208 | 0 | map { $_, undef }(qw/ | |||||||||
| 209 | catalog | ||||||||||
| 210 | outcols | ||||||||||
| 211 | /) | ||||||||||
| 212 | ); | ||||||||||
| 213 | } | ||||||||||
| 214 | |||||||||||
| 215 | 1 | 1; | |||||||||
| 216 | |||||||||||
| 217 | __END__ | ||||||||||