CR2RE Pipeline Reference Manual 1.6.8
irplib_cat-test.c
1/* $Id: irplib_cat-test.c,v 1.10 2013-01-29 08:43:33 jtaylor Exp $
2 *
3 * This file is part of the ESO Common Pipeline Library
4 * Copyright (C) 2001-2008 European Southern Observatory
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02111-1307 USA
19 */
20
21/*
22 * $Author: jtaylor $
23 * $Date: 2013-01-29 08:43:33 $
24 * $Revision: 1.10 $
25 * $Name: not supported by cvs2svn $
26 */
27
28/*-----------------------------------------------------------------------------
29 Includes
30 -----------------------------------------------------------------------------*/
31#ifdef HAVE_CONFIG_H
32#include <config.h>
33#endif
34
35#include <cpl_test.h>
36
37#include "irplib_cat.h"
38
39/*-----------------------------------------------------------------------------
40 Static functions
41 -----------------------------------------------------------------------------*/
42static void irplib_cat_all_test(void);
43
44/*-----------------------------------------------------------------------------
45 Main
46 -----------------------------------------------------------------------------*/
47int main (void)
48{
49
50 cpl_test_init(PACKAGE_BUGREPORT, CPL_MSG_WARNING);
51
52 irplib_cat_all_test();
53
54 return cpl_test_end(0);
55}
56
57static void irplib_cat_all_test(void)
58{
59 cpl_propertylist * prop_wcs;
60 cpl_wcs * wcs = NULL;
61 double ra1, ra2, dec1, dec2;
62
63 /* Create WCS object */
64 prop_wcs = cpl_propertylist_new();
65 cpl_test_nonnull(prop_wcs);
66 cpl_propertylist_append_double(prop_wcs, "CRVAL1", 0.);
67 cpl_propertylist_append_double(prop_wcs, "CRVAL2", 0.);
68 cpl_propertylist_append_int(prop_wcs, "CRPIX1", 1);
69 cpl_propertylist_append_int(prop_wcs, "CRPIX2", 1);
70 cpl_propertylist_append_double(prop_wcs, "CD1_1", .001);
71 cpl_propertylist_append_double(prop_wcs, "CD1_2", 0.);
72 cpl_propertylist_append_double(prop_wcs, "CD2_1", 00.);
73 cpl_propertylist_append_double(prop_wcs, "CD2_2", .001);
74 cpl_propertylist_append_int(prop_wcs, "NAXIS", 2);
75 cpl_propertylist_append_int(prop_wcs, "NAXIS1", 1000);
76 cpl_propertylist_append_int(prop_wcs, "NAXIS2", 1000);
77 wcs = cpl_wcs_new_from_propertylist(prop_wcs);
78 if(cpl_error_get_code() == CPL_ERROR_NO_WCS)
79 {
80 cpl_msg_warning(__func__,"No WCS present. Tests disabled");
81 cpl_test_error(CPL_ERROR_NO_WCS);
82 cpl_test_null(wcs);
83 cpl_propertylist_delete(prop_wcs);
84 return;
85 }
86 cpl_test_nonnull(wcs);
87
88 irplib_cat_get_image_limits(wcs, 0., &ra1, &ra2, &dec1, &dec2);
89 cpl_test_error(CPL_ERROR_NONE);
90 cpl_test_abs(ra1, 0.00, DBL_EPSILON);
91 cpl_test_abs(ra2, 0.99, DBL_EPSILON);
92 cpl_test_abs(dec1, 0.00, DBL_EPSILON);
93 cpl_test_abs(dec2, 0.99, DBL_EPSILON);
94
95 /* Free */
96 cpl_wcs_delete(wcs);
97 cpl_propertylist_delete(prop_wcs);
98}
cpl_error_code irplib_cat_get_image_limits(const cpl_wcs *wcs, float ext_search, double *ra1, double *ra2, double *dec1, double *dec2)
Get coverage in ra, dec of a frame.
Definition: irplib_cat.c:154