/* osgEarth
 * Copyright 2025 Pelican Mapping
 * MIT License
 */
#ifndef OSGEARTH_COMPOSITING_H
#define OSGEARTH_COMPOSITING_H 1

#include <osgEarth/Common>
#include <osgEarth/TileKey>
#include <osg/Referenced>
#include <osg/Image>
#include <vector>

namespace osgEarth { namespace Util
{
    /**
     * Pairs an OSG image with TileKey parameters.
     */
    struct OSGEARTH_EXPORT TileImage
    {
        /**
        *Constructor
        */
        TileImage(const osg::Image* image, const TileKey& key);

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

        /**
        *Gets a reference to the Image held by this GeoImage
        */
        const osg::Image* getImage() {return _image.get();}

        osg::ref_ptr<const osg::Image> _image;       
        double _minX, _minY, _maxX, _maxY;
        unsigned int _tileX;
        unsigned int _tileY;
    };

    /**
     * Utility class for extracting a single image from a collection of image tiles
     */
    class OSGEARTH_EXPORT ImageMosaic : public osg::Referenced
    {
    public:
        ImageMosaic();
        virtual ~ImageMosaic();

        osg::Image* createImage();

        /** A list of GeoImages */
        typedef std::vector<TileImage> TileImageList;

        /** Gets the images for this ImageMosaic */
        TileImageList& getImages() {return _images;}

        void getExtents(double &minX, double &minY, double &maxX, double &maxY);

    protected:

        TileImageList _images;
    };
} }

#endif // OSGEARTH_COMPOSITING_H
