| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Astro::Catalog::Query::Sesame; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Astro::Catalog::Query::Sesame - Object name resolution via SIMBAD |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
my $sesame = new Astro::Catalog::Query::Sesame( Target => "EX Hya" ); |
|
10
|
|
|
|
|
|
|
my $catalog = $sesame->querydb(); |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Simple wrapper object for the CDS SIMBAD Name Resolver serbice (Sesame), see |
|
15
|
|
|
|
|
|
|
http://cdsweb.u-strasbg.fr/cdsws.gml for details of the service. |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=cut |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# L O A D M O D U L E S -------------------------------------------------- |
|
20
|
|
|
|
|
|
|
|
|
21
|
2
|
|
|
2
|
|
8001737
|
use strict; |
|
|
2
|
|
|
|
|
19
|
|
|
|
2
|
|
|
|
|
150
|
|
|
22
|
2
|
|
|
2
|
|
13
|
use warnings; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
170
|
|
|
23
|
2
|
|
|
2
|
|
83
|
use base qw/ Astro::Catalog::Transport::WebService /; |
|
|
2
|
|
|
|
|
15
|
|
|
|
2
|
|
|
|
|
1756
|
|
|
24
|
|
|
|
|
|
|
use vars qw/ $VERSION /; |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
use Carp; |
|
27
|
|
|
|
|
|
|
use POSIX qw(ceil); |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# generic catalog objects |
|
30
|
|
|
|
|
|
|
use Astro::Coords; |
|
31
|
|
|
|
|
|
|
use Astro::Catalog; |
|
32
|
|
|
|
|
|
|
use Astro::Catalog::Star; |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
$VERSION = "4.31"; |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 REVISION |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
$Id: Sesame.pm,v 1.9 2005/07/25 07:45:49 aa Exp $ |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 METHODS |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head2 Constructor |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=over 4 |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=item B |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
Create a new instance from a hash of options |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
$query = new Astro::Catalog::Query::WebService( Object => $target ); |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
returns a reference to an query object. |
|
53
|
|
|
|
|
|
|
=cut |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# base class |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=item B |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Returns an Astro::Catalog object resulting from the specific query. |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
$catalog = $query->querydb(); |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=cut |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub querydb { |
|
66
|
|
|
|
|
|
|
my $self = shift; |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# clean out buffer |
|
69
|
|
|
|
|
|
|
$self->_set_raw(""); |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
my $endpoint = $self->endpoint(); |
|
72
|
|
|
|
|
|
|
my %options = $self->_translate_options(); |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
# return unless we haev a target, set it otherwise |
|
75
|
|
|
|
|
|
|
return undef unless $self->query_options("object"); |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
# make sesame query |
|
78
|
|
|
|
|
|
|
#print "Endpoint: $endpoint\n"; |
|
79
|
|
|
|
|
|
|
my $service = SOAP::Lite->service( $self->endpoint() ); |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
my $ident = $self->query_options("object"); |
|
82
|
|
|
|
|
|
|
$ident =~ s/\+/ /g; |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
my $buffer; |
|
85
|
|
|
|
|
|
|
eval { $buffer = $service->sesame( $ident, "u" ); }; |
|
86
|
|
|
|
|
|
|
if ( $@ ) { |
|
87
|
|
|
|
|
|
|
my $status = $service->transport()->status(); |
|
88
|
|
|
|
|
|
|
croak("Error ($status): $@"); |
|
89
|
|
|
|
|
|
|
return; |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
# parse results & return |
|
93
|
|
|
|
|
|
|
$self->_set_raw( $buffer ); |
|
94
|
|
|
|
|
|
|
my $catalog = $self->_parse_query(); |
|
95
|
|
|
|
|
|
|
return $catalog; |
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=back |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=begin __PRIVATE_METHODS__ |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head2 Private methods |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
These methods are for internal use only. |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=over 4 |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=item B<_default_endpoint> |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=cut |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub _default_endpoint { |
|
113
|
|
|
|
|
|
|
return "http://cdsws.u-strasbg.fr/axis/services/Sesame?wsdl"; |
|
114
|
|
|
|
|
|
|
} |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=item B<_default_urn> |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=cut |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub _default_urn { |
|
121
|
|
|
|
|
|
|
return undef; |
|
122
|
|
|
|
|
|
|
} |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=item B<_is_service> |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=cut |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
sub _is_service { |
|
129
|
|
|
|
|
|
|
return 1; |
|
130
|
|
|
|
|
|
|
} |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=item B<_get_allowed_options> |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Returns a hash with keys, being the internal options supported |
|
135
|
|
|
|
|
|
|
by this subclass, and values being the key name actually required |
|
136
|
|
|
|
|
|
|
by the remote system (and to be included in the query). |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=cut |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
sub _get_allowed_options { |
|
141
|
|
|
|
|
|
|
my $self = shift; |
|
142
|
|
|
|
|
|
|
return ( |
|
143
|
|
|
|
|
|
|
object => 'object' |
|
144
|
|
|
|
|
|
|
); |
|
145
|
|
|
|
|
|
|
} |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=item B<_get_supported_init> |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
Uses base class options. |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=cut |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
# base class |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=item B<_set_default_options> |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Set the default query state. |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=cut |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
sub _set_default_options { |
|
162
|
|
|
|
|
|
|
return ( |
|
163
|
|
|
|
|
|
|
object => undef, |
|
164
|
|
|
|
|
|
|
); |
|
165
|
|
|
|
|
|
|
} |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=item B<_get_supported_init> |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
Return the list of initialization methods supported by this catalogue. |
|
171
|
|
|
|
|
|
|
This is not the same as the allowed options since some methods are |
|
172
|
|
|
|
|
|
|
not related to options and other methods that are related to options |
|
173
|
|
|
|
|
|
|
use different names. |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=cut |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
sub _get_supported_init { |
|
178
|
|
|
|
|
|
|
return (qw/ Target URN Endpoint Proxy /); |
|
179
|
|
|
|
|
|
|
} |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=item B<_parse_query> |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
Private function used to parse the results returned in an USNO-A2.0 query. |
|
184
|
|
|
|
|
|
|
Should not be called directly. Instead use the querydb() assessor method to |
|
185
|
|
|
|
|
|
|
make and parse the results. |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=cut |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
sub _parse_query { |
|
190
|
|
|
|
|
|
|
my $self = shift; |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
# create an Astro::Catalog object to hold the search results |
|
193
|
|
|
|
|
|
|
my $catalog = new Astro::Catalog(); |
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
# create a temporary object to hold stars |
|
196
|
|
|
|
|
|
|
my $star = new Astro::Catalog::Star(); |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
# get a local copy of the current BUFFER |
|
199
|
|
|
|
|
|
|
my @result = $self->_dump_raw(); |
|
200
|
|
|
|
|
|
|
chomp @result; |
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
use Data::Dumper; print Dumper( @result ); |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
# Grab Coordinates |
|
205
|
|
|
|
|
|
|
# ---------------- |
|
206
|
|
|
|
|
|
|
#use Data::Dumper; |
|
207
|
|
|
|
|
|
|
#print Dumper( @result ); |
|
208
|
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
# grab line from return result |
|
210
|
|
|
|
|
|
|
my $coord_line = undef; |
|
211
|
|
|
|
|
|
|
foreach my $i ( 0 ... $#result ) { |
|
212
|
|
|
|
|
|
|
if ( $result[$i] =~ /^%J / ) { |
|
213
|
|
|
|
|
|
|
$coord_line = $i; |
|
214
|
|
|
|
|
|
|
last; |
|
215
|
|
|
|
|
|
|
} |
|
216
|
|
|
|
|
|
|
} |
|
217
|
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
croak "Can not understand response, no co-ordinate line found " |
|
219
|
|
|
|
|
|
|
unless defined $coord_line; |
|
220
|
|
|
|
|
|
|
my $line = $result[$coord_line]; |
|
221
|
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
# split it on \s+ |
|
223
|
|
|
|
|
|
|
my @coords = split( /\s+/,$line); |
|
224
|
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
# GRAB DEC |
|
226
|
|
|
|
|
|
|
# -------- |
|
227
|
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
# create an Astro::Coords::Angle for coordinate conversion |
|
229
|
|
|
|
|
|
|
my $ang = new Astro::Coords::Angle($coords[2], units => 'deg'); |
|
230
|
|
|
|
|
|
|
my $objdec = $ang->string; |
|
231
|
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
# GRAB RA |
|
233
|
|
|
|
|
|
|
# ------- |
|
234
|
|
|
|
|
|
|
$ang = new Astro::Coords::Angle($coords[1]/15.0, units => 'deg'); |
|
235
|
|
|
|
|
|
|
my $objra = $ang->string; |
|
236
|
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
$star->coords( new Astro::Coords(ra => $objra, |
|
238
|
|
|
|
|
|
|
dec => $objdec, |
|
239
|
|
|
|
|
|
|
units => 'sex', |
|
240
|
|
|
|
|
|
|
type => 'J2000', |
|
241
|
|
|
|
|
|
|
name => $self->query_options("object"), |
|
242
|
|
|
|
|
|
|
) ); |
|
243
|
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
# Push the star into the catalog |
|
246
|
|
|
|
|
|
|
$catalog->pushstar( $star ); |
|
247
|
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
# return |
|
249
|
|
|
|
|
|
|
return $catalog; |
|
250
|
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
} |
|
252
|
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
=back |
|
254
|
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
256
|
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
Copyright (C) 2002 University of Exeter. All Rights Reserved. |
|
258
|
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
This program was written as part of the eSTAR project and is free software; |
|
260
|
|
|
|
|
|
|
you can redistribute it and/or modify it under the terms of the GNU Public |
|
261
|
|
|
|
|
|
|
License. |
|
262
|
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
=head1 AUTHORS |
|
264
|
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
Alasdair Allan Eaa@astro.ex.ac.ukE, |
|
266
|
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
=cut |
|
268
|
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
# L A S T O R D E R S ------------------------------------------------------ |
|
270
|
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
1; |