//override
    void initialize( const osgDB::Options* dbOptions )
    {
        _dbOptions = dbOptions ? osg::clone(dbOptions) : 0L;
        if ( _dbOptions.valid() )
        {
            // Set up a Custom caching bin for this source:
            Cache* cache = Cache::get( _dbOptions.get() );
            if ( cache )
            {
                Config optionsConf = _options.getConfig();

                std::string binId = Stringify() << std::hex << hashString(optionsConf.toJSON()) << "_tfs";
                _cacheBin = cache->addBin( binId );
                
                // write a metadata record just for reference purposes.. we don't actually use it
                Config metadata = _cacheBin->readMetadata();
                if ( metadata.empty() )
                {
                    _cacheBin->writeMetadata( optionsConf );
                }

                if ( _cacheBin.valid() )
                {
                    _cacheBin->store( _dbOptions.get() );
                }
            }
        }     
        _layerValid = TFSReader::read(_options.url().get(), _dbOptions.get(), _layer);
        if (_layerValid)
        {
            OE_INFO << LC <<  "Read layer TFS " << _layer._title << " " << _layer._abstract << " " << _layer._firstLevel << " " << _layer._maxLevel << " " << _layer._extent.toString() << std::endl;
        }
    }
Example #2
0
    //override
    void initialize( const osgDB::Options* dbOptions )
    {
        FeatureSource::initialize( dbOptions );

        _dbOptions = dbOptions ? osg::clone(dbOptions) : 0L;
        if ( _dbOptions.valid() )
        {
            // Set up a Custom caching bin for this source:
            Cache* cache = Cache::get( _dbOptions.get() );
            if ( cache )
            {
                Config optionsConf = _options.getConfig();

                std::string binId = Stringify() << std::hex << hashString(optionsConf.toJSON()) << "_wfs";
                _cacheBin = cache->addBin( binId );
                _cacheBin->setHashKeys(true);
                
                // write a metadata record just for reference purposes.. we don't actually use it
                Config metadata = _cacheBin->readMetadata();
                if ( metadata.empty() )
                {
                    _cacheBin->writeMetadata( optionsConf );
                }

                if ( _cacheBin.valid() )
                {
                    _cacheBin->apply( _dbOptions.get() );
                }
            }
        }

        std::string capUrl;

        if ( _options.url().isSet() )
        {
            char sep = _options.url()->full().find_first_of('?') == std::string::npos? '?' : '&';

            capUrl = 
                _options.url()->full() +
                sep + 
                "SERVICE=WFS&VERSION=1.0.0&REQUEST=GetCapabilities";
        }        

        _capabilities = WFSCapabilitiesReader::read( capUrl, _dbOptions.get() );
        if ( !_capabilities.valid() )
        {
            OE_WARN << "[osgEarth::WFS] Unable to read WFS GetCapabilities." << std::endl;
            //return;
        }
        else
        {
            OE_INFO << "[osgEarth::WFS] Got capabilities from " << capUrl << std::endl;
        }
    }
Example #3
0
    //override
    void initialize( const osgDB::Options* dbOptions )
    {
        FeatureSource::initialize( dbOptions );

        _dbOptions = dbOptions ? osg::clone(dbOptions) : 0L;
        if ( _dbOptions.valid() )
        {
            // Set up a Custom caching bin for this source:
            Cache* cache = Cache::get( _dbOptions.get() );
            if ( cache )
            {
                Config optionsConf = _options.getConfig();

                std::string binId = Stringify() << std::hex << hashString(optionsConf.toJSON()) << "_tfs";
                _cacheBin = cache->addBin( binId );
                if ( _cacheBin.valid() )
                {                
                    // write a metadata record just for reference purposes.. we don't actually use it
                    Config metadata = _cacheBin->readMetadata();
                    if ( metadata.empty() )
                    {
                        _cacheBin->writeMetadata( optionsConf );
                    }

                    if ( _cacheBin.valid() )
                    {
                        _cacheBin->put( _dbOptions.get() );
                    }
                }
                else
                {
                    OE_INFO << LC << "Failed to open cache bin \"" << binId << "\"\n";
                }
            }
        }     
        _layerValid = TFSReaderWriter::read(_options.url().get(), _dbOptions.get(), _layer);
        if (_layerValid)
        {
            OE_INFO << LC <<  "Read layer TFS " << _layer.getTitle() << " " << _layer.getAbstract() << " " << _layer.getFirstLevel() << " " << _layer.getMaxLevel() << " " << _layer.getExtent().toString() << std::endl;
        }
    }
    Status initialize( const osgDB::Options* dbOptions )
    {
        Cache* cache = 0;

        _dbOptions = Registry::instance()->cloneOrCreateOptions( dbOptions );

        if ( _dbOptions.valid() )
        {
            // Set up a Custom caching bin for this TileSource
            cache = Cache::get( _dbOptions.get() );
            if ( cache )
            {
                Config optionsConf = _options.getConfig();

                std::string binId = Stringify() << std::hex << hashString(optionsConf.toJSON());
                _cacheBin = cache->addBin( binId );

                if ( _cacheBin.valid() )
                {
                    _cacheBin->apply( _dbOptions.get() );
                }
            }
        }


        if ( !_options.featureOptions().isSet() )
        {
            return Status::Error( Stringify() << LC << "Illegal: feature source is required" );
        }
    
        _features = FeatureSourceFactory::create( _options.featureOptions().value() );
        if ( !_features.valid() )
        {
            return Status::Error( Stringify() << "Illegal: no valid feature source provided");
        }

        //if ( _features->getGeometryType() != osgEarth::Symbology::Geometry::TYPE_POLYGON )
        //{
        //    Status::Error( Stringify() << "Illegal: only polygon features are currently supported");
        //    return false;
        //}

        _features->initialize( _dbOptions );

        // populate feature list
        //osg::ref_ptr<FeatureCursor> cursor = _features->createFeatureCursor();
        //while ( cursor.valid() && cursor->hasMore() )
        //{
        //    Feature* f = cursor->nextFeature();
        //    if ( f && f->getGeometry() )
        //        _featureList.push_back(f);
        //}
        if (_features->getFeatureProfile())
        {
			if (getProfile() && !getProfile()->getSRS()->isEquivalentTo(_features->getFeatureProfile()->getSRS()))
            {
                OE_WARN << LC << "Specified profile does not match feature profile, ignoring specified profile." << std::endl;
            }

            _extents = _features->getFeatureProfile()->getExtent();

			// If you didn't specify a profile (hint, you should have), use the feature profile.
			if ( !getProfile() )
			{
                OE_WARN << LC << "No profile specified; falling back on feature profile." << std::endl;

				const Profile* profile = Profile::create(
					_extents.getSRS(),
					_extents.bounds().xMin(),
					_extents.bounds().yMin(),
					_extents.bounds().xMax(),
					_extents.bounds().yMax());

				setProfile( profile );
			}
        }
        else
        {
            return Status::Error( Stringify() << "Failed to establish a profile for " <<  this->getName() );
        }

        //getDataExtents().push_back( DataExtent(_extents, 0, _maxDataLevel) );

        return STATUS_OK;
    }