/* osgEarth
 * Copyright 2025 Pelican Mapping
 * MIT License
 */
#pragma once

#include <osgEarth/Common>
#include <osgEarth/GeoData>
#include <osgEarth/TileKey>
#include <osgEarth/Units>

namespace osgEarth
{
    /**
     * A query filter that you can use to limit a set of symbology to process.
     */
    class OSGEARTH_EXPORT Query
    {
    public:
        //! Default constructor
        Query() = default;

        //! Copy constructor
        Query(const Query& rhs) = default;

        //! Construct from a serialized representation
        Query(const Config& conf);

        //! Construct from a tile key
        Query(const TileKey& key);

    public: // properties

        //! geospatial extent bounding this query when not using a tile key
        OE_OPTION(Bounds, bounds);

        //! Driver-specific query expression
        OE_OPTION(std::string, expression);

        //! Driver-specific orderby expression
        OE_OPTION(std::string, orderby);

        //! Sets tilekey to use for tiled feature sources
        OE_OPTION(TileKey, tileKey);

        //! Optional buffer to use with a tile key
        OE_OPTION(Distance, buffer);

        //! Maximum number of features to be returned by this Query
        OE_OPTION(int, limit);

        /** Merges this query with another query, and returns the result */
        Query combineWith( const Query& other ) const;

    public: // configurable

        virtual Config getConfig() const;
        void mergeConfig( const Config& conf );
    };
} // namespace osgEarth

OSGEARTH_SPECIALIZE_CONFIG(osgEarth::Query);
