HAWKI Pipeline Reference Manual  1.8.12
hawki_match_cats.c
1 /* $Id: hawki_match_cats.c,v 1.1 2009/11/26 09:52:32 cgarcia Exp $
2  *
3  * This file is part of the HAWKI Pipeline
4  * Copyright (C) 2002,2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  */
20 
21 /*
22  * $Author: cgarcia $
23  * $Date: 2009/11/26 09:52:32 $
24  * $Revision: 1.1 $
25  * $Name: hawki-1_8_12 $
26  */
27 
28 #ifdef HAVE_CONFIG_H
29 #include <config.h>
30 #endif
31 
32 /*-----------------------------------------------------------------------------
33  Includes
34  -----------------------------------------------------------------------------*/
35 
36 #include <float.h>
37 #include <string.h>
38 #include <math.h>
39 #include <cpl.h>
40 
41 #include "hawki_dfs.h"
42 #include "hawki_utils.h"
43 #include "hawki_pfits.h"
44 #include "hawki_match_cats.h"
45 
46 /*----------------------------------------------------------------------------*/
50 /*----------------------------------------------------------------------------*/
51 
54 /*----------------------------------------------------------------------------*/
76 (cpl_table * catalogue1,
77  cpl_table * catalogue2,
78  int iobj1,
79  int iobj2)
80 {
81  static const double max_dist2 = 25;
82 
83  int null;
84  double posx1;
85  double posy1;
86  double posx2;
87  double posy2;
88  double dist2;
89 
90  posx1 =
91  cpl_table_get_double(catalogue1, HAWKI_COL_OBJ_POSX, iobj1, &null);
92  posy1 =
93  cpl_table_get_double(catalogue1, HAWKI_COL_OBJ_POSY, iobj1, &null);
94  posx2 =
95  cpl_table_get_double(catalogue2, HAWKI_COL_OBJ_POSX, iobj2, &null);
96  posy2 =
97  cpl_table_get_double(catalogue2, HAWKI_COL_OBJ_POSY, iobj2, &null);
98 
99  dist2 = (posx1 - posx2) * (posx1 - posx2) + (posy1 - posy2) * (posy1 - posy2);
100  if(dist2 <= max_dist2)
101  return 1;
102 
103  return 0;
104 }
105