2 * Copyright (C) 2008 Liam Girdwood
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330,
17 * Boston, MA 02111-1307, USA.
26 #define CAT_HOME NOVA_CATALOG_DIR
33 struct astro_object
*object
;
34 struct astrodb_db
*cat
;
35 struct astrodb_table
*table
;
38 struct astro_object star_table
= {
40 .init
= star_object_init
,
41 .free
= star_object_free
,
42 .render
= star_object_render
,
45 /* default datasets */
46 static struct table_desc dlib
[] = {
47 {"Sky2000", "V", "109", "sky2kv4", &star_table
},
50 static struct table_desc olib
[16];
52 static struct astrodb_library
*nova_lib
;
58 nova_lib
= astrodb_open_library("ftp://cdsarc.u-strasbg.fr/pub/cats",
61 g_critical("failed to open astro library at %s\n", CAT_HOME
);
63 for (i
= 0; i
< astrodb_size(dlib
); i
++) {
65 /* ra,dec,mag bounds are set here along with the 3D
67 dlib
[i
].cat
= astrodb_create_db(nova_lib
, dlib
[i
].class,
72 if (dlib
[i
].cat
== NULL
)
73 g_critical("failed to create db for class %s num %s\n",
74 dlib
[i
].class, dlib
[i
].num
);
76 /* use the first dataset in this example */
77 dlib
[i
].table
= astrodb_table_create(dlib
[i
].cat
,
80 if (dlib
[i
].table
== NULL
)
81 g_critical("failed to create table %s\n",
84 if (dlib
[i
].object
->init
)
85 dlib
[i
].object
->init(dlib
[i
].table
);
94 for (i
= 0; i
< astrodb_size(dlib
); i
++) {
95 if (dlib
[i
].object
->free
)
96 dlib
[i
].object
->free(dlib
[i
].table
);
97 astrodb_db_free(dlib
[i
].cat
);
99 astrodb_close_library(nova_lib
);
102 struct astrodb_table
*db_get_table(gchar
*name
)
106 for (i
= 0; i
< astrodb_size(olib
); i
++) {
107 if (!strncmp(name
, olib
[i
].table_name
, strlen(name
)))
108 return olib
[i
].table
;
114 struct astrodb_table
*db_get_default_table(gchar
*type
)
118 for (i
= 0; i
< astrodb_size(dlib
); i
++) {
119 if (!strncmp(type
, dlib
[i
].object
->type
, strlen(type
)))
120 return dlib
[i
].table
;