BoundingBoxRefine.cpp

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2004 CSIRO ICT Centre
00003  *
00004  * $Id: BoundingBoxRefine.cpp 587 2004-12-03 15:06:33Z nch $
00005  */
00006 
00007 /* BoundingBoxRefine is a Refine that reports
00008  * only those candidate pairs who are close enough to each other than
00009  * the bounding box around the angular threshold circle centred on one
00010  * point contains the other point. */
00011 
00012 #include <iostream>
00013 #include "String.h"
00014 
00015 #include "BoundingBoxRefine.h"
00016 #include "Object.h"
00017 #include "ObjectPairConsumer.h"
00018 
00019 
00020 String BoundingBoxRefine::s_name("Bounding Box Refine");
00021 
00022 
00023 BoundingBoxRefine::BoundingBoxRefine(ObjectPairConsumer * mPPCons,
00024                                      ObjectPairConsumer * uPPCons)
00025     : Refine(mPPCons, uPPCons)
00026 {}
00027 
00028 BoundingBoxRefine::~BoundingBoxRefine()
00029 {}
00030 
00031 /* checks whether the bounding boxes of the two points intersect.
00032  * If so, then a match is passed through for reporting or further
00033  * refinement.  If not, the pair is rejected. */
00034 bool BoundingBoxRefine::refine(Object const * redObject,
00035                                Object const * blueObject)
00036 {
00037   bool result = false;
00038 
00039   double radius = Object::computeDistanceBound(redObject->getSD(),
00040                                               blueObject->getSD());
00041 
00042   // if the distance between the two is less than the sum of their bounds,
00043   // then reject the pair
00044   if (std::abs(redObject->getDec() - blueObject->getDec()) > radius)
00045   {
00046     reportNoMatch(redObject, blueObject);
00047   }
00048   else
00049   {
00050     // for the second parameter, either point will suffice.  The constraint
00051     // will be slightly stronger if we picker the point furthest from the
00052     // equator, but it's not really worth the effort.
00053     double raBound = Object::computeRACorrection(radius, redObject->getDec());
00054 
00055     double distance = blueObject->getRa() - redObject->getRa();
00056     if (distance < 0)
00057       distance = 360 + distance;
00058     if (distance > 180)
00059       distance = 360 - distance;
00060     if (distance > raBound)
00061     {
00062       reportNoMatch(redObject, blueObject);
00063     }
00064     else
00065     {
00066       result = reportMatch(redObject, blueObject);
00067     }
00068   }
00069 
00070   return result;
00071 }
00072 
Generated on Mon Oct 4 10:39:55 2010 for Matching.kdevelop by  doxygen 1.6.3