Esempio n. 1
0
FeatureSource*
FeatureSourceFactory::create( const FeatureSourceOptions& options )
{
    FeatureSource* featureSource = 0L;

    if ( !options.getDriver().empty() )
    {
        std::string driverExt = std::string(".osgearth_feature_") + options.getDriver();

        osg::ref_ptr<osgDB::Options> rwopts = Registry::instance()->cloneOrCreateOptions();
        rwopts->setPluginData( FEATURE_SOURCE_OPTIONS_TAG, (void*)&options );

        featureSource = dynamic_cast<FeatureSource*>( osgDB::readObjectFile( driverExt, rwopts.get() ) );
        if ( featureSource )
        {
            if ( options.name().isSet() )
                featureSource->setName( *options.name() );
            else
                featureSource->setName( options.getDriver() );
        }
        else
        {
            OE_WARN << LC << "FAILED to load feature driver \"" << options.getDriver() << "\"" << std::endl;
        }
    }
    else
    {
        OE_WARN << LC << "ILLEGAL null feature driver name" << std::endl;
    }

    return featureSource;
}
Esempio n. 2
0
FeatureSource*
FeatureSourceFactory::create( const DriverOptions* driverOptions )
{
    FeatureSource* featureSource = 0L;
    if ( driverOptions )
    {
        std::string driverExt = std::string(".osgearth_feature_") + driverOptions->driver();

        featureSource = dynamic_cast<FeatureSource*>( osgDB::readObjectFile( driverExt, driverOptions ) );
        if ( featureSource )
        {
            featureSource->setName( driverOptions->name() );
        }
        else
        {
            OE_NOTICE
                << "WARNING: Failed to load feature driver for " << driverExt << std::endl;
        }
    }
    else
    {
        OE_NOTICE
            << "ERROR: null driver options to FeatureSourceFactory" << std::endl;
    }

    return featureSource;
}