osgEarth 2.1.1
Public Types | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes

osgEarth::Map Class Reference

Inheritance diagram for osgEarth::Map:
Collaboration diagram for osgEarth::Map:

List of all members.

Public Types

enum  ModelParts {
  IMAGE_LAYERS = 1 << 0, ELEVATION_LAYERS = 1 << 1, TERRAIN_LAYERS = IMAGE_LAYERS | ELEVATION_LAYERS, MODEL_LAYERS = 1 << 2,
  MASK_LAYERS = 1 << 3, MASKED_TERRAIN_LAYERS = TERRAIN_LAYERS | MASK_LAYERS, ENTIRE_MODEL = 0xff
}

Public Member Functions

 Map (const MapOptions &options=MapOptions())
const MapOptionsgetMapOptions () const
const ProfilegetProfile () const
int getImageLayers (ImageLayerVector &out_layers, bool validLayersOnly=false) const
int getNumImageLayers () const
ImageLayergetImageLayerByName (const std::string &name) const
ImageLayergetImageLayerByUID (UID layerUID) const
ImageLayergetImageLayerAt (int index) const
int getElevationLayers (ElevationLayerVector &out_layers, bool validLayersOnly=false) const
int getNumElevationLayers () const
ElevationLayergetElevationLayerByName (const std::string &name) const
ElevationLayergetElevationLayerByUID (UID layerUID) const
ElevationLayergetElevationLayerAt (int index) const
int getModelLayers (ModelLayerVector &out_layers, bool validLayersOnly=false) const
int getNumModelLayers () const
ModelLayergetModelLayerByName (const std::string &name) const
ModelLayergetModelLayerByUID (UID layerUID) const
ModelLayergetModelLayerAt (int index) const
int getTerrainMaskLayers (MaskLayerVector &out_list) const
void addMapCallback (MapCallback *callback) const
void removeMapCallback (MapCallback *callback)
void addImageLayer (ImageLayer *layer)
void insertImageLayer (ImageLayer *layer, unsigned int index)
void removeImageLayer (ImageLayer *layer)
void moveImageLayer (ImageLayer *layer, unsigned int newIndex)
void addElevationLayer (ElevationLayer *layer)
void removeElevationLayer (ElevationLayer *layer)
void moveElevationLayer (ElevationLayer *layer, unsigned int newIndex)
void addModelLayer (ModelLayer *layer)
void insertModelLayer (ModelLayer *layer, unsigned int index)
void removeModelLayer (ModelLayer *layer)
void moveModelLayer (ModelLayer *layer, unsigned int newIndex)
void addTerrainMaskLayer (MaskLayer *layer)
void removeTerrainMaskLayer (MaskLayer *layer)
const
osgDB::ReaderWriter::Options * 
getGlobalOptions () const
void setGlobalOptions (const osgDB::ReaderWriter::Options *options)
void setName (const std::string &name)
const std::string & getName () const
bool getHeightField (const TileKey &key, bool fallback, osg::ref_ptr< osg::HeightField > &out_hf, bool *out_isFallback=0L, ElevationInterpolation interpolation=INTERP_AVERAGE, ElevationSamplePolicy samplePolicy=SAMPLE_FIRST_VALID, ProgressCallback *progress=0) const
void setCache (Cache *cache)
CachegetCache () const
Revision getDataModelRevision () const
bool isGeocentric () const
bool toMapPoint (const osg::Vec3d &input, const SpatialReference *input_srs, osg::Vec3d &output) const
bool mapPointToWorldPoint (const osg::Vec3d &input, osg::Vec3d &output) const
bool worldPointToMapPoint (const osg::Vec3d &input, osg::Vec3d &output) const
bool sync (class MapFrame &frame) const

Protected Member Functions

 ~Map ()

Private Member Functions

void calculateProfile ()

Private Attributes

MapOptions _mapOptions
std::string _name
ImageLayerVector _imageLayers
ElevationLayerVector _elevationLayers
ModelLayerVector _modelLayers
MaskLayerVector _terrainMaskLayers
MapCallbackList _mapCallbacks
osg::ref_ptr< const
osgDB::ReaderWriter::Options > 
_globalOptions
Threading::ReadWriteMutex _mapDataMutex
osg::ref_ptr< const Profile_profile
osg::ref_ptr< Cache_cache
Revision _dataModelRevision

Detailed Description

Map is the main data model that the MapNode will render. It is a container for all Layer objects (that contain the actual data) and the rendering options.

Definition at line 112 of file Map.


Member Enumeration Documentation

Enumerator:
IMAGE_LAYERS 
ELEVATION_LAYERS 
TERRAIN_LAYERS 
MODEL_LAYERS 
MASK_LAYERS 
MASKED_TERRAIN_LAYERS 
ENTIRE_MODEL 

Definition at line 374 of file Map.


Constructor & Destructor Documentation

Map::Map ( const MapOptions options = MapOptions())

Constructs a new, empty map.

Definition at line 64 of file Map.cpp.

                                    :
osg::Referenced( true ),
_mapOptions( options ),
_dataModelRevision(0)
{
    //NOP
}
osgEarth::Map::~Map ( ) [inline, protected]

Definition at line 386 of file Map.

{ }

Member Function Documentation

void Map::addElevationLayer ( ElevationLayer layer)

Adds an elevation layer to the map.

Definition at line 428 of file Map.cpp.

{
    osgEarth::Registry::instance()->clearBlacklist();
    unsigned int index = -1;
    if ( layer )
    {
            //Set options for the map from the layer
                layer->setReferenceURI( _mapOptions.referenceURI().value() );

        //propagate the cache to the layer:
        if ( _mapOptions.cache().isSet() && _mapOptions.cache()->cacheOnly().isSetTo( true ) )
                {
                        layer->setCacheOnly( true );
                }

                //Set the Cache for the MapLayer to our cache.
                layer->setCache( this->getCache() );
        
        // Tell the layer the map profile, if possible:
        if ( _profile.valid() )
            layer->setTargetProfileHint( _profile.get() );

        int newRevision;

        // Add the layer to our stack.
        {
            Threading::ScopedWriteLock lock( _mapDataMutex );

            _elevationLayers.push_back( layer );
            index = _elevationLayers.size() - 1;
            newRevision = ++_dataModelRevision;
        }

        // a separate block b/c we don't need the mutex   
        for( MapCallbackList::iterator i = _mapCallbacks.begin(); i != _mapCallbacks.end(); i++ )
        {
            i->get()->onMapModelChanged( MapModelChange(
                MapModelChange::ADD_ELEVATION_LAYER, newRevision, layer, index) );
        }       
    }   
}

Here is the call graph for this function:

Here is the caller graph for this function:

void Map::addImageLayer ( ImageLayer layer)

Adds an image layer to the map.

Definition at line 338 of file Map.cpp.

{
    osgEarth::Registry::instance()->clearBlacklist();
    unsigned int index = -1;
    if ( layer )
    {
            //Set options for the map from the layer
                layer->setReferenceURI( _mapOptions.referenceURI().value() );

        //propagate the cache to the layer:
        if ( _mapOptions.cache().isSet() && _mapOptions.cache()->cacheOnly().isSetTo( true ) )
                {
                        layer->setCacheOnly( true );
                }

                //Set the Cache for the MapLayer to our cache.
                layer->setCache( this->getCache() );

        // Tell the layer the map profile, if possible:
        if ( _profile.valid() )
            layer->setTargetProfileHint( _profile.get() );

        int newRevision;

        // Add the layer to our stack.
        {
            Threading::ScopedWriteLock lock( _mapDataMutex );

            _imageLayers.push_back( layer );
            index = _imageLayers.size() - 1;
            newRevision = ++_dataModelRevision;
        }

        // a separate block b/c we don't need the mutex   
        for( MapCallbackList::iterator i = _mapCallbacks.begin(); i != _mapCallbacks.end(); i++ )
        {
            i->get()->onMapModelChanged( MapModelChange(
                MapModelChange::ADD_IMAGE_LAYER, newRevision, layer, index) );
            //i->get()->onImageLayerAdded( layer, index, newRevision );
        }       
    }   
}

Here is the call graph for this function:

Here is the caller graph for this function:

void Map::addMapCallback ( MapCallback callback) const

Adds a map layer callback to this map. This will be notified whenever layers are added, removed, or re-ordered.

Definition at line 321 of file Map.cpp.

{
    if ( cb )
        const_cast<Map*>(this)->_mapCallbacks.push_back( cb );
}

Here is the caller graph for this function:

void Map::addModelLayer ( ModelLayer layer)

Adds a new model layer to the map.

Definition at line 636 of file Map.cpp.

{
    if ( layer )
    {
        unsigned int index = -1;

        Revision newRevision;
        {
            Threading::ScopedWriteLock lock( _mapDataMutex );
            _modelLayers.push_back( layer );
                                                index = _modelLayers.size() - 1;
            newRevision = ++_dataModelRevision;
        }

        layer->initialize( _mapOptions.referenceURI().get(), this ); //getReferenceURI(), this );        

        // a seprate block b/c we don't need the mutex
        for( MapCallbackList::iterator i = _mapCallbacks.begin(); i != _mapCallbacks.end(); i++ )
        {
            i->get()->onMapModelChanged( MapModelChange(
                                                                MapModelChange::ADD_MODEL_LAYER, newRevision, layer, index ) );
        }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void Map::addTerrainMaskLayer ( MaskLayer layer)

Adds a new layer to use as a terrain mask.

Definition at line 762 of file Map.cpp.

{
    if ( layer )
    {
        Revision newRevision;
        {
            Threading::ScopedWriteLock lock( _mapDataMutex );
            _terrainMaskLayers.push_back(layer);
            newRevision = ++_dataModelRevision;
        }

        layer->initialize( _mapOptions.referenceURI().value(), this );

        // a separate block b/c we don't need the mutex   
        for( MapCallbackList::iterator i = _mapCallbacks.begin(); i != _mapCallbacks.end(); i++ )
        {
            i->get()->onMapModelChanged( MapModelChange(
                MapModelChange::ADD_MASK_LAYER, newRevision, layer) );
        }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void Map::calculateProfile ( ) [private]

Definition at line 815 of file Map.cpp.

{
    if ( !_profile.valid() )
    {
        osg::ref_ptr<const Profile> userProfile;
        if ( _mapOptions.profile().isSet() )
        {
            userProfile = Profile::create( _mapOptions.profile().value() );
        }

        if ( _mapOptions.coordSysType() == MapOptions::CSTYPE_GEOCENTRIC )
        {
            if ( userProfile.valid() )
            {
                if ( userProfile->isOK() && userProfile->getSRS()->isGeographic() )
                {
                    _profile = userProfile.get();
                }
                else
                {
                    OE_WARN << LC 
                        << "Map is geocentric, but the configured profile does not "
                        << "have a geographic SRS. Falling back on default.."
                        << std::endl;
                }
            }

            if ( !_profile.valid() )
            {
                // by default, set a geocentric map to use global-geodetic WGS84.
                _profile = osgEarth::Registry::instance()->getGlobalGeodeticProfile();
            }
        }

        else if ( _mapOptions.coordSysType() == MapOptions::CSTYPE_GEOCENTRIC_CUBE )
        {
            //If the map type is a Geocentric Cube, set the profile to the cube profile.
            _profile = osgEarth::Registry::instance()->getCubeProfile();
        }

        else // CSTYPE_PROJECTED
        {
            if ( userProfile.valid() )
            {
                _profile = userProfile.get();
            }
        }

        // At this point, if we don't have a profile we need to search tile sources until we find one.
        if ( !_profile.valid() )
        {
            Threading::ScopedReadLock lock( _mapDataMutex );

            for( ImageLayerVector::iterator i = _imageLayers.begin(); i != _imageLayers.end() && !_profile.valid(); i++ )
            {
                ImageLayer* layer = i->get();
                if ( layer->getTileSource() )
                {
                    _profile = layer->getTileSource()->getProfile();
                }
            }

            for( ElevationLayerVector::iterator i = _elevationLayers.begin(); i != _elevationLayers.end() && !_profile.valid(); i++ )
            {
                ElevationLayer* layer = i->get();
                if ( layer->getTileSource() )
                {
                    _profile = layer->getTileSource()->getProfile();
                }
            }
        }

        // finally, fire an event if the profile has been set.
        if ( _profile.valid() )
        {
            OE_INFO << LC << "Map profile is: " << _profile->toString() << std::endl;

            for( MapCallbackList::iterator i = _mapCallbacks.begin(); i != _mapCallbacks.end(); i++ )
            {
                i->get()->onMapInfoEstablished( MapInfo(this) );
            }
        }

        else
        {
            OE_WARN << LC << "Warning, not yet able to establish a map profile!" << std::endl;
        }
    }

    if ( _profile.valid() )
    {
        // tell all the loaded layers what the profile is, as a hint
        {
            Threading::ScopedWriteLock lock( _mapDataMutex );

            for( ImageLayerVector::iterator i = _imageLayers.begin(); i != _imageLayers.end(); i++ )
            {
                ImageLayer* layer = i->get();
                layer->setTargetProfileHint( _profile.get() );
            }

            for( ElevationLayerVector::iterator i = _elevationLayers.begin(); i != _elevationLayers.end(); i++ )
            {
                ElevationLayer* layer = i->get();
                layer->setTargetProfileHint( _profile.get() );
            }
        }
    }
}

Here is the call graph for this function:

Cache * Map::getCache ( ) const

Gets the Cache for this Map

Definition at line 274 of file Map.cpp.

{
    if ( !_cache.valid() )
    {
        Cache* cache = 0L;

        // if there's a cache override in the registry, install it now.
        if ( osgEarth::Registry::instance()->getCacheOverride() )
        {
            cache = osgEarth::Registry::instance()->getCacheOverride();
        }

        else if ( _mapOptions.cache().isSet() )
        {
            cache = CacheFactory::create( _mapOptions.cache().get() );
        }

        if ( cache )
        {
            const_cast<Map*>(this)->setCache( cache );
        }
    }
        return _cache.get();
}

Here is the call graph for this function:

Here is the caller graph for this function:

Revision Map::getDataModelRevision ( ) const

Gets the revision # of the map. The revision # changes every time you add, remove, or move layers. You can use this to track changes in the map model (as a alternative to installing a MapCallback).

Definition at line 259 of file Map.cpp.

{
    Threading::ScopedReadLock lock( const_cast<Map*>(this)->_mapDataMutex );
    return _dataModelRevision;
}
ElevationLayer * Map::getElevationLayerAt ( int  index) const

Gets an elevation layer at the specified index.

Definition at line 181 of file Map.cpp.

{
    Threading::ScopedReadLock( const_cast<Map*>(this)->_mapDataMutex );
    if ( index >= 0 && index < (int)_elevationLayers.size() )
        return _elevationLayers[index].get();
    else
        return 0L;
}
ElevationLayer * Map::getElevationLayerByName ( const std::string &  name) const

Gets an elevation layer by name.

Definition at line 161 of file Map.cpp.

{
    Threading::ScopedReadLock( const_cast<Map*>(this)->_mapDataMutex );
    for( ElevationLayerVector::const_iterator i = _elevationLayers.begin(); i != _elevationLayers.end(); ++i )
        if ( i->get()->getName() == name )
            return i->get();
    return 0L;
}
ElevationLayer * Map::getElevationLayerByUID ( UID  layerUID) const

Gets an elevation layer by its unique ID.

Definition at line 171 of file Map.cpp.

{
    Threading::ScopedReadLock( const_cast<Map*>(this)->_mapDataMutex );
    for( ElevationLayerVector::const_iterator i = _elevationLayers.begin(); i != _elevationLayers.end(); ++i )
        if ( i->get()->getUID() == layerUID )
            return i->get();
    return 0L;
}
int Map::getElevationLayers ( ElevationLayerVector out_layers,
bool  validLayersOnly = false 
) const

Copies references of the elevation layers into the output list. This method is thread safe. It returns the map revision that was in effect when the data was copied.

Definition at line 141 of file Map.cpp.

{
    out_list.reserve( _elevationLayers.size() );

    Threading::ScopedReadLock lock( const_cast<Map*>(this)->_mapDataMutex );
    for( ElevationLayerVector::const_iterator i = _elevationLayers.begin(); i != _elevationLayers.end(); ++i )
        if ( !validLayersOnly || i->get()->getProfile() )
            out_list.push_back( i->get() );

    return _dataModelRevision;
}

Here is the caller graph for this function:

const osgDB::ReaderWriter::Options * Map::getGlobalOptions ( ) const

Gets the user-provided options structure stored in this map.

Definition at line 81 of file Map.cpp.

                            {
    return _globalOptions.get();
}
bool Map::getHeightField ( const TileKey key,
bool  fallback,
osg::ref_ptr< osg::HeightField > &  out_hf,
bool *  out_isFallback = 0L,
ElevationInterpolation  interpolation = INTERP_AVERAGE,
ElevationSamplePolicy  samplePolicy = SAMPLE_FIRST_VALID,
ProgressCallback progress = 0 
) const

Creates a heightfield for the region covered by the given TileKey, falling back on lower resolutions if necessary.

Parameters:
keyTile key defining the region (and ideal LOD) for which to return a heightfield
samplePolicySee enum SamplePolicy in this class.

Definition at line 1150 of file Map.cpp.

{
    Threading::ScopedReadLock lock( const_cast<Map*>(this)->_mapDataMutex );

    return s_getHeightField(
        key, _elevationLayers, getProfile(), fallback, 
        interpolation, samplePolicy, 
        out_result, out_isFallback,
        progress );
}

Here is the call graph for this function:

ImageLayer * Map::getImageLayerAt ( int  index) const

Gets an image layer at the specified index.

Definition at line 131 of file Map.cpp.

{
    Threading::ScopedReadLock( const_cast<Map*>(this)->_mapDataMutex );
    if ( index >= 0 && index < (int)_imageLayers.size() )
        return _imageLayers[index].get();
    else
        return 0L;
}
ImageLayer * Map::getImageLayerByName ( const std::string &  name) const

Gets an image layer by name.

Definition at line 111 of file Map.cpp.

{
    Threading::ScopedReadLock( const_cast<Map*>(this)->_mapDataMutex );
    for( ImageLayerVector::const_iterator i = _imageLayers.begin(); i != _imageLayers.end(); ++i )
        if ( i->get()->getName() == name )
            return i->get();
    return 0L;
}
ImageLayer * Map::getImageLayerByUID ( UID  layerUID) const

Gets an image layer by its unique ID.

Definition at line 121 of file Map.cpp.

{
    Threading::ScopedReadLock( const_cast<Map*>(this)->_mapDataMutex );
    for( ImageLayerVector::const_iterator i = _imageLayers.begin(); i != _imageLayers.end(); ++i )
        if ( i->get()->getUID() == layerUID )
            return i->get();
    return 0L;
}
int Map::getImageLayers ( ImageLayerVector out_layers,
bool  validLayersOnly = false 
) const

Copies references of the map image layers into the output list. This method is thread safe. It returns the map revision that was in effect when the data was copied.

Definition at line 91 of file Map.cpp.

{
    out_list.reserve( _imageLayers.size() );

    Threading::ScopedReadLock lock( const_cast<Map*>(this)->_mapDataMutex );
    for( ImageLayerVector::const_iterator i = _imageLayers.begin(); i != _imageLayers.end(); ++i )
        if ( !validLayersOnly || i->get()->getProfile() )
            out_list.push_back( i->get() );

    return _dataModelRevision;
}

Here is the caller graph for this function:

const MapOptions& osgEarth::Map::getMapOptions ( ) const [inline]

Gets the optons with which this map was created.

Definition at line 124 of file Map.

{ return _mapOptions; }

Here is the caller graph for this function:

ModelLayer * Map::getModelLayerAt ( int  index) const

Gets the model layer at the specified index.

Definition at line 225 of file Map.cpp.

{
    Threading::ScopedReadLock( const_cast<Map*>(this)->_mapDataMutex );
    if ( index >= 0 && index < (int)_modelLayers.size() )
        return _modelLayers[index].get();
    else
        return 0L;
}
ModelLayer * Map::getModelLayerByName ( const std::string &  name) const

Gets a model layer by name.

Definition at line 204 of file Map.cpp.

{
    Threading::ScopedReadLock( const_cast<Map*>(this)->_mapDataMutex );
    for( ModelLayerVector::const_iterator i = _modelLayers.begin(); i != _modelLayers.end(); ++i )
        if ( i->get()->getName() == name )
            return i->get();
    return 0L;
}
ModelLayer * Map::getModelLayerByUID ( UID  layerUID) const

Gets a model layer by its unique ID.

Definition at line 214 of file Map.cpp.

{
    Threading::ScopedReadLock( const_cast<Map*>(this)->_mapDataMutex );
    for( ModelLayerVector::const_iterator i = _modelLayers.begin(); i != _modelLayers.end(); ++i )
        if ( i->get()->getUID() == layerUID )
            return i->get();
    return 0L;
}
int Map::getModelLayers ( ModelLayerVector out_layers,
bool  validLayersOnly = false 
) const

Copies references of the model layers into the output list. This method is thread safe. It returns the map revision that was in effect when the data was copied.

Definition at line 191 of file Map.cpp.

{
    out_list.reserve( _modelLayers.size() );

    Threading::ScopedReadLock lock( const_cast<Map*>(this)->_mapDataMutex );
    for( ModelLayerVector::const_iterator i = _modelLayers.begin(); i != _modelLayers.end(); ++i )
        //if ( !validLayersOnly || i->get()->i->get()->getProfile() )
            out_list.push_back( i->get() );

    return _dataModelRevision;
}
const std::string& osgEarth::Map::getName ( ) const [inline]

Gets the readable name of this map.

Definition at line 309 of file Map.

{ return _name; }
int Map::getNumElevationLayers ( ) const

Gets the number of elevation layers in the map.

Definition at line 154 of file Map.cpp.

{
    Threading::ScopedReadLock lock( const_cast<Map*>(this)->_mapDataMutex );
    return _elevationLayers.size();
}
int Map::getNumImageLayers ( ) const

Gets the number of image layers in the map.

Definition at line 104 of file Map.cpp.

{
    Threading::ScopedReadLock lock( const_cast<Map*>(this)->_mapDataMutex );
    return _imageLayers.size();
}
int Map::getNumModelLayers ( ) const

Gets the number of model layers in the map.

Definition at line 235 of file Map.cpp.

{
    Threading::ScopedReadLock lock( const_cast<Map*>(this)->_mapDataMutex );
    return _modelLayers.size();
}
const Profile * Map::getProfile ( ) const

Gets the map's master profile. This value may not be available until after autoCalculateProfile has been called.

Definition at line 266 of file Map.cpp.

{
    if ( !_profile.valid() )
        const_cast<Map*>(this)->calculateProfile();
    return _profile.get();
}

Here is the caller graph for this function:

int Map::getTerrainMaskLayers ( MaskLayerVector out_list) const

Copies references of the mask layers into the output list. This method is thread safe. It returns the map revision that was in effect when the data was copied.

Definition at line 242 of file Map.cpp.

{
    out_list.reserve( _terrainMaskLayers.size() );

    Threading::ScopedReadLock lock( const_cast<Map*>(this)->_mapDataMutex );
    for( MaskLayerVector::const_iterator i = _terrainMaskLayers.begin(); i != _terrainMaskLayers.end(); ++i )
        out_list.push_back( i->get() );

    return _dataModelRevision;
}
void Map::insertImageLayer ( ImageLayer layer,
unsigned int  index 
)

Adds an image layer to the map at the specified index.

Definition at line 383 of file Map.cpp.

{
    osgEarth::Registry::instance()->clearBlacklist();
    if ( layer )
    {
        //Set options for the map from the layer
        layer->setReferenceURI( _mapOptions.referenceURI().value() );

        //propagate the cache to the layer:
        if ( _mapOptions.cache().isSet() && _mapOptions.cache()->cacheOnly().isSetTo( true ) )
        {
            layer->setCacheOnly( true );
        }

        //Set the Cache for the MapLayer to our cache.
        layer->setCache( this->getCache() );

        // Tell the layer the map profile, if possible:
        if ( _profile.valid() )
            layer->setTargetProfileHint( _profile.get() );

        int newRevision;

        // Add the layer to our stack.
        {
            Threading::ScopedWriteLock lock( _mapDataMutex );

            if (index >= _imageLayers.size())
                _imageLayers.push_back(layer);
            else
                _imageLayers.insert( _imageLayers.begin() + index, layer );

            newRevision = ++_dataModelRevision;
        }

        // a separate block b/c we don't need the mutex   
        for( MapCallbackList::iterator i = _mapCallbacks.begin(); i != _mapCallbacks.end(); i++ )
        {
            i->get()->onMapModelChanged( MapModelChange(
                MapModelChange::ADD_IMAGE_LAYER, newRevision, layer, index) );
        }       
    }   
}

Here is the call graph for this function:

void Map::insertModelLayer ( ModelLayer layer,
unsigned int  index 
)

Adds a new model layer to the map at the specified index.

Definition at line 662 of file Map.cpp.

{
    if ( layer )
    {
        Revision newRevision;
        {
            Threading::ScopedWriteLock lock( _mapDataMutex );
            _modelLayers.insert( _modelLayers.begin() + index, layer );
            newRevision = ++_dataModelRevision;
        }

        layer->initialize( _mapOptions.referenceURI().get(), this ); //getReferenceURI(), this );        

        // a seprate block b/c we don't need the mutex
        for( MapCallbackList::iterator i = _mapCallbacks.begin(); i != _mapCallbacks.end(); i++ )
        {
            i->get()->onMapModelChanged( MapModelChange(
                MapModelChange::ADD_MODEL_LAYER, newRevision, layer, index) );
        }
    }
}

Here is the call graph for this function:

bool Map::isGeocentric ( ) const

Convenience function that returns TRUE if the map cs type is geocentric.

Definition at line 73 of file Map.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool Map::mapPointToWorldPoint ( const osg::Vec3d &  input,
osg::Vec3d &  output 
) const

Convenience function to convert a point (in map coordinates) to world-space (XYZ) coordinates.

Definition at line 1239 of file Map.cpp.

{
    return MapInfo(this).mapPointToWorldPoint(input, output);
}

Here is the call graph for this function:

void Map::moveElevationLayer ( ElevationLayer layer,
unsigned int  newIndex 
)

Moves (re-orders) an elevation layer to another index position in its list.

Definition at line 589 of file Map.cpp.

{
    unsigned int oldIndex = 0;
    unsigned int actualIndex = 0;
    Revision newRevision;

    if ( layer )
    {
        Threading::ScopedWriteLock lock( _mapDataMutex );

        // preserve the layer with a ref:
        osg::ref_ptr<ElevationLayer> layerToMove = layer;

        // find it:
        ElevationLayerVector::iterator i_oldIndex = _elevationLayers.end();
        for( ElevationLayerVector::iterator i = _elevationLayers.begin(); i != _elevationLayers.end(); i++, actualIndex++ )
        {
            if ( i->get() == layer )
            {
                i_oldIndex = i;
                oldIndex = actualIndex;
                break;
            }
        }

        if ( i_oldIndex == _elevationLayers.end() )
            return; // layer not found in list

        // erase the old one and insert the new one.
        _elevationLayers.erase( i_oldIndex );
        _elevationLayers.insert( _elevationLayers.begin() + newIndex, layerToMove.get() );

        newRevision = ++_dataModelRevision;
    }

    // a separate block b/c we don't need the mutex
    if ( layer )
    {
        for( MapCallbackList::iterator i = _mapCallbacks.begin(); i != _mapCallbacks.end(); i++ )
        {
            i->get()->onMapModelChanged( MapModelChange(
                MapModelChange::MOVE_ELEVATION_LAYER, newRevision, layer, oldIndex, newIndex) );
        }
    }
}
void Map::moveImageLayer ( ImageLayer layer,
unsigned int  newIndex 
)

Moves (re-orders) an image layer to another index position in its list.

Definition at line 542 of file Map.cpp.

{
    unsigned int oldIndex = 0;
    unsigned int actualIndex = 0;
    Revision newRevision;

    if ( layer )
    {
        Threading::ScopedWriteLock lock( _mapDataMutex );

        // preserve the layer with a ref:
        osg::ref_ptr<ImageLayer> layerToMove = layer;

        // find it:
        ImageLayerVector::iterator i_oldIndex = _imageLayers.end();
        for( ImageLayerVector::iterator i = _imageLayers.begin(); i != _imageLayers.end(); i++, actualIndex++ )
        {
            if ( i->get() == layer )
            {
                i_oldIndex = i;
                oldIndex = actualIndex;
                break;
            }
        }

        if ( i_oldIndex == _imageLayers.end() )
            return; // layer not found in list

        // erase the old one and insert the new one.
        _imageLayers.erase( i_oldIndex );
        _imageLayers.insert( _imageLayers.begin() + newIndex, layerToMove.get() );

        newRevision = ++_dataModelRevision;
    }

    // a separate block b/c we don't need the mutex
    if ( layer )
    {
        for( MapCallbackList::iterator i = _mapCallbacks.begin(); i != _mapCallbacks.end(); i++ )
        {
            i->get()->onMapModelChanged( MapModelChange(
                MapModelChange::MOVE_IMAGE_LAYER, newRevision, layer, oldIndex, newIndex) );
        }
    }
}
void Map::moveModelLayer ( ModelLayer layer,
unsigned int  newIndex 
)

Moves (re-orders) an image layer to another index position in its list.

Definition at line 715 of file Map.cpp.

{
    unsigned int oldIndex = 0;
    unsigned int actualIndex = 0;
    Revision newRevision;

    if ( layer )
    {
        Threading::ScopedWriteLock lock( _mapDataMutex );

        // preserve the layer with a ref:
        osg::ref_ptr<ModelLayer> layerToMove = layer;

        // find it:
        ModelLayerVector::iterator i_oldIndex = _modelLayers.end();
        for( ModelLayerVector::iterator i = _modelLayers.begin(); i != _modelLayers.end(); i++, actualIndex++ )
        {
            if ( i->get() == layer )
            {
                i_oldIndex = i;
                oldIndex = actualIndex;
                break;
            }
        }

        if ( i_oldIndex == _modelLayers.end() )
            return; // layer not found in list

        // erase the old one and insert the new one.
        _modelLayers.erase( i_oldIndex );
        _modelLayers.insert( _modelLayers.begin() + newIndex, layerToMove.get() );

        newRevision = ++_dataModelRevision;
    }

    // a separate block b/c we don't need the mutex
    if ( layer )
    {
        for( MapCallbackList::iterator i = _mapCallbacks.begin(); i != _mapCallbacks.end(); i++ )
        {
            i->get()->onMapModelChanged( MapModelChange(
                MapModelChange::MOVE_MODEL_LAYER, newRevision, layer, oldIndex, newIndex) );
        }
    }
}
void Map::removeElevationLayer ( ElevationLayer layer)

Removes an elevation layer from the map.

Definition at line 507 of file Map.cpp.

{
    osgEarth::Registry::instance()->clearBlacklist();
    unsigned int index = -1;

    osg::ref_ptr<ElevationLayer> layerToRemove = layer;
    Revision newRevision;

    if ( layerToRemove.get() )
    {
        Threading::ScopedWriteLock lock( _mapDataMutex );
        index = 0;
        for( ElevationLayerVector::iterator i = _elevationLayers.begin(); i != _elevationLayers.end(); i++, index++ )
        {
            if ( i->get() == layerToRemove.get() )
            {
                _elevationLayers.erase( i );
                newRevision = ++_dataModelRevision;
                break;
            }
        }
    }

    // a separate block b/c we don't need the mutex
    if ( newRevision >= 0 ) //layerToRemove.get() )
    {
        for( MapCallbackList::iterator i = _mapCallbacks.begin(); i != _mapCallbacks.end(); i++ )
        {
            i->get()->onMapModelChanged( MapModelChange(
                MapModelChange::REMOVE_ELEVATION_LAYER, newRevision, layerToRemove.get(), index) );
        }
    }
}

Here is the call graph for this function:

void Map::removeImageLayer ( ImageLayer layer)

Removes an image layer from the map.

Definition at line 471 of file Map.cpp.

{
    osgEarth::Registry::instance()->clearBlacklist();
    unsigned int index = -1;

    osg::ref_ptr<ImageLayer> layerToRemove = layer;
    Revision newRevision;

    if ( layerToRemove.get() )
    {
        Threading::ScopedWriteLock lock( _mapDataMutex );
        index = 0;
        for( ImageLayerVector::iterator i = _imageLayers.begin(); i != _imageLayers.end(); i++, index++ )
        {
            if ( i->get() == layerToRemove.get() )
            {
                _imageLayers.erase( i );
                newRevision = ++_dataModelRevision;
                break;
            }
        }
    }

    // a separate block b/c we don't need the mutex
    if ( newRevision >= 0 ) // layerToRemove.get() )
    {
        for( MapCallbackList::iterator i = _mapCallbacks.begin(); i != _mapCallbacks.end(); i++ )
        {
            i->get()->onMapModelChanged( MapModelChange(
                MapModelChange::REMOVE_IMAGE_LAYER, newRevision, layerToRemove.get(), index) );
            //i->get()->onImageLayerRemoved( layerToRemove.get(), index, newRevision );
        }
    }
}

Here is the call graph for this function:

void Map::removeMapCallback ( MapCallback callback)

Definition at line 328 of file Map.cpp.

{
    MapCallbackList::iterator i = std::find( _mapCallbacks.begin(), _mapCallbacks.end(), cb);
    if (i != _mapCallbacks.end())
    {
        _mapCallbacks.erase( i );
    }    
}
void Map::removeModelLayer ( ModelLayer layer)

Removes a model layer from the map.

Definition at line 685 of file Map.cpp.

{
    if ( layer )
    {
        //Take a reference to the layer since we will be deleting it
        osg::ref_ptr< ModelLayer > layerRef = layer;

        Revision newRevision;
        {
            Threading::ScopedWriteLock lock( _mapDataMutex );
            for( ModelLayerVector::iterator i = _modelLayers.begin(); i != _modelLayers.end(); ++i )
            {
                if ( i->get() == layer )
                {
                    _modelLayers.erase( i );
                    newRevision = ++_dataModelRevision;
                    break;
                }
            }
        }

        for( MapCallbackList::iterator i = _mapCallbacks.begin(); i != _mapCallbacks.end(); ++i )
        {
            i->get()->onMapModelChanged( MapModelChange(
                MapModelChange::REMOVE_MODEL_LAYER, newRevision, layerRef.get()) );
        }
    }
}
void Map::removeTerrainMaskLayer ( MaskLayer layer)

Removed a terrain mask layer that was set with setTerrainMaskLayer().

Definition at line 785 of file Map.cpp.

{
    if ( layer )
    {
        //Take a reference to the layer since we will be deleting it
        osg::ref_ptr< MaskLayer > layerRef = layer;
        Revision newRevision;
        {
            Threading::ScopedWriteLock lock( _mapDataMutex );
            for( MaskLayerVector::iterator i = _terrainMaskLayers.begin(); i != _terrainMaskLayers.end(); ++i )
            {
                if ( i->get() == layer )
                {
                    _terrainMaskLayers.erase( i );
                    newRevision = ++_dataModelRevision;
                    break;
                }
            }
        }
        
        // a separate block b/c we don't need the mutex   
        for( MapCallbackList::iterator i = _mapCallbacks.begin(); i != _mapCallbacks.end(); i++ )
        {
            i->get()->onMapModelChanged( MapModelChange(
                MapModelChange::REMOVE_MASK_LAYER, newRevision, layerRef.get()) );
        }       
    }
}
void Map::setCache ( Cache cache)

Sets the Cache for this Map. Set to NULL for no cache.

Definition at line 300 of file Map.cpp.

{
    if (_cache.get() != cache)
    {
        _cache = cache;
        _cache->setReferenceURI( _mapOptions.referenceURI().value() );

        //Propagate the cache to any of our layers
        for (ImageLayerVector::iterator i = _imageLayers.begin(); i != _imageLayers.end(); ++i)
        {
            i->get()->setCache( _cache.get() );
        }

        for (ElevationLayerVector::iterator i = _elevationLayers.begin(); i != _elevationLayers.end(); ++i)
        {
            i->get()->setCache( _cache.get() );
        }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void Map::setGlobalOptions ( const osgDB::ReaderWriter::Options *  options)

Definition at line 86 of file Map.cpp.

                                                               {
    _globalOptions = options;
}
void Map::setName ( const std::string &  name)

Sets the readable name of this map.

Definition at line 254 of file Map.cpp.

                                    {
    _name = name;
}
bool Map::sync ( class MapFrame frame) const

Synronizes a map frame to the current revision of the map's data model. Returns true if new Map model data was available and a sync occurred; returns false if nothing changed.

Definition at line 1168 of file Map.cpp.

{
    bool result = false;

    if ( frame._mapDataModelRevision != _dataModelRevision || !frame._initialized )
    {
        // hold the read lock while copying the layer lists.
        Threading::ScopedReadLock lock( const_cast<Map*>(this)->_mapDataMutex );

        if ( frame._parts & IMAGE_LAYERS )
        {
            if ( !frame._initialized )
                frame._imageLayers.reserve( _imageLayers.size() );
            frame._imageLayers.clear();
            if ( frame._copyValidDataOnly )
            {
                for( ImageLayerVector::const_iterator i = _imageLayers.begin(); i != _imageLayers.end(); ++i )
                    if ( i->get()->getProfile() )
                        frame._imageLayers.push_back( i->get() );
            }
            else
                std::copy( _imageLayers.begin(), _imageLayers.end(), std::back_inserter(frame._imageLayers) );
        }

        if ( frame._parts & ELEVATION_LAYERS )
        {
            if ( !frame._initialized )
                frame._elevationLayers.reserve( _elevationLayers.size() );
            frame._elevationLayers.clear();
            if ( frame._copyValidDataOnly )
            {
                for( ElevationLayerVector::const_iterator i = _elevationLayers.begin(); i != _elevationLayers.end(); ++i )
                    if ( i->get()->getProfile() )
                        frame._elevationLayers.push_back( i->get() );
            }
            else
                std::copy( _elevationLayers.begin(), _elevationLayers.end(), std::back_inserter(frame._elevationLayers) );
        }

        if ( frame._parts & MODEL_LAYERS )
        {
            if ( !frame._initialized )
                frame._modelLayers.reserve( _modelLayers.size() );
            frame._modelLayers.clear();
            std::copy( _modelLayers.begin(), _modelLayers.end(), std::back_inserter(frame._modelLayers) );
        }

        if ( frame._parts & MASK_LAYERS )
        {
          if ( !frame._initialized )
              frame._maskLayers.reserve( _terrainMaskLayers.size() );
          frame._maskLayers.clear();
          std::copy( _terrainMaskLayers.begin(), _terrainMaskLayers.end(), std::back_inserter(frame._maskLayers) );
        }

        // sync the revision numbers.
        frame._initialized = true;
        frame._mapDataModelRevision = _dataModelRevision;
            
        result = true;
    }    
    return result;
}

Here is the call graph for this function:

bool Map::toMapPoint ( const osg::Vec3d &  input,
const SpatialReference input_srs,
osg::Vec3d &  output 
) const

Convenience function to convert an arbitrary point to map coordinates.

Definition at line 1233 of file Map.cpp.

{
    return MapInfo(this).toMapPoint(input, inputSRS, output);
}

Here is the call graph for this function:

bool Map::worldPointToMapPoint ( const osg::Vec3d &  input,
osg::Vec3d &  output 
) const

Convenience function to convert a world-space (XYZ) point to map coordinates.

Definition at line 1245 of file Map.cpp.

{
    return MapInfo(this).worldPointToMapPoint(input, output);
}

Here is the call graph for this function:


Member Data Documentation

osg::ref_ptr<Cache> osgEarth::Map::_cache [private]

Definition at line 400 of file Map.

Definition at line 401 of file Map.

Definition at line 393 of file Map.

osg::ref_ptr<const osgDB::ReaderWriter::Options> osgEarth::Map::_globalOptions [private]

Definition at line 397 of file Map.

Definition at line 392 of file Map.

Definition at line 396 of file Map.

Definition at line 398 of file Map.

Definition at line 390 of file Map.

Definition at line 394 of file Map.

std::string osgEarth::Map::_name [private]

Definition at line 391 of file Map.

osg::ref_ptr<const Profile> osgEarth::Map::_profile [private]

Definition at line 399 of file Map.

Definition at line 395 of file Map.


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