/* -*-c++-*- */
/* osgEarth - Dynamic map generation toolkit for OpenSceneGraph
 * Copyright 2016 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/>
 */
#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::Drivers;

    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;
        const KMLOptions* _options;
    };

} // namespace osgEarth_kml

#endif // OSGEARTH_DRIVER_KML_READER

