void TerrainEngineNode::onMapInfoEstablished( const MapInfo& mapInfo ) { // set up the CSN values mapInfo.getProfile()->getSRS()->populateCoordinateSystemNode( this ); // OSG's CSN likes a NULL ellipsoid to represent projected mode. if ( !mapInfo.isGeocentric() ) this->setEllipsoidModel( NULL ); }
void GeometryPool::createKeyForTileKey(const TileKey& tileKey, unsigned size, const MapInfo& mapInfo, GeometryPool::GeometryKey& out) const { out.lod = tileKey.getLOD(); out.yMin = mapInfo.isGeocentric()? tileKey.getExtent().yMin() : 0.0; out.size = size; }
// This method is called by StreamingTerrainNode::traverse() in the UPDATE TRAVERSAL. void StreamingTerrainNode::refreshFamily(const MapInfo& mapInfo, const TileKey& key, StreamingTile::Relative* family, bool tileTableLocked ) { osgTerrain::TileID tileId = key.getTileId(); // geocentric maps wrap around in the X dimension. bool wrapX = mapInfo.isGeocentric(); unsigned int tileCountX, tileCountY; mapInfo.getProfile()->getNumTiles( tileId.level, tileCountX, tileCountY ); // Relative::PARENT { family[StreamingTile::Relative::PARENT].expected = true; // TODO: is this always correct? family[StreamingTile::Relative::PARENT].elevLOD = -1; family[StreamingTile::Relative::PARENT].imageLODs.clear(); family[StreamingTile::Relative::PARENT].tileID = osgTerrain::TileID( tileId.level-1, tileId.x/2, tileId.y/2 ); osg::ref_ptr<StreamingTile> parent; getTile( family[StreamingTile::Relative::PARENT].tileID, parent, !tileTableLocked ); if ( parent.valid() ) { family[StreamingTile::Relative::PARENT].elevLOD = parent->getElevationLOD(); ColorLayersByUID relLayers; parent->getCustomColorLayers( relLayers ); for( ColorLayersByUID::const_iterator i = relLayers.begin(); i != relLayers.end(); ++i ) { family[StreamingTile::Relative::PARENT].imageLODs[i->first] = i->second.getLevelOfDetail(); } } } // Relative::WEST { family[StreamingTile::Relative::WEST].expected = tileId.x > 0 || wrapX; family[StreamingTile::Relative::WEST].elevLOD = -1; family[StreamingTile::Relative::WEST].imageLODs.clear(); family[StreamingTile::Relative::WEST].tileID = osgTerrain::TileID( tileId.level, tileId.x > 0? tileId.x-1 : tileCountX-1, tileId.y ); osg::ref_ptr<StreamingTile> west; getTile( family[StreamingTile::Relative::WEST].tileID, west, !tileTableLocked ); if ( west.valid() ) { family[StreamingTile::Relative::WEST].elevLOD = west->getElevationLOD(); ColorLayersByUID relLayers; west->getCustomColorLayers( relLayers ); for( ColorLayersByUID::const_iterator i = relLayers.begin(); i != relLayers.end(); ++i ) { family[StreamingTile::Relative::WEST].imageLODs[i->first] = i->second.getLevelOfDetail(); } } } // Relative::NORTH { family[StreamingTile::Relative::NORTH].expected = tileId.y < (int)tileCountY-1; family[StreamingTile::Relative::NORTH].elevLOD = -1; family[StreamingTile::Relative::NORTH].imageLODs.clear(); family[StreamingTile::Relative::NORTH].tileID = osgTerrain::TileID( tileId.level, tileId.x, tileId.y < (int)tileCountY-1 ? tileId.y+1 : 0 ); osg::ref_ptr<StreamingTile> north; getTile( family[StreamingTile::Relative::NORTH].tileID, north, !tileTableLocked ); if ( north.valid() ) { family[StreamingTile::Relative::NORTH].elevLOD = north->getElevationLOD(); ColorLayersByUID relLayers; north->getCustomColorLayers( relLayers ); for( ColorLayersByUID::const_iterator i = relLayers.begin(); i != relLayers.end(); ++i ) { family[StreamingTile::Relative::NORTH].imageLODs[i->first] = i->second.getLevelOfDetail(); } } } // Relative::EAST { family[StreamingTile::Relative::EAST].expected = tileId.x < (int)tileCountX-1 || wrapX; family[StreamingTile::Relative::EAST].elevLOD = -1; family[StreamingTile::Relative::EAST].imageLODs.clear(); family[StreamingTile::Relative::EAST].tileID = osgTerrain::TileID( tileId.level, tileId.x < (int)tileCountX-1 ? tileId.x+1 : 0, tileId.y ); osg::ref_ptr<StreamingTile> east; getTile( family[StreamingTile::Relative::EAST].tileID, east, !tileTableLocked ); if ( east.valid() ) { family[StreamingTile::Relative::EAST].elevLOD = east->getElevationLOD(); ColorLayersByUID relLayers; east->getCustomColorLayers( relLayers ); for( ColorLayersByUID::const_iterator i = relLayers.begin(); i != relLayers.end(); ++i ) { family[StreamingTile::Relative::EAST].imageLODs[i->first] = i->second.getLevelOfDetail(); } } } // Relative::SOUTH { family[StreamingTile::Relative::SOUTH].expected = tileId.y > 0; family[StreamingTile::Relative::SOUTH].elevLOD = -1; family[StreamingTile::Relative::SOUTH].imageLODs.clear(); family[StreamingTile::Relative::SOUTH].tileID = osgTerrain::TileID( tileId.level, tileId.x, tileId.y > 0 ? tileId.y-1 : tileCountY-1 ); osg::ref_ptr<StreamingTile> south; getTile( family[StreamingTile::Relative::SOUTH].tileID, south, !tileTableLocked ); if ( south.valid() ) { family[StreamingTile::Relative::SOUTH].elevLOD = south->getElevationLOD(); ColorLayersByUID relLayers; south->getCustomColorLayers( relLayers ); for( ColorLayersByUID::const_iterator i = relLayers.begin(); i != relLayers.end(); ++i ) { family[StreamingTile::Relative::SOUTH].imageLODs[i->first] = i->second.getLevelOfDetail(); } } } }