aboutsummaryrefslogtreecommitdiff
path: root/vendor/voclient/libvoclient/examples/skybot.c
blob: 78da18cad907cbd28ff498c89d47e41ca1c8b708 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/************************************************************************
 * Call the SkyBoT minor planet service with the specified parameters.
 *
 * Usage:        skybot <ra> <dec> <sr> <jd_epoch>
 *
 * Or call with no args for the built-in unit test.
 *
 *  M. Fitzpatrick, NOAO, August 2006
 */


#include <stdio.h>
#include <stdlib.h>
#include "VOClient.h"


double	ra	= 0.0,		/* RA of search (J2000)		*/
	dec	= 0.0,		/* Dec of search (J2000)	*/
	sr	= 900.0,	/* Search radius (arcsec)	*/
	epoch	= 2454545.0;	/* JD epoch			*/


int main (int argc, char *argv[])
{
    Skybot  sb = (Skybot) NULL;
    int     i, n;


    /*  Process command line arguments or else use built-in defaults.
     */
    if (argc == 5) {
	ra    = atof (argv[1]);
	dec   = atof (argv[2]);
	sr    = atof (argv[3]);
	epoch = atof (argv[4]);
    }
    printf ("#\n#  SkyBoT Service\n#\n#  Search Terms:\n");
    printf ("#\t ra=%f dec=%f sr=%.2f epoch=%f\n#\n", ra, dec, sr, epoch);

    /*  Now call the SkyBoT Service and summarize the results.   We'll 
     *  let the interface initialize the VO Client server and simply call
     *  the procedure we need.
     */
    sb = voc_skybot (ra, dec, sr, sr, epoch);

    printf ("#  Found %d objects\n#\n", (n = voc_skybotNObjs(sb)) );

    for (i = 0; i < n; i++) {
	printf ("%02d: %-12s  ra=%10.6f  dec=%10.6f  Mv=%.2f  R=%.4f\n", i+1,
	    voc_skybotStrAttr(sb, "name", i),
	    voc_skybotDblAttr(sb, "ra", i),
	    voc_skybotDblAttr(sb, "dec", i),
	    voc_skybotDblAttr(sb, "vmag", i),
	    voc_skybotDblAttr(sb, "cdist", i));
    }

    voc_closeVOClient (1);
    return (0);
}