本文整理汇总了C++中ImageLayer::getTileSource方法的典型用法代码示例。如果您正苦于以下问题:C++ ImageLayer::getTileSource方法的具体用法?C++ ImageLayer::getTileSource怎么用?C++ ImageLayer::getTileSource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImageLayer
的用法示例。
在下文中一共展示了ImageLayer::getTileSource方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: seed
void CacheSeed::seed( Map* map )
{
// We must do this to avoid an error message in OpenSceneGraph b/c the findWrapper method doesn't appear to be threadsafe.
// This really isn't a big deal b/c this only effects data that is already cached.
osgDB::ObjectWrapper* wrapper = osgDB::Registry::instance()->getObjectWrapperManager()->findWrapper( "osg::Image" );
osg::Timer_t startTime = osg::Timer::instance()->tick();
if ( !map->getCache() )
{
OE_WARN << LC << "Warning: No cache defined; aborting." << std::endl;
return;
}
std::vector<TileKey> keys;
map->getProfile()->getRootKeys(keys);
//Add the map's entire extent if we don't have one specified.
if (_extents.empty())
{
addExtent( map->getProfile()->getExtent() );
}
bool hasCaches = false;
int src_min_level = INT_MAX;
unsigned int src_max_level = 0;
MapFrame mapf( map, Map::TERRAIN_LAYERS, "CacheSeed::seed" );
//Assumes the the TileSource will perform the caching for us when we call createImage
for( ImageLayerVector::const_iterator i = mapf.imageLayers().begin(); i != mapf.imageLayers().end(); i++ )
{
ImageLayer* layer = i->get();
TileSource* src = layer->getTileSource();
const ImageLayerOptions& opt = layer->getImageLayerOptions();
if ( layer->isCacheOnly() )
{
OE_WARN << LC << "Warning: Layer \"" << layer->getName() << "\" is set to cache-only; skipping." << std::endl;
}
else if ( !src )
{
OE_WARN << "Warning: Layer \"" << layer->getName() << "\" could not create TileSource; skipping." << std::endl;
}
//else if ( src->getCachePolicyHint(0L) == CachePolicy::NO_CACHE )
//{
// OE_WARN << LC << "Warning: Layer \"" << layer->getName() << "\" does not support seeding; skipping." << std::endl;
//}
else if ( !layer->getCache() )
{
OE_WARN << LC << "Notice: Layer \"" << layer->getName() << "\" has no cache defined; skipping." << std::endl;
}
else
{
hasCaches = true;
if (opt.minLevel().isSet() && (int)opt.minLevel().get() < src_min_level)
src_min_level = opt.minLevel().get();
if (opt.maxLevel().isSet() && opt.maxLevel().get() > src_max_level)
src_max_level = opt.maxLevel().get();
}
}
for( ElevationLayerVector::const_iterator i = mapf.elevationLayers().begin(); i != mapf.elevationLayers().end(); i++ )
{
ElevationLayer* layer = i->get();
TileSource* src = layer->getTileSource();
const ElevationLayerOptions& opt = layer->getElevationLayerOptions();
if ( layer->isCacheOnly() )
{
OE_WARN << LC << "Warning: Layer \"" << layer->getName() << "\" is set to cache-only; skipping." << std::endl;
}
else if (!src)
{
OE_WARN << "Warning: Layer \"" << layer->getName() << "\" could not create TileSource; skipping." << std::endl;
}
//else if ( src->getCachePolicyHint(0L) == CachePolicy::NO_CACHE )
//{
// OE_WARN << LC << "Warning: Layer \"" << layer->getName() << "\" does not support seeding; skipping." << std::endl;
//}
else if ( !layer->getCache() )
{
OE_WARN << LC << "Notice: Layer \"" << layer->getName() << "\" has no cache defined; skipping." << std::endl;
}
else
{
hasCaches = true;
if (opt.minLevel().isSet() && (int)opt.minLevel().get() < src_min_level)
src_min_level = opt.minLevel().get();
if (opt.maxLevel().isSet() && opt.maxLevel().get() > src_max_level)
src_max_level = opt.maxLevel().get();
}
}
if ( !hasCaches )
{
OE_WARN << LC << "There are either no caches defined in the map, or no sources to cache; aborting." << std::endl;
return;
//.........这里部分代码省略.........
示例2: if
osg::Image*
CompositeTileSource::createImage(const TileKey& key,
ProgressCallback* progress )
{
ImageMixVector images;
images.reserve(_imageLayers.size());
// Try to get an image from each of the layers for the given key.
for (ImageLayerVector::const_iterator itr = _imageLayers.begin(); itr != _imageLayers.end(); ++itr)
{
ImageLayer* layer = itr->get();
ImageInfo imageInfo;
imageInfo.dataInExtents = layer->getTileSource()->hasDataInExtent( key.getExtent() );
imageInfo.opacity = layer->getOpacity();
if (imageInfo.dataInExtents)
{
GeoImage image = layer->createImage(key, progress);
if (image.valid())
{
imageInfo.image = image.getImage();
}
// If the progress got cancelled or it needs a retry then return NULL to prevent this tile from being built and cached with incomplete or partial data.
if (progress && (progress->isCanceled() || progress->needsRetry()))
{
OE_DEBUG << LC << " createImage was cancelled or needs retry for " << key.str() << std::endl;
return 0L;
}
}
images.push_back(imageInfo);
}
// Determine the output texture size to use based on the image that were creatd.
unsigned numValidImages = 0;
osg::Vec2s textureSize;
for (unsigned int i = 0; i < images.size(); i++)
{
ImageInfo& info = images[i];
if (info.image.valid())
{
if (numValidImages == 0)
{
textureSize.set( info.image->s(), info.image->t());
}
numValidImages++;
}
}
// Create fallback images if we have some valid data but not for all the layers
if (numValidImages > 0 && numValidImages < images.size())
{
for (unsigned int i = 0; i < images.size(); i++)
{
ImageInfo& info = images[i];
ImageLayer* layer = _imageLayers[i].get();
if (!info.image.valid() && info.dataInExtents)
{
TileKey parentKey = key.createParentKey();
GeoImage image;
while (!image.valid() && parentKey.valid())
{
image = layer->createImage(parentKey, progress);
if (image.valid())
{
break;
}
// If the progress got cancelled or it needs a retry then return NULL to prevent this tile from being built and cached with incomplete or partial data.
if (progress && (progress->isCanceled() || progress->needsRetry()))
{
OE_DEBUG << LC << " createImage was cancelled or needs retry for " << key.str() << std::endl;
return 0L;
}
parentKey = parentKey.createParentKey();
}
if (image.valid())
{
// TODO: Bilinear options?
bool bilinear = layer->isCoverage() ? false : true;
GeoImage cropped = image.crop( key.getExtent(), true, textureSize.x(), textureSize.y(), bilinear);
info.image = cropped.getImage();
}
}
}
}
// Now finally create the output image.
//Recompute the number of valid images
numValidImages = 0;
for (unsigned int i = 0; i < images.size(); i++)
{
ImageInfo& info = images[i];
if (info.image.valid()) numValidImages++;
}
//.........这里部分代码省略.........
示例3: seed
void CacheSeed::seed( Map* map )
{
if ( !map->getCache() )
{
OE_WARN << LC << "Warning: No cache defined; aborting." << std::endl;
return;
}
std::vector<TileKey> keys;
map->getProfile()->getRootKeys(keys);
//Add the map's entire extent if we don't have one specified.
if (_extents.empty())
{
addExtent( map->getProfile()->getExtent() );
}
bool hasCaches = false;
int src_min_level = INT_MAX;
unsigned int src_max_level = 0;
MapFrame mapf( map, Map::TERRAIN_LAYERS, "CacheSeed::seed" );
//Assumes the the TileSource will perform the caching for us when we call createImage
for( ImageLayerVector::const_iterator i = mapf.imageLayers().begin(); i != mapf.imageLayers().end(); i++ )
{
ImageLayer* layer = i->get();
TileSource* src = layer->getTileSource();
const ImageLayerOptions& opt = layer->getImageLayerOptions();
if ( layer->isCacheOnly() )
{
OE_WARN << LC << "Warning: Layer \"" << layer->getName() << "\" is set to cache-only; skipping." << std::endl;
}
else if ( !src )
{
OE_WARN << "Warning: Layer \"" << layer->getName() << "\" could not create TileSource; skipping." << std::endl;
}
//else if ( src->getCachePolicyHint(0L) == CachePolicy::NO_CACHE )
//{
// OE_WARN << LC << "Warning: Layer \"" << layer->getName() << "\" does not support seeding; skipping." << std::endl;
//}
else if ( !layer->getCache() )
{
OE_WARN << LC << "Notice: Layer \"" << layer->getName() << "\" has no cache defined; skipping." << std::endl;
}
else
{
hasCaches = true;
if (opt.minLevel().isSet() && (int)opt.minLevel().get() < src_min_level)
src_min_level = opt.minLevel().get();
if (opt.maxLevel().isSet() && opt.maxLevel().get() > src_max_level)
src_max_level = opt.maxLevel().get();
}
}
for( ElevationLayerVector::const_iterator i = mapf.elevationLayers().begin(); i != mapf.elevationLayers().end(); i++ )
{
ElevationLayer* layer = i->get();
TileSource* src = layer->getTileSource();
const ElevationLayerOptions& opt = layer->getElevationLayerOptions();
if ( layer->isCacheOnly() )
{
OE_WARN << LC << "Warning: Layer \"" << layer->getName() << "\" is set to cache-only; skipping." << std::endl;
}
else if (!src)
{
OE_WARN << "Warning: Layer \"" << layer->getName() << "\" could not create TileSource; skipping." << std::endl;
}
//else if ( src->getCachePolicyHint(0L) == CachePolicy::NO_CACHE )
//{
// OE_WARN << LC << "Warning: Layer \"" << layer->getName() << "\" does not support seeding; skipping." << std::endl;
//}
else if ( !layer->getCache() )
{
OE_WARN << LC << "Notice: Layer \"" << layer->getName() << "\" has no cache defined; skipping." << std::endl;
}
else
{
hasCaches = true;
if (opt.minLevel().isSet() && (int)opt.minLevel().get() < src_min_level)
src_min_level = opt.minLevel().get();
if (opt.maxLevel().isSet() && opt.maxLevel().get() > src_max_level)
src_max_level = opt.maxLevel().get();
}
}
if ( !hasCaches )
{
OE_WARN << LC << "There are either no caches defined in the map, or no sources to cache; aborting." << std::endl;
return;
}
if ( src_max_level > 0 && src_max_level < _maxLevel )
{
_maxLevel = src_max_level;
//.........这里部分代码省略.........
示例4: if
void
Map::calculateProfile()
{
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 SRS ("
<< userProfile->getSRS()->getName() << ") is not geographic; "
<< "it will be ignored."
<< 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();
}
}
}
// convert the profile to Plate Carre if necessary.
if (_profile.valid() &&
_profile->getSRS()->isGeographic() &&
getMapOptions().coordSysType() == MapOptions::CSTYPE_PROJECTED )
{
OE_INFO << LC << "Projected display with geographic SRS; activating Plate Carre mode" << std::endl;
_profile = _profile->overrideSRS( _profile->getSRS()->createPlateCarreGeographicSRS() );
}
// 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;
}
}
//.........这里部分代码省略.........
示例5: seed
void CacheSeed::seed( Map* map )
{
if ( !map->getCache() )
{
OE_WARN << LC << "Warning: No cache defined; aborting." << std::endl;
return;
}
std::vector<TileKey> keys;
map->getProfile()->getRootKeys(keys);
//Add the map's entire extent if we don't have one specified.
if (_extents.empty())
{
addExtent( map->getProfile()->getExtent() );
}
bool hasCaches = false;
int src_min_level = INT_MAX;
unsigned int src_max_level = 0;
MapFrame mapf( map, Map::TERRAIN_LAYERS, "CacheSeed::seed" );
//Assumes the the TileSource will perform the caching for us when we call createImage
for( ImageLayerVector::const_iterator i = mapf.imageLayers().begin(); i != mapf.imageLayers().end(); i++ )
{
ImageLayer* layer = i->get();
TileSource* src = layer->getTileSource();
const ImageLayerOptions& opt = layer->getImageLayerOptions();
if ( layer->isCacheOnly() )
{
OE_WARN << LC << "Warning: Layer \"" << layer->getName() << "\" is set to cache-only; skipping." << std::endl;
}
else if ( !src )
{
OE_WARN << "Warning: Layer \"" << layer->getName() << "\" could not create TileSource; skipping." << std::endl;
}
//else if ( src->getCachePolicyHint(0L) == CachePolicy::NO_CACHE )
//{
// OE_WARN << LC << "Warning: Layer \"" << layer->getName() << "\" does not support seeding; skipping." << std::endl;
//}
else if ( !layer->getCache() )
{
OE_WARN << LC << "Notice: Layer \"" << layer->getName() << "\" has no cache defined; skipping." << std::endl;
}
else
{
hasCaches = true;
if (opt.minLevel().isSet() && (int)opt.minLevel().get() < src_min_level)
src_min_level = opt.minLevel().get();
if (opt.maxLevel().isSet() && opt.maxLevel().get() > src_max_level)
src_max_level = opt.maxLevel().get();
}
}
for( ElevationLayerVector::const_iterator i = mapf.elevationLayers().begin(); i != mapf.elevationLayers().end(); i++ )
{
ElevationLayer* layer = i->get();
TileSource* src = layer->getTileSource();
const ElevationLayerOptions& opt = layer->getElevationLayerOptions();
if ( layer->isCacheOnly() )
{
OE_WARN << LC << "Warning: Layer \"" << layer->getName() << "\" is set to cache-only; skipping." << std::endl;
}
else if (!src)
{
OE_WARN << "Warning: Layer \"" << layer->getName() << "\" could not create TileSource; skipping." << std::endl;
}
//else if ( src->getCachePolicyHint(0L) == CachePolicy::NO_CACHE )
//{
// OE_WARN << LC << "Warning: Layer \"" << layer->getName() << "\" does not support seeding; skipping." << std::endl;
//}
else if ( !layer->getCache() )
{
OE_WARN << LC << "Notice: Layer \"" << layer->getName() << "\" has no cache defined; skipping." << std::endl;
}
else
{
hasCaches = true;
if (opt.minLevel().isSet() && (int)opt.minLevel().get() < src_min_level)
src_min_level = opt.minLevel().get();
if (opt.maxLevel().isSet() && opt.maxLevel().get() > src_max_level)
src_max_level = opt.maxLevel().get();
}
}
if ( !hasCaches )
{
OE_WARN << LC << "There are either no caches defined in the map, or no sources to cache; aborting." << std::endl;
return;
}
if ( src_max_level > 0 && src_max_level < _maxLevel )
{
_maxLevel = src_max_level;
//.........这里部分代码省略.........
示例6: if
void
Map::calculateProfile()
{
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() );
//.........这里部分代码省略.........