/* -*-c++-*- */
/* osgEarth - Dynamic map generation toolkit for OpenSceneGraph
 * Copyright 2008-2009 Pelican Ventures, Inc.
 * http://osgearth.org
 *
 * osgEarth is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
 */
#ifndef SEAMLESS_GEOGRAPHIC
#define SEAMLESS_GEOGRAPHIC 1

#include <vector>

#include <osg/CoordinateSystemNode>
#include <osg/MatrixTransform>
#include <osg/Vec3d>

#include <osgEarth/GeoData>
#include <osgEarth/Map>
#include <osgEarth/TaskService>
#include <osgEarth/TileKey>

#include "PatchSet"
#include "Euler"

namespace seamless
{
class Geographic : public PatchSet
{
public:
    Geographic(const osgEarth::Map* map,
               const osgEarth::Drivers::SeamlessOptions& options);
    Geographic(const Geographic& rhs,
               const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
    META_Object(seamless, PatchSet);
    virtual ~Geographic();
    virtual osg::Node* createPatchGroup(const std::string& filename,
                                        PatchOptions* poptions);
    virtual osg::Transform* createPatch(const std::string& filename,
                                        PatchOptions* poptions);
    virtual osg::Node* createPatchSetGraph(const std::string& filename);
    virtual osg::Node* createChild(const PatchOptions* parentOptions, int childNum);
    osgEarth::Profile* getProfile() const { return _profile.get(); }
    void setEllipsoidModel(osg::EllipsoidModel* eModel) { _eModel = eModel; }
    osg::EllipsoidModel* getEllipsoidModel() const { return _eModel.get(); }
    osg::Vec3d toModel(double cubeX, double cubeY, double elevation);
    // Updates to the terrain are mostly done in task requests.
    osgEarth::TaskService* getHeightFieldService() { return _hfService; }
    osgEarth::TaskService* getImageService() { return _imageService; }
protected:
    osg::ref_ptr<EulerProfile> _profile;
    osg::ref_ptr<osg::EllipsoidModel> _eModel;
    osg::ref_ptr<osgEarth::TaskService> _hfService;
    osg::ref_ptr<osgEarth::TaskService> _imageService;
};

}
#endif
