/*****************************************************************************
 * $LastChangedDate: 2009-11-22 22:39:11 -0500 (Sun, 22 Nov 2009) $
 * @file
 * @author  Jim E. Brooks  http://www.palomino3d.org
 * @brief   Planet class is a Facade over ossimplanet or one GIS image.
 * @remarks Planet is a private implementation of the world module.
 *//*
 * LEGAL:   COPYRIGHT (C) 2008 JIM E. BROOKS
 *          THIS SOURCE CODE IS RELEASED UNDER THE TERMS
 *          OF THE GNU GENERAL PUBLIC LICENSE VERSION 2 (GPL 2).
 *****************************************************************************/

#if COMPILE_OSSIM && NEED_PLANET_CLASS
#ifndef WORLD_PLANET_OSSIM_HH
#define WORLD_PLANET_OSSIM_HH 1

class ossimPlanet;
class ossimKeywordlist;
class ossimPlanetGeoRefModel;

namespace world {

////////////////////////////////////////////////////////////////////////////////
/// @brief OssimPlanet class is a Facade over ossimplanet.
///
/// Planet is a private implementation of the world module.
/// Unusually, Planet derivatives are instantiated by the base Planet::GetInstance().
///
class OssimPlanet : public Planet
{
friend class Planet;  // only Planet can instantiate
private:
                            OssimPlanet( void );
                            ~OssimPlanet();

public:
    virtual shptr<Object>   GetRootObject( void );
    virtual bool            IfFlat( void ) { return false; }
    virtual const Matrix&   GetTangentMatrix( const SphereVertex& sv );
    virtual WorldVertex     ComputeUpVector( const SphereVertex& sv );
    virtual WorldVertex     SphereVertex2WorldVertex( const SphereVertex& sv );  // clients of world should use geo::SphereVertex2WorldVertex()
    virtual SphereVertex    WorldVertex2SphereVertex( const WorldVertex& wv );  // clients of world should use geo::WorldVertex2SphereVertex()
    virtual fpx             MeterSimRatio( void );
    virtual fp              RadiusGraphical( void );
    virtual BoxVolume       GetVolume( void );

private:
#if DEBUG
    void                    DebugSelfChecks( void );
#endif
    void                    ChangeKeywordRelativePath( ossimKeywordlist& kwl, const char key[] );
    string                  FindOssimDataDir( void );
    string                  FindOrMakeCacheDir( void );
    void                    RecomputeMeterSimRatio( void );

private:
    shptr0<Object>                  mRootObject;            ///< encapsulates ossimplanet as an Object
    RefPtr<ossimPlanet>             mOssimPlanet;           ///< www.ossim.org
    RefPtr<ossimPlanetGeoRefModel>  mOssimModel;            ///< tweak
    Matrix                          mTangentMatrix;         ///< tangent to a point on the world
    fpx                             mMeterSimRatio;         ///< ratio of meters to a graphical coordinates
    fpx                             mElevationScale;        ///< defined in data/ossim.kwl
};

} // namespace world

#endif // WORLD_PLANET_OSSIM_HH
#endif // COMPILE_OSSIM && NEED_PLANET_CLASS
