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

#include <osgEarth/Common>
#include <osgEarth/URI>
#include <osgEarth/MapNode>
#include <osg/Node>
#include <iostream>
#include "KMLOptions"

#include "rapidxml.hpp"
#include "rapidxml_utils.hpp"

using namespace rapidxml;

namespace osgEarth_kml
{
    using namespace osgEarth;
    using namespace osgEarth::KML;

    class KMLReader
    {
    public:
        /** Initialized a KML reader that will work with the provided map node */
        KMLReader( MapNode* mapNode, const KMLOptions* options );

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

        /** Reads KML from a stream and returns a node */
        osg::Node* read( std::istream& in, const osgDB::Options* dbOptions ) ;

        /** Reads KML from an xml_document object */
        osg::Node* read( xml_document<>& doc, const osgDB::Options* dbOptions );

    private:
        MapNode* _mapNode = nullptr;
        const KMLOptions* _options = nullptr;
    };

} // namespace osgEarth_kml

#endif // OSGEARTH_DRIVER_KML_READER

