/* $Header: https://oberon.oapd.inaf.it/shins/trunk/shins/src/iif/Interface/Ltcs/Iif/IifStarcat.h 374 2018-01-11 11:43:51Z depa $
*/

#pragma once


#include <vector>
#include <fstream>

#include <Nice/Map.h>
#include <Ltcs/Iif/IifStar.h>
#include <Ltcs/Iif/IifSide.h>

namespace Ltcs
{
/*!************************
* @brief A LbtStarCatSrt object helps to sort a LBTO catalogue by distance.
* @since 2017-01-20
* @author R. J. mathar
*/
class LbtStarCatSrt
{
public:
    LbtStarCatSrt(const IifStar & cntr) ;
    bool operator() (const IifStar &i , const IifStar & j) ;
protected:
private:
    /** The star that defines distance zero. The reference site
    */
    IifStar refstar ;
} ;



/*!************************
* @brief A IifStarcat object is a star catalogue with a set of stars.
* @since 2017-01-18
* @author R. J. mathar
*/
class IifStarcat : public SeqIifStar
{
public:
    /** The catalogue.
    * An unsorted list of stars.
    */
//		std::vector<Ltcs::IifStar> cat ;

    IifStarcat() ;
    IifStarcat(const lbto::SeqPos2 & slist) ;
    IifStarcat(const Ltcs::SeqIifStar & slist) ;
    IifStarcat(const std::string & ifnam, const std::string & typ) ;
    IifStarcat(const Nice::SeqString & ifnam, const std::string & typ) ;

    operator lbto::SeqPos2() const;

    int brightest() const ;

    void add(const Ltcs::IifStar & s ) ;
    void add(const lbto::position2 & p ) ;
    void add(const Ltcs::IifStarcat & s ) ;

    void rmFaint(const double mag) ;
    void rm(const size_t idx) ;
#if 0
    lbto::position2 at(const int idx) const ;
#endif
    IifStarcat keepByDist(const double & close, const double & far) const ;

    IifStarcat roi(const double coord1, const double coord2, const double dist) const ;
    IifStarcat roi(const IifStar & cntr, const double dist) const ;

    virtual std::string toLbtoFmt() ;
    virtual std::string toLbtoFmt(const IifStar & cntr, const Nice::Date & t, const double dist) ;

    IifStarcat propMot() const ;
    IifStarcat propMot(const Nice::Date & t) const ;
    IifStarcat precess() const ;
    IifStarcat precess(const Nice::Date & t) const ;

protected:
		static std::string mkstemp(const char * tmpnam) ;
		void aladin() const ;

private:
protected:
    void cat();
} ;
}
