osgEarth 2.1.1
Public Member Functions

ReaderWriterKML Struct Reference

List of all members.

Public Member Functions

 ReaderWriterKML ()
ReadResult readObject (const std::string &url, const Options *options) const
ReadResult readObject (std::istream &in, const Options *options) const
ReadResult readNode (const std::string &url, const Options *options) const
ReadResult readNode (std::istream &in, const Options *options) const

Detailed Description

Definition at line 39 of file ReaderWriterKML.cpp.


Constructor & Destructor Documentation

ReaderWriterKML::ReaderWriterKML ( ) [inline]

Definition at line 41 of file ReaderWriterKML.cpp.

    {
        supportsExtension( "kml", "KML" );

#ifdef SUPPORT_KMZ
        supportsExtension( "kmz", "KMZ" );
#endif // SUPPORT_KMZ
    }

Member Function Documentation

ReadResult ReaderWriterKML::readNode ( const std::string &  url,
const Options *  options 
) const [inline]

Definition at line 60 of file ReaderWriterKML.cpp.

    {
        std::string ext = osgDB::getLowerCaseFileExtension(url);
        if ( !acceptsExtension(ext) )
            return ReadResult::FILE_NOT_HANDLED;

        if ( ext == "kmz" )
        {
            return URI(url + "/.kml").readNode( options );
        }
        else
        {
            // propagate the source URI along to the stream reader
            osg::ref_ptr<osgDB::Options> myOptions = Registry::instance()->cloneOrCreateOptions(options);
            URIContext(url).store( myOptions.get() );
            return readNode( URIStream(url), myOptions.get() );
        }
    }

Here is the call graph for this function:

ReadResult ReaderWriterKML::readNode ( std::istream &  in,
const Options *  options 
) const [inline]

Definition at line 79 of file ReaderWriterKML.cpp.

    {
        if ( !options )
            return ReadResult("Missing required MapNode option");

        // this plugin requires that you pass in a MapNode* in options.
        MapNode* mapNode = const_cast<MapNode*>(
            static_cast<const MapNode*>( options->getPluginData("osgEarth::MapNode")) );
        if ( !mapNode )
            return ReadResult("Missing required MapNode option");

        // grab the KMLOptions if present
        const KMLOptions* kmlOptions =
            static_cast<const KMLOptions*>(options->getPluginData("osgEarth::KMLOptions") );

        // Grab the URIContext from the options (since we're reading from a stream)
        URIContext uriContext( options );

        // fire up a KML reader and parse the data.
        KMLReader reader( mapNode, kmlOptions );
        osg::Node* node = reader.read( in, uriContext );
        return ReadResult(node);
    }

Here is the call graph for this function:

ReadResult ReaderWriterKML::readObject ( const std::string &  url,
const Options *  options 
) const [inline]

Definition at line 50 of file ReaderWriterKML.cpp.

    {
        return readNode( url, options );
    }
ReadResult ReaderWriterKML::readObject ( std::istream &  in,
const Options *  options 
) const [inline]

Definition at line 55 of file ReaderWriterKML.cpp.

    {
        return readNode(in, options);
    }

The documentation for this struct was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines