read_file.cpp

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2004 CSIRO ICT Centre
00003  *
00004  * $Id: read_file.cpp 587 2004-12-03 15:06:33Z nch $
00005  */
00006 
00007 /*
00008  * This is a simple test program that reads a catalogue file(s),
00009  * checks that it os sorted by declination and calculates the
00010  * the max standard deviations found.
00011  */
00012 
00013 #include <stdio.h>
00014 #include <iostream>
00015 
00016 #include "Object.h"
00017 #include "ObjectProducer.h"
00018 #include "FileProducerFactory.h"
00019 
00020 #ifdef TIMER
00021 #include "Timer.h"
00022 #endif
00023 
00024 int main(int argc, char * argv[])
00025 {
00026   if (argc != 4 && argc != 5 && argc != 6)
00027   {
00028     std::cerr << argv[0] << " <dir|0> <prefix|name> [large] <binary|ascii> [merge]" << std::endl;
00029   }
00030   else
00031   {
00032 #ifdef TIMER
00033     Timer::globalTimer()->cont();        // need to start the timer
00034 #endif
00035 
00036     int param = 1;
00037     char * dir = argv[param++];
00038     char * name = argv[param++];
00039     bool large = false;
00040     if (strcmp(argv[param], "large") == 0)
00041     {
00042       large = true;
00043       param++;
00044     }
00045     bool binary = (strcmp(argv[param++], "binary") == 0);
00046     bool merge = (argc == param+1 && strcmp(argv[param], "merge") == 0);
00047 
00048     ObjectProducer * prod = FileProducerFactory::instance()->
00049                                 createProducer(dir, name, binary, merge, large);
00050 
00051     bool orderOk = true;
00052     double maxSD = 0.0;
00053     double currentDec = -90.0;
00054     unsigned long long cnt = 0;
00055     while (prod->hasNext())
00056     {
00057       Object * obj = prod->next();
00058       if (obj->getDec() < currentDec)
00059         orderOk = false;
00060       currentDec = obj->getDec();
00061       if (obj->getSD() > maxSD)
00062         maxSD = obj->getSD();
00063       delete obj;
00064       cnt++;
00065     }
00066 
00067     std::cout << "Read         : " << cnt << " records." << std::endl;
00068     std::cout << "Dec order is : " << ((orderOk) ? "ok" : "not ok!") << std::endl;
00069     std::cout << "Max SD       : " << maxSD << std::endl;
00070 
00071     delete prod;
00072 
00073 #ifdef TIMER
00074     Timer::globalTimer()->reportTimes();
00075 #endif
00076   }
00077 
00078   return 0;
00079 }
Generated on Mon Oct 4 10:39:55 2010 for Matching.kdevelop by  doxygen 1.6.3