//
//  CoordRep.h
//  Qdos2 - Generic Coordinate Representatiom Class 
//
//  Janet Barnes
//  Nov 2000
//

#ifndef QDOS_COORD_REP_H
#define QDOS_COORD_REP_H

#include <string>
#include <map>
#include "CoordSys.h"
#include "Exception.h"
#include "Sequence.h"

namespace QDOS{

// default strings
#define XYZ "xyz"
#define X "x"
#define Y "y"
#define Z "z"
#define RTP "rtp"
#define RTP_DEG "rtp(deg)"
#define MAG "r(mag)"
#define THETA "theta(rad)"
#define THETA_DEG "theta(deg)"
#define PHI "phi(rad)"
#define PHI_DEG "phi(deg)"
#define RLP "rlp"
#define RLP_DEG "rlp(deg)"
#define LAT "Lat(rad)"
#define LAT_DEG "Lat(deg)"

class CoordRepConvException: public Exception
{
public:
    CoordRepConvException(ExceptionMsg m=""):\
        Exception(m<<"[CoordRepConvException]"){;}
};

template<class T1, class T2> class CoordRepConv;

template<class T1, class T2>
class CoordRep
{
protected:
    typedef map<string,CoordRepConv<T1,T2>* > CoordRepConvMap;
    
public:
    virtual typename CoordRep<T1,T2>::CoordRepConvMap& coordrepconv()=0;
    virtual CoordRepConv<T1,T2>* get_coordrepconv(string vcomp)
    { return coordrepconv()[vcomp];}
    
    virtual ~CoordRep(){;}
    
    void set_coordrepconv(string vcomp,CoordRepConv<T1,T2>* ptr)
    { coordrepconv()[vcomp]=ptr;}
};


template<class T1,class T2>
class RLP_CoordRep:public CoordRep<T1,T2>
{
    typename CoordRep<T1,T2>::CoordRepConvMap _coordrepconv;
public:
    RLP_CoordRep();
 
    ~RLP_CoordRep()
    { typename CoordRep<T1,T2>::CoordRepConvMap::iterator itr;
      for(itr=_coordrepconv.begin();itr!=_coordrepconv.end();itr++)
          delete itr->second;
    }
        
    virtual typename CoordRep<T1,T2>::CoordRepConvMap& coordrepconv()
    { return _coordrepconv;}
 
};  

template<class T1,class T2>
class RLP_DEG_CoordRep:public CoordRep<T1,T2>
{
    typename CoordRep<T1,T2>::CoordRepConvMap _coordrepconv;
public:
    RLP_DEG_CoordRep();
   
    ~RLP_DEG_CoordRep()
    { typename CoordRep<T1,T2>::CoordRepConvMap::iterator itr;
      for(itr=_coordrepconv.begin();itr!=_coordrepconv.end();itr++)
          delete itr->second;
    }
    
    virtual typename CoordRep<T1,T2>::CoordRepConvMap& coordrepconv()
    { return _coordrepconv;}
 
};  


template<class T1,class T2>
class RTP_CoordRep:public CoordRep<T1,T2>
{
    typename CoordRep<T1,T2>::CoordRepConvMap _coordrepconv;
public:
    RTP_CoordRep();
    
    ~RTP_CoordRep()
    { typename CoordRep<T1,T2>::CoordRepConvMap::iterator itr;
      for(itr=_coordrepconv.begin();itr!=_coordrepconv.end();itr++)
          delete itr->second;
    }
    
    virtual typename CoordRep<T1,T2>::CoordRepConvMap& coordrepconv()
    { return _coordrepconv;}
 
}; 

template<class T1,class T2>
class RTP_DEG_CoordRep:public CoordRep<T1,T2>
{
    typename CoordRep<T1,T2>::CoordRepConvMap _coordrepconv;
public:
    RTP_DEG_CoordRep();
    
    ~RTP_DEG_CoordRep()
    { typename CoordRep<T1,T2>::CoordRepConvMap::iterator itr;
      for(itr=_coordrepconv.begin();itr!=_coordrepconv.end();itr++)
          delete itr->second;
    }
    
    virtual typename CoordRep<T1,T2>::CoordRepConvMap& coordrepconv()
    { return _coordrepconv;}
 
};   

template<class T1,class T2>
class XYZ_CoordRep:public CoordRep<T1,T2>
{
    typename CoordRep<T1,T2>::CoordRepConvMap _coordrepconv;
public:
    XYZ_CoordRep();
  
    ~XYZ_CoordRep()
    { typename CoordRep<T1,T2>::CoordRepConvMap::iterator itr;
      for(itr=_coordrepconv.begin();itr!=_coordrepconv.end();itr++)
          delete itr->second;
    }
    
    virtual typename CoordRep<T1,T2>::CoordRepConvMap& coordrepconv()
    { return _coordrepconv;}
    
};  

template<class T1,class T2>
class CoordRepConv
{
public:
    virtual void get_vcomp(const T1& inrep, T2& out_rep) const=0;
    //virtual void get_vcomp(const T1& inrep, const T2& out_rep) const=0;
};

template<class T1, class T2>
class RLP_MAG:public CoordRepConv<T1,T2>
{
public:
    virtual void get_vcomp(const T1& inrep, T2& outrep) const
    { outrep=inrep[0];}
    //virtual void get_vcomp(const T1& inrep, const T2& outrep) const
    //{ outrep=inrep[0];}
};

template<class T1, class T2>
class RLP_LAT:public CoordRepConv<T1,T2>
{
public:
    virtual void get_vcomp(const T1& inrep, T2& outrep) const
    { outrep=inrep[1];}
    //virtual void get_vcomp(const T1& inrep, const T2& outrep) const
    //{ outrep=inrep[1];}
};

template<class T1, class T2>
class RLP_LAT_DEG:public CoordRepConv<T1,T2>
{
public:
    virtual void get_vcomp(const T1& inrep, T2& outrep) const
    { rad_to_deg(inrep[1],outrep);}
    //virtual void get_vcomp(const T1& inrep, const T2& outrep) const
    //{ rad_to_deg(inrep[1],outrep);}
};

template<class T1, class T2>
class RLP_DEG_LAT:public CoordRepConv<T1,T2>
{
public:
    virtual void get_vcomp(const T1& inrep, T2& outrep) const
    { deg_to_rad(inrep[1],outrep);}
    //virtual void get_vcomp(const T1& inrep, const T2& outrep) const
    //{ deg_to_rad(inrep[1],outrep);}
};

template<class T1, class T2>
class RLP_THETA:public CoordRepConv<T1,T2>
{
public:
    virtual void get_vcomp(const T1& inrep, T2& outrep) const
    { T1 pi_by_2=2*atan((T1)1); outrep=pi_by_2-inrep[1];}
    //virtual void get_vcomp(const T1& inrep, const T2& outrep) const
    //{ T1 pi_by_2=2*atan((T1)1); outrep=pi_by_2-inrep[1];}
};

template<class T1, class T2>
class RLP_THETA_DEG:public CoordRepConv<T1,T2>
{
public:
    virtual void get_vcomp(const T1& inrep, T2& outrep) const
    { T1 pi_by_2=2*atan((T1)1); rad_to_deg(pi_by_2-inrep[1],outrep);}
    //virtual void get_vcomp(const T1& inrep, const T2& outrep) const
    //{ T1 pi_by_2=2*atan((T1)1); rad_to_deg(pi_by_2-inrep[1],outrep);}
};

template<class T1, class T2>
class RLP_DEG_THETA:public CoordRepConv<T1,T2>
{
public:
    virtual void get_vcomp(const T1& inrep, T2& outrep) const
    { deg_to_rad((T1)90-inrep[1],outrep); }
    //virtual void get_vcomp(const T1& inrep, const T2& outrep) const
    //{ deg_to_rad((T1)90-inrep[1],outrep); }
};

template<class T1, class T2>
class RLP_DEG_THETA_DEG:public CoordRepConv<T1,T2>
{
public:
    virtual void get_vcomp(const T1& inrep, T2& outrep) const
    { outrep=(T1)90-inrep[1]; }
    //virtual void get_vcomp(const T1& inrep, const T2& outrep) const
    //{ outrep=(T1)90-inrep[1]; }
};

template<class T1, class T2>
class RLP_PHI:public CoordRepConv<T1,T2>
{
public:
    virtual void get_vcomp(const T1& inrep, T2& outrep) const
    { outrep=inrep[2];}
    //virtual void get_vcomp(const T1& inrep, const T2& outrep) const
    //{ outrep=inrep[2];}
};

template<class T1, class T2>
class RLP_PHI_DEG:public CoordRepConv<T1,T2>
{
public:
    virtual void get_vcomp(const T1& inrep, T2& outrep) const
    { rad_to_deg(inrep[2],outrep);}
    //virtual void get_vcomp(const T1& inrep, const T2& outrep) const
    //{ rad_to_deg(inrep[2],outrep);}
};

template<class T1, class T2>
class RLP_DEG_PHI:public CoordRepConv<T1,T2>
{
public:
    virtual void get_vcomp(const T1& inrep, T2& outrep) const
    { deg_to_rad(inrep[2],outrep);}
    //virtual void get_vcomp(const T1& inrep, const T2& outrep) const
    //{ deg_to_rad(inrep[2],outrep);}
};

template<class T1, class T2>
class RLP_X:public CoordRepConv<T1,T2>
{
public:
    virtual void get_vcomp(const T1& inrep, T2& outrep) const
    { rlp_to_x(inrep[0],inrep[1],inrep[2],outrep);}
    //virtual void get_vcomp(const T1& inrep, const T2& outrep) const
    //{ rlp_to_x(inrep[0],inrep[1],inrep[2],outrep);}
};

template<class T1, class T2>
class RLP_DEG_X:public CoordRepConv<T1,T2>
{
public:
    virtual void get_vcomp(const T1& inrep, T2& outrep) const
    { rlp_deg_to_x(inrep[0],inrep[1],inrep[2],outrep);}
    //virtual void get_vcomp(const T1& inrep, const T2& outrep) const
    //{ rlp_deg_to_x(inrep[0],inrep[1],inrep[2],outrep);}
};

template<class T1, class T2>
class RLP_Y:public CoordRepConv<T1,T2>
{
public:
    virtual void get_vcomp(const T1& inrep, T2& outrep) const
    { rlp_to_y(inrep[0],inrep[1],inrep[2],outrep);}
    //virtual void get_vcomp(const T1& inrep, const T2& outrep) const
    //{ rlp_to_y(inrep[0],inrep[1],inrep[2],outrep);}
};

template<class T1, class T2>
class RLP_DEG_Y:public CoordRepConv<T1,T2>
{
public:
    virtual void get_vcomp(const T1& inrep, T2& outrep) const
    { rlp_deg_to_y(inrep[0],inrep[1],inrep[2],outrep);}
    //virtual void get_vcomp(const T1& inrep, const T2& outrep) const
    //{ rlp_deg_to_y(inrep[0],inrep[1],inrep[2],outrep);}
};

template<class T1, class T2>
class RLP_Z:public CoordRepConv<T1,T2>
{
public:
    virtual void get_vcomp(const T1& inrep, T2& outrep) const
    { rlp_to_z(inrep[0],inrep[1],inrep[2],outrep);}
    //virtual void get_vcomp(const T1& inrep, const T2& outrep) const
    //{ rlp_to_z(inrep[0],inrep[1],inrep[2],outrep);}
};

template<class T1, class T2>
class RLP_DEG_Z:public CoordRepConv<T1,T2>
{
public:
    virtual void get_vcomp(const T1& inrep, T2& outrep) const
    { rlp_deg_to_z(inrep[0],inrep[1],inrep[2],outrep);}
    //virtual void get_vcomp(const T1& inrep, const T2& outrep) const
    //{ rlp_deg_to_z(inrep[0],inrep[1],inrep[2],outrep);}
};


template<class T1, class T2>
class RTP_X:public CoordRepConv<T1,T2>
{
public:
    virtual void get_vcomp(const T1& inrep, T2& outrep) const
    { rtp_to_x(inrep[0],inrep[1],inrep[2],outrep);}
    //virtual void get_vcomp(const T1& inrep, const T2& outrep) const
    //{ rtp_to_x(inrep[0],inrep[1],inrep[2],outrep);}
};

template<class T1, class T2>
class RTP_DEG_X:public CoordRepConv<T1,T2>
{
public:
    virtual void get_vcomp(const T1& inrep, T2& outrep) const
    { rtp_deg_to_x(inrep[0],inrep[1],inrep[2],outrep);}
    //virtual void get_vcomp(const T1& inrep, const T2& outrep) const
    //{ rtp_deg_to_x(inrep[0],inrep[1],inrep[2],outrep);}
};


template<class T1, class T2>
class RTP_Y:public CoordRepConv<T1,T2>
{
public:
    virtual void get_vcomp(const T1& inrep, T2& outrep) const
    { rtp_to_y(inrep[0],inrep[1],inrep[2],outrep);}
    //virtual void get_vcomp(const T1& inrep, const T2& outrep) const
    //{ rtp_to_y(inrep[0],inrep[1],inrep[2],outrep);}
};

template<class T1, class T2>
class RTP_DEG_Y:public CoordRepConv<T1,T2>
{
public:
    virtual void get_vcomp(const T1& inrep, T2& outrep) const
    { rtp_deg_to_y(inrep[0],inrep[1],inrep[2],outrep);}
    //virtual void get_vcomp(const T1& inrep, const T2& outrep) const
    //{ rtp_deg_to_y(inrep[0],inrep[1],inrep[2],outrep);}
};


template<class T1, class T2>
class RTP_Z:public CoordRepConv<T1,T2>
{
public:
    virtual void get_vcomp(const T1& inrep, T2& outrep) const
    { rtp_to_z(inrep[0],inrep[1],inrep[2],outrep);}
    //virtual void get_vcomp(const T1& inrep, const T2& outrep) const
    //{ rtp_to_z(inrep[0],inrep[1],inrep[2],outrep);}
};

template<class T1, class T2>
class RTP_DEG_Z:public CoordRepConv<T1,T2>
{
public:
    virtual void get_vcomp(const T1& inrep, T2& outrep) const
    { rtp_deg_to_z(inrep[0],inrep[1],inrep[2],outrep);}
    //virtual void get_vcomp(const T1& inrep, const T2& outrep) const
    //{ rtp_deg_to_z(inrep[0],inrep[1],inrep[2],outrep);}
};

template<class T1, class T2>
class XYZ_MAG:public CoordRepConv<T1,T2>
{
public:
    virtual void get_vcomp(const T1& inrep, T2& outrep) const
    { xyz_to_r(inrep[0],inrep[1],inrep[2],outrep);}
    //virtual void get_vcomp(const T1& inrep, const T2& outrep) const
    //{ xyz_to_r(inrep[0],inrep[1],inrep[2],outrep);}
};

template<class T1, class T2>
class XYZ_THETA:public CoordRepConv<T1,T2>
{
public:
    virtual void get_vcomp(const T1& inrep, T2& outrep) const
    { xyz_to_t(inrep[0],inrep[1],inrep[2],outrep);}
    //virtual void get_vcomp(const T1& inrep, const T2& outrep) const
    //{ xyz_to_t(inrep[0],inrep[1],inrep[2],outrep);}
};

template<class T1, class T2>
class XYZ_THETA_DEG:public CoordRepConv<T1,T2>
{
public:
    virtual void get_vcomp(const T1& inrep, T2& outrep) const
    { xyz_to_t_deg(inrep[0],inrep[1],inrep[2],outrep);}
    //virtual void get_vcomp(const T1& inrep, const T2& outrep) const
    //{ xyz_to_t_deg(inrep[0],inrep[1],inrep[2],outrep);}
};

template<class T1, class T2>
class XYZ_LAT:public CoordRepConv<T1,T2>
{
public:
    virtual void get_vcomp(const T1& inrep, T2& outrep) const
    { xyz_to_l(inrep[0],inrep[1],inrep[2],outrep);}
    //virtual void get_vcomp(const T1& inrep, const T2& outrep) const
    //{ xyz_to_l(inrep[0],inrep[1],inrep[2],outrep);}
};

template<class T1, class T2>
class XYZ_LAT_DEG:public CoordRepConv<T1,T2>
{
public:
    virtual void get_vcomp(const T1& inrep, T2& outrep) const
    { xyz_to_l_deg(inrep[0],inrep[1],inrep[2],outrep);}
    //virtual void get_vcomp(const T1& inrep, const T2& outrep) const
    //{ xyz_to_l_deg(inrep[0],inrep[1],inrep[2],outrep);}
};

template<class T1, class T2>
class XYZ_PHI:public CoordRepConv<T1,T2>
{
public:
    virtual void get_vcomp(const T1& inrep, T2& outrep) const
    { xyz_to_p(inrep[0],inrep[1],inrep[2],outrep);}
    //virtual void get_vcomp(const T1& inrep, const T2& outrep) const
    //{ xyz_to_p(inrep[0],inrep[1],inrep[2],outrep);}
};

template<class T1, class T2>
class XYZ_PHI_DEG:public CoordRepConv<T1,T2>
{
public:
    virtual void get_vcomp(const T1& inrep, T2& outrep) const
    { xyz_to_p_deg(inrep[0],inrep[1],inrep[2],outrep);}
    //virtual void get_vcomp(const T1& inrep, const T2& outrep) const
    //{ xyz_to_p_deg(inrep[0],inrep[1],inrep[2],outrep);}
};

template<class T1, class T2>
class XYZ_X:public CoordRepConv<T1,T2>
{
public:
    virtual void get_vcomp(const T1& inrep, T2& outrep) const
    { outrep=inrep[0];}
    //virtual void get_vcomp(const T1& inrep, const T2& outrep) const
    //{ outrep=inrep[0];}
};

template<class T1, class T2>
class XYZ_Y:public CoordRepConv<T1,T2>
{
public:
    virtual void get_vcomp(const T1& inrep, T2& outrep) const
    { outrep=inrep[1];}
    //virtual void get_vcomp(const T1& inrep, const T2& outrep) const
    //{ outrep=inrep[1];}
};

template<class T1, class T2>
class XYZ_Z:public CoordRepConv<T1,T2>
{
public:
    virtual void get_vcomp(const T1& inrep, T2& outrep) const
    { outrep=inrep[2];}
    //virtual void get_vcomp(const T1& inrep, const T2& outrep) const
    //{ outrep=inrep[2];}
};
    
template<class T1, class T2>
class CoordRepConversion
{
   typedef map<string,CoordRep<T1,T2>*> CoordRepMap;

   CoordRepMap _coordreps;

public:
    CoordRepConversion()
    { set_coordrep(XYZ,new XYZ_CoordRep<T1,T2>());
      set_coordrep(RTP,new RTP_CoordRep<T1,T2>());
      set_coordrep(RLP,new RLP_CoordRep<T1,T2>());
      set_coordrep(RTP_DEG,new RTP_DEG_CoordRep<T1,T2>());
      set_coordrep(RLP_DEG,new RLP_DEG_CoordRep<T1,T2>());
    }
    ~CoordRepConversion()
    {
        typename CoordRepMap::iterator itr;
        for(itr=_coordreps.begin();itr!=_coordreps.end();itr++)
            delete itr->second;
    }

    void get_vcomp(string in_coordrep, string vcomp,\
       const NumericSequence<T1>& in_seq, \
       NumericSequence<T2>& out_seq)
    {
        CoordRep<T1,T2>* coordrep=get_coordrep(in_coordrep);
        if(coordrep==0)
            throw CoordRepConvException("'"+in_coordrep+"' not defined!");

        CoordRepConv<T1,T2>* coordrep_conv=coordrep->get_coordrepconv(vcomp);
        if(coordrep_conv==0)
            throw CoordRepConvException(vcomp+" not defined for "\
                +in_coordrep+"!");

        int sz=in_seq.size();
        out_seq.resize(sz);
        for(int i=0;i<sz;i++)
        {
            T2& out_ref=out_seq[i];
            coordrep_conv->get_vcomp(in_seq[i],out_ref);
        }
    }

    void get_vcomp(string in_coordrep, string vcomp,const T1& in_ref, T2& out_ref)
    {
        CoordRep<T1,T2>* coordrep=get_coordrep(in_coordrep);
        if(coordrep==0)
            throw CoordRepConvException("'"+in_coordrep+"' not defined!");

        CoordRepConv<T1,T2>* coordrep_conv=coordrep->get_coordrepconv(vcomp);
        if(coordrep_conv==0)
            throw CoordRepConvException(vcomp+" not defined for "\
                +in_coordrep+"!");

        coordrep_conv->get_vcomp(in_ref,out_ref);
    }

    CoordRep<T1,T2>* get_coordrep(string in_coordrep)
    { return _coordreps[in_coordrep];}

    void set_coordrep(string in_coordrep,CoordRep<T1,T2>* ptr)
    {
        CoordRep<T1,T2>* optr=get_coordrep(in_coordrep);
        if(!optr)
            delete optr; 
        _coordreps[in_coordrep]=ptr;
    }
};

template<class T1, class T2>
RLP_CoordRep<T1,T2>::RLP_CoordRep()
{ 
    set_coordrepconv(MAG,new RLP_MAG<T1,T2>());
    set_coordrepconv(LAT,new RLP_LAT<T1,T2>());
    set_coordrepconv(LAT_DEG,new RLP_LAT_DEG<T1,T2>());
    set_coordrepconv(THETA,new RLP_THETA<T1,T2>());
    set_coordrepconv(THETA_DEG,new RLP_THETA_DEG<T1,T2>());
    set_coordrepconv(PHI,new RLP_PHI<T1,T2>());
    set_coordrepconv(PHI_DEG,new RLP_PHI_DEG<T1,T2>());
    set_coordrepconv(X,new RLP_X<T1,T2>());
    set_coordrepconv(Y,new RLP_Y<T1,T2>());
    set_coordrepconv(Z,new RLP_Z<T1,T2>());
}

template<class T1, class T2>
RLP_DEG_CoordRep<T1,T2>::RLP_DEG_CoordRep()
{ 
    set_coordrepconv(MAG,new RLP_MAG<T1,T2>());
    set_coordrepconv(LAT,new RLP_DEG_LAT<T1,T2>());
    set_coordrepconv(LAT_DEG,new RLP_LAT<T1,T2>());
    set_coordrepconv(THETA,new RLP_DEG_THETA<T1,T2>());
    set_coordrepconv(THETA_DEG,new RLP_DEG_THETA_DEG<T1,T2>());
    set_coordrepconv(PHI,new RLP_DEG_PHI<T1,T2>());
    set_coordrepconv(PHI_DEG,new RLP_PHI<T1,T2>());
    set_coordrepconv(X,new RLP_DEG_X<T1,T2>());
    set_coordrepconv(Y,new RLP_DEG_Y<T1,T2>());
    set_coordrepconv(Z,new RLP_DEG_Z<T1,T2>());
}

template<class T1, class T2>
RTP_CoordRep<T1,T2>::RTP_CoordRep()
{ 
    set_coordrepconv(MAG,new RLP_MAG<T1,T2>());
    set_coordrepconv(PHI,new RLP_PHI<T1,T2>());
    set_coordrepconv(PHI_DEG,new RLP_PHI_DEG<T1,T2>());
    set_coordrepconv(THETA,new RLP_LAT<T1,T2>());
    set_coordrepconv(THETA_DEG,new RLP_LAT_DEG<T1,T2>());
    set_coordrepconv(LAT,new RLP_THETA<T1,T2>());
    set_coordrepconv(LAT_DEG,new RLP_THETA_DEG<T1,T2>());
    set_coordrepconv(X,new RTP_X<T1,T2>());
    set_coordrepconv(Y,new RTP_Y<T1,T2>());
    set_coordrepconv(Z,new RTP_Z<T1,T2>());
}

template<class T1, class T2>
RTP_DEG_CoordRep<T1,T2>::RTP_DEG_CoordRep()
{ 
    set_coordrepconv(MAG,new RLP_MAG<T1,T2>());
    set_coordrepconv(PHI,new RLP_DEG_PHI<T1,T2>());
    set_coordrepconv(PHI_DEG,new RLP_PHI<T1,T2>());
    set_coordrepconv(THETA,new RLP_DEG_LAT<T1,T2>());
    set_coordrepconv(THETA_DEG,new RLP_LAT<T1,T2>());
    set_coordrepconv(LAT,new RLP_DEG_THETA<T1,T2>());
    set_coordrepconv(LAT_DEG,new RLP_DEG_THETA_DEG<T1,T2>());
    set_coordrepconv(X,new RTP_DEG_X<T1,T2>());
    set_coordrepconv(Y,new RTP_DEG_Y<T1,T2>());
    set_coordrepconv(Z,new RTP_DEG_Z<T1,T2>());
}

template<class T1, class T2>
XYZ_CoordRep<T1,T2>::XYZ_CoordRep()
{ 
    set_coordrepconv(MAG,new XYZ_MAG<T1,T2>());
    set_coordrepconv(PHI,new XYZ_PHI<T1,T2>());
    set_coordrepconv(PHI_DEG,new XYZ_PHI_DEG<T1,T2>());
    set_coordrepconv(THETA,new XYZ_THETA<T1,T2>());
    set_coordrepconv(THETA_DEG,new XYZ_THETA_DEG<T1,T2>());
    set_coordrepconv(LAT,new XYZ_LAT<T1,T2>());
    set_coordrepconv(LAT_DEG,new XYZ_LAT_DEG<T1,T2>());
    set_coordrepconv(X,new XYZ_X<T1,T2>());
    set_coordrepconv(Y,new XYZ_Y<T1,T2>());
    set_coordrepconv(Z,new XYZ_Z<T1,T2>());
}
    


}  // end namespace QDOS
#endif
