/* -*-c++-*- */
/* osgEarth - Dynamic map generation toolkit for OpenSceneGraph
 * Copyright 2015 Pelican Mapping
 * 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 OSGEARTH_DRIVER_AGGLITE_DRIVEROPTIONS
#define OSGEARTH_DRIVER_AGGLITE_DRIVEROPTIONS 1

#include <osgEarth/Common>
#include <osgEarthFeatures/FeatureTileSource>

namespace osgEarth { namespace Drivers
{
    using namespace osgEarth;
    using namespace osgEarth::Features;

    class AGGLiteOptions : public FeatureTileSourceOptions // NO EXPORT; header only
    {
    public:
        /** 
         * Whether to downsample line features to that they are no higher resolution than
         * the target image resolution. Defaults to true, but you can disable this (for a possible
         * performance increase) if you know your data to be of a relatively low resolution.
         * (Default = true)
         */
        optional<bool>& optimizeLineSampling() { return _optimizeLineSampling; }
        const optional<bool>& optimizeLineSampling() const { return _optimizeLineSampling; }

        /** 
         * Set the gamma parameter applied on the AggLite rasterizer : allow to control geometry antialiasing
         * (Default = 1.3)
         */
        optional<double>& gamma() { return _gamma; }
        const optional<double>& gamma() const { return _gamma; }

    public:
        AGGLiteOptions( const TileSourceOptions& options =TileSourceOptions() )
            : FeatureTileSourceOptions( options ),
              _optimizeLineSampling   ( true ),
              _gamma                  ( 1.3 )
        {
            setDriver( "agglite" );
            fromConfig( _conf );
        }

        /** dtor */
        virtual ~AGGLiteOptions() { }

    public:
        Config getConfig() const {
            Config conf = FeatureTileSourceOptions::getConfig();
            conf.updateIfSet("optimize_line_sampling", _optimizeLineSampling);
            conf.updateIfSet("gamma", _gamma );
            return conf;
        }

    protected:
        void mergeConfig( const Config& conf ) {
            FeatureTileSourceOptions::mergeConfig( conf );
            fromConfig(conf);
        }

    private:
        void fromConfig( const Config& conf ) {
            conf.getIfSet( "optimize_line_sampling", _optimizeLineSampling );
            conf.getIfSet( "gamma", _gamma );
        }

        optional<bool>   _optimizeLineSampling;
        optional<double> _gamma;
    };

} } // namespace osgEarth::Drivers

#endif // OSGEARTH_DRIVER_AGGLITE_DRIVEROPTIONS

