/* -*-c++-*- */
/* osgEarth - Geospatial SDK for OpenSceneGraph
 * Copyright 2020 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/>
 */
#pragma once

#include <osgEarth/FeatureModelLayer>

namespace osgEarth
{
    /**
    * Specialty layer that renders power towers and lines.
    */
    class OSGEARTH_EXPORT PowerlineLayer : public FeatureModelLayer
    {
    public:
        //! Configuration for the towers.
        class ModelOptions : public ConfigOptions
        {
        public:
            META_ConfigOptions(osgEarth, ModelOptions, ConfigOptions);
            OE_OPTION(std::string, name);
            OE_OPTION(std::string, uri);
            OE_OPTION_VECTOR(osg::Vec3d, attachment_points);
            OE_OPTION(float, maxSag);

            void fromConfig(const Config& conf);
            Config getConfig() const override;
        };

        //! Configuration for the lines.
        class OSGEARTH_EXPORT Options : public FeatureModelLayer::Options
        {
        public:
            Options();
            Options(const ConfigOptions& options);
            OE_OPTION(bool, inferTowerLocations, false);
            OE_OPTION(bool, combineLines, true);
            OE_OPTION(StringExpression, towerExpr);
            OE_OPTION(StringExpression, cableStyleExpr);
            OE_OPTION(NumericExpression, numCablesExpr);
            OE_OPTION_VECTOR(ModelOptions, towerModels);
            Config getConfig() const override;
            void fromConfig(const Config& conf);
            std::string referrer;

        protected: // LayerOptions
            virtual void mergeConfig(const Config& conf);        
        };

    public:
        META_Layer(osgEarth, PowerlineLayer, Options, FeatureModelLayer, PowerlineModel);

        void init() override;

        void create() override;

    protected:
        FeatureNodeFactory* createFeatureNodeFactoryImplementation() const override;
    };
}
