// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// Copyright 2003 Liam Girdwood
#ifndef _POLLUX_CATALOG_HH
#define _POLLUX_CATALOG_HH
#include <glibmm/dispatcher.h>
#include <vector>
#include "astro_object.hh"
// catalog file data sizes
#define CAT_NAME_SIZE 64
#define CAT_MAINTAINER_SIZE 1024
#define CAT_DATE_SIZE 16
#define CAT_TYPE_SIZE 16
#define CAT_DESCRIPTION_SIZE 4096
#define CAT_HISTORY_SIZE 1024
#define CAT_ACKNOWLEDGE_SIZE 1024
// element data sizes
#define ELEMENT_NAME_SIZE 32
#define ELEMENT_UNIT_SIZE 32
#define ELEMENT_DESCRIPTION_SIZE 255
/*
* catalog is RA_DIV * DEC_DIV * (MAX_MAG - MIN_MAG) array of objects
* MAG_DIV 0 represents naked eye objects
* MAG_DIV0_LIMIT then = 6
*/
#define RA_DIV (360 / 5)
#define DEC_DIV (180 / 5)
#define MAG_MAX 20
#define MAG_MIN -2
#define MAG_EYE 6
/*! \namespace Pollux
* \brief Object Catalog Manager
*
* All classes defined in Pollux are responsible in some way
* of loading, saving, importing and managing object catalogs
*/
namespace Pollux
{
/*! \class Catalog
* \brief catalog of objects.
*
* This class is a container for any single type of astronomical objects.
*
* It stores all deep sky objects in a 3 dimensional array based on ra*dec*mag
* for clipping and quick searching. It also allow catalogs to be split
* into several files.
*
* Near sky objects are stored in a 1 dimensional array depending on
* there semi-major axis.
*/
class Catalog
{
public:
/*! \enum CatType
* \brief Catalog type descriptor
*/
enum CatType {
DEEP, /*<! Deep sky catalog */
NEAR /*<! Near sky catalog */
};
/*! \fn Catalog()
* \brief Constructor
*/
Catalog();
/*! \fn Catalog(std::string& name, std::string& description,
std::string& maintainer, std::string& type,
std::string& created, std::string& version,
std::string& history, std::string& ack);
* \brief Constructor
*/
Catalog(std::string& name, std::string& description,
std::string& maintainer, std::string& type,
std::string& created, std::string& version,
std::string& history, std::string& ack);
/*! \fn ~Catalog()
* \brief Destructor
*/
~Catalog();
/*! \fn bool add (Castor::AstroObject* object);
* \brief add object to the catalog
*/
bool add (Castor::AstroObject* object);
/*! \fn void add_description (std::string& name, std::string& units,
std::string& description);
* \brief Add object description to catalog
*/
void add_description (std::string& name, std::string& units,
std::string& description);
/*! \fn void clip (double min_ra, double min_dec, double max_ra, double max_dec);
* \brief set catalog clipping area
*/
void clip (double min_ra, double min_dec, double max_ra, double max_dec, double min_mag, double max_mag);
/*! \fn void unclip ();
* \brief unset catalog clipping area
*/
void unclip ();
/*! int get_objects (std::vector<Castor::AstroObject*>& result);
* \brief Get objects from catalog
*/
int get_objects (std::vector<Castor::AstroObject*>& result);
/*! \fn int load (std::string& name, std::string& path, Glib::Dispatcher* signal = 0);
* \brief Load catalog from file
*/
int load (std::string& name, std::string& path, Glib::Dispatcher* signal = 0);
/*! \fn int load_partial (std::string& name, std::string& path,
int min_ra, int max_ra,
int min_dec, int max_dec);
* \brief Load partial catalog from file
*/
int load_partial (std::string& name, std::string& path,
int min_ra, int max_ra,
int min_dec, int max_dec);
/*! \fn int save (std::string& name, std::string& path, Glib::Dispatcher* signal = 0);
* \brief Save catalog to file
*/
int save (std::string& name, std::string& path, Glib::Dispatcher* signal = 0);
/*! \fn void get_name (std::string& cat_name);
* \brief Get catalog name
*/
void get_name (std::string& name);
/*! \fn void get_description (std::string& desc);
* \brief Get catalog description
*/
void get_description (std::string& desc);
/*! \fn void get_type (std::string& type);
* \brief Get catalog type
*/
void get_type (std::string& type);
/*! \fn void get_maintainer (std::string& maintainer);
* \brief Get catalog maintainer
*/
void get_maintainer (std::string& maintainer);
/*! \fn void get_date (std::string& date);
* \brief Get catalog creation date
*/
void get_date (std::string& date);
/*! \fn int get_size ();
* \brief Get catalog size
*/
int get_size ();
/*! \fn double get_progress();
* \brief Returns the progress of Catalog load / save.
*/
double get_progress();
/*! \fn void get_ack (std::string& date);
* \brief Get catalog creation date
*/
void get_ack (std::string& ack);
/*! \fn void get_history (std::string& history);
* \brief Get catalog history
*/
void get_history (std::string& history);
/*! \fn void get_version (std::string& history);
* \brief Get catalog version
*/
void get_version (std::string& history);
private:
// object storage
std::vector<Castor::AstroObject*> m_objects[RA_DIV][DEC_DIV][MAG_MAX - MAG_MIN]; /*!< catalog objects */
// catalog info
std::string m_name; /*!< catalog name */
std::string m_description; /*!< catalog description */
std::string m_type; /*!< catalog type */
std::string m_maintainer; /*!< catalog maintainer */
std::string m_date; /*!< catalog creation date */
std::string m_history; /*!< catalog history */
std::string m_acknowledge; /*!< catalog acknowledgements */
std::string m_version; /*!< catalog version */
// catalog file sectors
int m_ra_fdiv; /*!< Number of RA file divisions */
int m_dec_fdiv; /*!< Number of DEC file divisions */
int m_ra_div_fsize; /*!< Size of RA file division in degrees */
int m_dec_div_fsize; /*!< Size of DEC file division in degrees */
// catalog storage data
int m_size; /*!< Number of objects in catalog */
int m_add_size; /*!< Number of elements added to catalog */
int m_ra_div_size; /*!< Size of RA division in degrees */
int m_dec_div_size; /*!< Size of DEC division in degrees */
// load/save progress
double m_progress; /*!< Operation progress 0.0 ... 1.0 */
// clipping
int m_clip_min_ra; /*!< Clipping Min RA */
int m_clip_min_dec; /*!< Clipping Min DEC */
int m_clip_max_ra; /*!< Clipping Max RA */
int m_clip_max_dec; /*!< Clipping Max DEC */
int m_clip_max_mag; /*!< Clipping Max Mag */
int m_clip_min_mag; /*!< Clipping Min Mag */
// new catalog element data
std::vector<std::string> m_unknown_names; /*!< Unknown object data names */
/*! \struct extra_element
* \brief extra element descriptors
*/
struct extra_element
{
std::string name; /*!< Element name */
std::string units; /*!< Element units */
std::string description; /*!< Element description */
};
// extra element vector
std::vector<extra_element> m_extra_info; /*!< Extra element info */
/*! \struct file_header
* \brief Catalog File Header
*/
struct file_header
{
char cat_name[CAT_NAME_SIZE]; /*!< Catalog name*/
char cat_maintainer[CAT_MAINTAINER_SIZE]; /*!< Catalog maintainer */
char cat_date[CAT_DATE_SIZE]; /*!< Catalog creationj date */
char cat_type[CAT_TYPE_SIZE]; /*!< Catalog type */
char cat_description[CAT_DESCRIPTION_SIZE]; /*!< Catalog description */
int cat_size; /*!< Number of objects in catalog */
int unknown_elements; /*!< Number of unkown element descriptions in catalog */
};
/*! \struct file_extra_element
* \brief Description of extra elements in catalog
*/
struct file_extra_element
{
char name[ELEMENT_NAME_SIZE]; /*!< Element Name */
char units[ELEMENT_UNIT_SIZE]; /*!< Element units */
char description[ELEMENT_DESCRIPTION_SIZE]; /*!< Element description */
};
/*! \fn int save_sectors (std::string& file, Glib::Dispatcher* signal = 0);
* \brief Save catalog sectors to file.
*/
int save_sectors (std::string& file, Glib::Dispatcher* signal = 0);
/*! \fn int load_sectors (std::string& file, Glib::Dispatcher* signal = 0);
* \brief Load catalog sectors.
*/
int load_sectors (std::string& file, Glib::Dispatcher* signal = 0);
/*! \fn int load_sectors (std::string& file,
int ra_start, int ra_sectors,
int dec_start, int dec_sectors);
* \brief Load catalog sectors.
*/
int load_sectors (std::string& file,
int ra_start, int ra_sectors,
int dec_start, int dec_sectors);
/*! \fn int load_file (char* file);
* \brief Load a catalog file into memory
*/
int load_file (char* file);
};
}
#endif
syntax highlighted by Code2HTML, v. 0.9.1