/* -*-c++-*- */
/* osgEarth - Dynamic map generation toolkit for OpenSceneGraph
 * Copyright 2008-2014 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_INTERSECT_FEATUREFILTER_OPTIONS
#define OSGEARTH_DRIVER_INTERSECT_FEATUREFILTER_OPTIONS 1

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

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

    /**
     * Options for the Raster feature driver.
     */
    class IntersectFeatureFilterOptions : public ConfigOptions // NO EXPORT; header only
    {
    public:
        IntersectFeatureFilterOptions( const ConfigOptions& opt =ConfigOptions() ) : ConfigOptions( opt )
        {
            _conf.set("driver", "intersect");
            _contains.init( true );
            fromConfig( _conf );
        }

        /** Features to load and use as boundary geometries */
        optional<FeatureSourceOptions>& features() { return _features; }
        const optional<FeatureSourceOptions>& features() const { return _features; }

        /** If true (the default), accept features whose centroids are contained in the boundaries */
        optional<bool>& contains() { return _contains; }
        const optional<bool>& contains() const { return _contains; }

    public:
        Config getConfig() const {
            Config conf = ConfigOptions::getConfig();
            conf.key() = "intersect";
            conf.addObjIfSet( "features", _features );
            conf.addIfSet   ( "contains", _contains );
            return conf;
        }

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

    private:
        void fromConfig( const Config& conf ) {
            conf.getObjIfSet( "features", _features );
            conf.getIfSet   ( "contains", _contains );
        }

        optional<FeatureSourceOptions> _features;
        optional<bool>                 _contains;
    };

} } // namespace osgEarth::Drivers

#endif // OSGEARTH_DRIVER_INTERSECT_FEATUREFILTER_OPTIONS
