osgEarth 2.1.1
|
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 |
Definition at line 39 of file ReaderWriterKML.cpp.
ReaderWriterKML::ReaderWriterKML | ( | ) | [inline] |
Definition at line 41 of file ReaderWriterKML.cpp.
{ supportsExtension( "kml", "KML" ); #ifdef SUPPORT_KMZ supportsExtension( "kmz", "KMZ" ); #endif // SUPPORT_KMZ }
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() ); } }
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); }
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.