1 /*
2 # This file is part of the Astrometry.net suite.
3 # Licensed under a 3-clause BSD style license - see LICENSE
4 */
5 #include <unistd.h>
6 #include <stdlib.h>
7 #include <stdio.h>
8 #include <math.h>
9 #include <string.h>
10
11 #include "quadfile.h"
12 #include "codekd.h"
13 #include "starkd.h"
14 #include "fitsioutils.h"
15 #include "errors.h"
16 #include "boilerplate.h"
17 #include "ioutils.h"
18 #include "merge-index.h"
19
20 #define OPTIONS "hq:c:s:o:"
21
printHelp(char * progname)22 static void printHelp(char* progname) {
23 BOILERPLATE_HELP_HEADER(stdout);
24 printf("\nUsage: %s\n"
25 " -q <input-quad-filename>\n"
26 " -c <input-code-kdtree-filename>\n"
27 " -s <input-star-kdtree-filename>\n"
28 " -o <output-index-filename>\n"
29 "\n", progname);
30 }
31
32
main(int argc,char ** args)33 int main(int argc, char **args) {
34 int argchar;
35 char* progname = args[0];
36 char* quadfn = NULL;
37 char* codefn = NULL;
38 char* starfn = NULL;
39 char* outfn = NULL;
40
41 while ((argchar = getopt (argc, args, OPTIONS)) != -1)
42 switch (argchar) {
43 case 'q':
44 quadfn = optarg;
45 break;
46 case 'c':
47 codefn = optarg;
48 break;
49 case 's':
50 starfn = optarg;
51 break;
52 case 'o':
53 outfn = optarg;
54 break;
55 case '?':
56 fprintf(stderr, "Unknown option `-%c'.\n", optopt);
57 case 'h':
58 printHelp(progname);
59 return 0;
60 default:
61 return -1;
62 }
63
64 if (!(quadfn && starfn && codefn && outfn)) {
65 printHelp(progname);
66 fprintf(stderr, "\nYou must specify all filenames (-q, -c, -s, -o)\n");
67 exit(-1);
68 }
69
70 fits_use_error_system();
71
72 if (merge_index_files(quadfn, codefn, starfn, outfn)) {
73 exit(-1);
74 }
75 return 0;
76 }
77