|
osgEarth 2.1.1
|
Inheritance diagram for osgEarth::Features::TransformFilter:
Collaboration diagram for osgEarth::Features::TransformFilter:Public Member Functions | |
| TransformFilter () | |
| TransformFilter (const osg::Matrixd &xform) | |
| TransformFilter (const SpatialReference *outputSRS, bool outputGeocentric=false) | |
| void | setMatrix (const osg::Matrixd &mat) |
| const osg::Matrixd & | getMatrix () const |
| void | setMakeGeocentric (bool value) |
| bool | getMakeGeocentric () const |
| void | setLocalizeCoordinates (bool value) |
| bool | getLocalizeCoordinates () const |
| FilterContext | push (FeatureList &features, FilterContext &context) |
Protected Member Functions | |
| bool | push (Feature *feature, FilterContext &context) |
Protected Attributes | |
| osg::ref_ptr< const SpatialReference > | _outputSRS |
| bool | _makeGeocentric |
| osg::BoundingBoxd | _bbox |
| bool | _localize |
| osg::Matrixd | _mat |
Feature filter that transforms features from one FeatureProfile to another.
Definition at line 36 of file TransformFilter.
| TransformFilter::TransformFilter | ( | ) |
Definition at line 93 of file TransformFilter.cpp.
: _makeGeocentric( false ), _localize( false ) { // nop }
| TransformFilter::TransformFilter | ( | const osg::Matrixd & | xform | ) |
Definition at line 100 of file TransformFilter.cpp.
: _makeGeocentric( false ), _localize ( false ), _mat ( xform ) { //nop }
| TransformFilter::TransformFilter | ( | const SpatialReference * | outputSRS, |
| bool | outputGeocentric = false |
||
| ) |
Definition at line 108 of file TransformFilter.cpp.
: _outputSRS( outputSRS ), _makeGeocentric( outputGeocentric ), _localize( false ) { //NOP }
| bool osgEarth::Features::TransformFilter::getLocalizeCoordinates | ( | ) | const [inline] |
Definition at line 55 of file TransformFilter.
{ return _localize; }
| bool osgEarth::Features::TransformFilter::getMakeGeocentric | ( | ) | const [inline] |
Definition at line 50 of file TransformFilter.
{ return _makeGeocentric; }
| const osg::Matrixd& osgEarth::Features::TransformFilter::getMatrix | ( | ) | const [inline] |
Definition at line 46 of file TransformFilter.
{ return _mat; }
| bool TransformFilter::push | ( | Feature * | feature, |
| FilterContext & | context | ||
| ) | [protected] |
Definition at line 118 of file TransformFilter.cpp.
{
if ( !input || !input->getGeometry() )
return true;
bool needsSRSXform =
_outputSRS.valid() &&
( ! context.profile()->getSRS()->isEquivalentTo( _outputSRS.get() ) );
bool needsMatrixXform = !_mat.isIdentity();
// optimize: do nothing if nothing needs doing
if ( !needsSRSXform && !_makeGeocentric && !_localize && !needsMatrixXform )
return true;
// iterate over the feature geometry.
GeometryIterator iter( input->getGeometry() );
while( iter.hasMore() )
{
Geometry* geom = iter.next();
// pre-transform the point before doing an SRS transformation.
if ( needsMatrixXform )
{
for( unsigned i=0; i < geom->size(); ++i )
(*geom)[i] = (*geom)[i] * _mat;
}
// first transform the geometry to the output SRS:
if ( needsSRSXform )
context.profile()->getSRS()->transformPoints( _outputSRS.get(), geom->asVector(), false );
// convert to ECEF if required:
if ( _makeGeocentric )
_outputSRS->transformToECEF( geom->asVector(), false );
// update the bounding box.
if ( _localize )
{
for( unsigned i=0; i<geom->size(); ++i )
_bbox.expandBy( (*geom)[i] );
}
}
return true;
}
Here is the call graph for this function:| FilterContext TransformFilter::push | ( | FeatureList & | features, |
| FilterContext & | context | ||
| ) | [virtual] |
Implements osgEarth::Features::FeatureFilter.
Definition at line 166 of file TransformFilter.cpp.
{
_bbox = osg::BoundingBoxd();
// first transform all the points into the output SRS, collecting a bounding box as we go:
bool ok = true;
for( FeatureList::iterator i = input.begin(); i != input.end(); i++ )
if ( !push( i->get(), incx ) )
ok = false;
FilterContext outcx( incx );
outcx.isGeocentric() = _makeGeocentric;
if ( _outputSRS.valid() )
{
if ( incx.extent()->isValid() )
outcx.profile() = new FeatureProfile( incx.extent()->transform( _outputSRS.get() ) );
else
outcx.profile() = new FeatureProfile( incx.profile()->getExtent().transform( _outputSRS.get() ) );
}
// set the reference frame to shift data to the centroid. This will
// prevent floating point precision errors in the openGL pipeline for
// properly gridded data.
if ( _bbox.valid() && _localize )
{
// create a suitable reference frame:
osg::Matrixd localizer;
if ( _makeGeocentric )
{
localizer = createGeocentricInvRefFrame( _bbox.center(), _outputSRS.get() );
localizer.invert( localizer );
}
else
{
localizer = osg::Matrixd::translate( -_bbox.center() );
}
// localize the geometry relative to the reference frame.
for( FeatureList::iterator i = input.begin(); i != input.end(); i++ )
{
localizeGeometry( i->get(), localizer );
}
outcx.setReferenceFrame( localizer );
}
return outcx;
}
Here is the call graph for this function:| void osgEarth::Features::TransformFilter::setLocalizeCoordinates | ( | bool | value | ) | [inline] |
Whether to localize coordinates to the bounding box centroid (to avoid precision jitter when turning the data into OSG geometry)
Definition at line 54 of file TransformFilter.
{ _localize = value; }
Here is the caller graph for this function:| void osgEarth::Features::TransformFilter::setMakeGeocentric | ( | bool | value | ) | [inline] |
Whether to convert the transformed coordinates into geocentric (default = false )
Definition at line 49 of file TransformFilter.
{ _makeGeocentric = value; }
Here is the caller graph for this function:| void osgEarth::Features::TransformFilter::setMatrix | ( | const osg::Matrixd & | mat | ) | [inline] |
Transform matrix to apply to each point. If there's is also an SRS conversion, the matrix will be applied first.
Definition at line 45 of file TransformFilter.
{ _mat = mat; }
osg::BoundingBoxd osgEarth::Features::TransformFilter::_bbox [protected] |
Definition at line 63 of file TransformFilter.
bool osgEarth::Features::TransformFilter::_localize [protected] |
Definition at line 64 of file TransformFilter.
bool osgEarth::Features::TransformFilter::_makeGeocentric [protected] |
Definition at line 62 of file TransformFilter.
osg::Matrixd osgEarth::Features::TransformFilter::_mat [protected] |
Definition at line 65 of file TransformFilter.
osg::ref_ptr<const SpatialReference> osgEarth::Features::TransformFilter::_outputSRS [protected] |
Definition at line 61 of file TransformFilter.
1.7.3