/* osgEarth - Geospatial SDK for OpenSceneGraph
 * Copyright 2020 Pelican Mapping
 * MIT License
 */

#ifndef OSGEARTH_CESIUM_LAYER_H
#define OSGEARTH_CESIUM_LAYER_H

#include "Export"
#include <osgEarth/VisibleLayer>
#include <osgEarth/URI>
#include "CesiumTilesetNode"

namespace osgEarth
{
    namespace Cesium
    {        
        class OSGEARTHCESIUM_EXPORT CesiumNative3DTilesLayer : public VisibleLayer
        {
        public: // serialization
            class OSGEARTHCESIUM_EXPORT Options : public VisibleLayer::Options {
            public:
                META_LayerOptions(osgEarthCesium, Options, VisibleLayer::Options);
                OE_OPTION(URI, server);
                OE_OPTION(URI, url);
                OE_OPTION(unsigned int, assetId);
                OE_OPTION(std::string, token);
                OE_OPTION(int, rasterOverlay);
                OE_OPTION(float, maximumScreenSpaceError);
                OE_OPTION(bool, forbidHoles);

                virtual Config getConfig() const;
            private:
                void fromConfig(const Config& conf);
            };

        public:
            META_Layer(osgEarthCesium, CesiumNative3DTilesLayer, Options, VisibleLayer, CesiumNative3DTiles);

        public:
            void setURL(const URI& value);
            const URI& getURL() const;

            //! Asset identifier
            void setAssetId(unsigned int value);
            unsigned int getAssetId() const;

            //! Auth token
            void setToken(const std::string& value);
            const std::string& getToken() const;

            //! Raster overlay to drape over this 3d tileset
            void setRasterOverlay(int value);
            int getRasterOverlay() const;

            //! The maximum screen space error for this layer
            float getMaximumScreenSpaceError() const;
            void setMaximumScreenSpaceError(float maximumScreenSpaceError);

            //! Whether to forbid holes
            bool getForbidHoles() const;
            void setForbidHoles(bool forbidHoles);

        public: // Layer

            //! Open the layer and return its status
            virtual Status openImplementation();

            //! Node created by this model layer
            virtual osg::Node* getNode() const;

        protected: // Layer

            //! post-ctor initialization
            virtual void init();

            virtual ~CesiumNative3DTilesLayer();

            std::string _key;

            osg::ref_ptr< osgEarth::Cesium::CesiumTilesetNode > _tilesetNode;
        };
    }
} // namespace osgEarth

OSGEARTH_SPECIALIZE_CONFIG(osgEarth::Cesium::CesiumNative3DTilesLayer::Options);

#endif // OSGEARTH_CESIUM_LAYER_H
