/* osgEarth
 * Copyright 2025 Pelican Mapping
 * MIT License
 */
#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(Expression<String>, towerExpr);
            OE_OPTION(Expression<String>, cableStyleExpr);
            OE_OPTION(Expression<int>, 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;
    };
}
