osgEarth 2.1.1
Public Member Functions | Private Attributes

FeatureMaskSource Class Reference

Inheritance diagram for FeatureMaskSource:
Collaboration diagram for FeatureMaskSource:

List of all members.

Public Member Functions

 FeatureMaskSource (const MaskSourceOptions &options)
const MaskSourceOptionsgetOptions () const
void initialize (const std::string &referenceURI, const osgEarth::Map *map)
osg::Vec3dArray * createBoundary (const SpatialReference *srs, ProgressCallback *progress)

Private Attributes

bool _failed
const FeatureMaskOptions _options
osg::ref_ptr< FeatureSource_features

Detailed Description

Definition at line 40 of file FeatureMaskSource.cpp.


Constructor & Destructor Documentation

FeatureMaskSource::FeatureMaskSource ( const MaskSourceOptions options) [inline]

Definition at line 43 of file FeatureMaskSource.cpp.

        : MaskSource( options ), _options( options ), _failed( false )
    {
        // the data source from which to pull features:
        if ( _options.featureSource().valid() )
        {
            _features = _options.featureSource().get();
        }
        else if ( _options.featureOptions().isSet() )
        {
            _features = FeatureSourceFactory::create( _options.featureOptions().value() );
            if ( !_features.valid() )
            {
                OE_WARN << "FeatureModelSource - no valid feature source provided" << std::endl;
            }
        }
    }

Member Function Documentation

osg::Vec3dArray* FeatureMaskSource::createBoundary ( const SpatialReference srs,
ProgressCallback progress 
) [inline, virtual]

Subclass implements this method to create the boundary geometry.

Implements osgEarth::MaskSource.

Definition at line 78 of file FeatureMaskSource.cpp.

    {
        if ( _failed )
            return 0L;

        if ( _features.valid() )
        {
            if ( _features->getFeatureProfile() )
            {
                osg::ref_ptr<FeatureCursor> cursor = _features->createFeatureCursor();
                if ( cursor )
                {
                    if ( cursor->hasMore() )
                    {
                        Feature* f = cursor->nextFeature();
                        if ( f && f->getGeometry() )
                        {
                            // Init a filter to tranform feature in desired SRS 
                            if (!srs->isEquivalentTo(_features->getFeatureProfile()->getSRS())) {
                                FilterContext cx;
                                cx.profile() = new FeatureProfile(_features->getFeatureProfile()->getExtent());
                                //cx.isGeocentric() = _features->getFeatureProfile()->getSRS()->isGeographic();

                                TransformFilter xform( srs );
                                FeatureList featureList;
                                featureList.push_back(f);
                                cx = xform.push(featureList, cx);
                            }

                            return f->getGeometry()->toVec3dArray();
                        }
                    }
                }
            }
            else
            {
                OE_WARN << LC << "Failed to create boundary; feature source has no SRS" << std::endl;
                _failed = true;
            }
        }
        else
        {
            OE_WARN << LC << "Unable to create boundary; invalid feature source" << std::endl;
            _failed = true;
        }
        return 0L;
    }

Here is the call graph for this function:

const MaskSourceOptions& FeatureMaskSource::getOptions ( ) const [inline]

Reimplemented from osgEarth::MaskSource.

Definition at line 61 of file FeatureMaskSource.cpp.

{ return _options; }
void FeatureMaskSource::initialize ( const std::string &  referenceURI,
const osgEarth::Map map 
) [inline, virtual]

Reimplemented from osgEarth::MaskSource.

Definition at line 64 of file FeatureMaskSource.cpp.

    {
        MaskSource::initialize( referenceURI, map );

        if ( _features.valid() )
        {
            _features->initialize( referenceURI );
        } 
        else
        {
            OE_WARN << LC << "No FeatureSource; nothing will be rendered (" << getName() << ")" << std::endl;
        }
    }

Here is the call graph for this function:


Member Data Documentation

Definition at line 127 of file FeatureMaskSource.cpp.

Definition at line 129 of file FeatureMaskSource.cpp.

Reimplemented from osgEarth::MaskSource.

Definition at line 128 of file FeatureMaskSource.cpp.


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