#include <osgDB/FileNameUtils>
#include <osgDB/FileUtils>
#include <osg/io_utils>
#include <osgEarth/Common>
#include <osgEarth/Map>
#include <osgEarth/CacheSeed>
#include <osgEarth/MapNode>
#include <osgEarth/Registry>
#include <osgEarth/Caching>
#include <iostream>
#include <sstream>
#include <iterator>
Go to the source code of this file.
Defines |
#define | LC "[osgearth_cache] " |
Functions |
int | list (osg::ArgumentParser &args) |
int | seed (osg::ArgumentParser &args) |
int | purge (osg::ArgumentParser &args) |
int | usage (const std::string &msg) |
int | message (const std::string &msg) |
int | main (int argc, char **argv) |
Define Documentation
#define LC "[osgearth_cache] " |
Function Documentation
int list |
( |
osg::ArgumentParser & |
args | ) |
|
Definition at line 151 of file osgearth_seed.cpp.
{
osg::ref_ptr<osg::Node> node = osgDB::readNodeFiles( args );
if ( !node.valid() )
return usage( "Failed to read .earth file." );
MapNode* mapNode = MapNode::findMapNode( node.get() );
if ( !mapNode )
return usage( "Input file was not a .earth file" );
Map* map = mapNode->getMap();
const Cache* cache = map->getCache();
if ( !cache )
return message( "Earth file does not contain a cache." );
std::cout
<< "Cache config = " << cache->getCacheOptions().getConfig().toString() << std::endl;
MapFrame mapf( mapNode->getMap() );
TerrainLayerVector layers;
std::copy( mapf.imageLayers().begin(), mapf.imageLayers().end(), std::back_inserter(layers) );
std::copy( mapf.elevationLayers().begin(), mapf.elevationLayers().end(), std::back_inserter(layers) );
for( TerrainLayerVector::const_iterator i =layers.begin(); i != layers.end(); ++i )
{
TerrainLayer* layer = i->get();
const CacheSpec& spec = layer->getCacheSpec();
std::cout
<< "Layer = \"" << layer->getName() << "\", cacheId = " << spec.cacheId() << std::endl;
}
return 0;
}
int main |
( |
int |
argc, |
|
|
char ** |
argv |
|
) |
| |
Definition at line 49 of file osgearth_seed.cpp.
{
osg::ArgumentParser args(&argc,argv);
if ( args.read( "--seed") )
return seed( args );
else if ( args.read( "--list" ) )
return list( args );
else if ( args.read( "--purge" ) )
return purge( args );
else
return usage("");
}
int message |
( |
const std::string & |
msg | ) |
|
Definition at line 92 of file osgearth_seed.cpp.
{
if ( !msg.empty() )
{
std::cout << msg << std::endl << std::endl;
}
return 0;
}
int purge |
( |
osg::ArgumentParser & |
args | ) |
|
Definition at line 188 of file osgearth_seed.cpp.
{
return usage( "Sorry, but purge is not yet implemented." );
osg::ref_ptr<osg::Node> node = osgDB::readNodeFiles( args );
if ( !node.valid() )
return usage( "Failed to read .earth file." );
MapNode* mapNode = MapNode::findMapNode( node.get() );
if ( !mapNode )
return usage( "Input file was not a .earth file" );
Map* map = mapNode->getMap();
const Cache* cache = map->getCache();
if ( !cache )
return message( "Earth file does not contain a cache." );
}
int seed |
( |
osg::ArgumentParser & |
args | ) |
|
Definition at line 103 of file osgearth_seed.cpp.
{
unsigned int minLevel = 0;
while (args.read("--min-level", minLevel));
unsigned int maxLevel = 5;
while (args.read("--max-level", maxLevel));
Bounds bounds(0, 0, 0, 0);
while (args.read("--bounds", bounds.xMin(), bounds.yMin(), bounds.xMax(), bounds.yMax()));
while (args.read("-b", bounds.xMin(), bounds.yMin(), bounds.xMax(), bounds.yMax()));
std::string cachePath;
while (args.read("--cache-path", cachePath));
std::string cacheType;
while (args.read("--cache-type", cacheType));
bool quiet = args.read("--quiet");
osg::ref_ptr<osg::Node> node = osgDB::readNodeFiles( args );
if ( !node.valid() )
return usage( "Failed to read .earth file." );
MapNode* mapNode = MapNode::findMapNode( node.get() );
if ( !mapNode )
return usage( "Input file was not a .earth file" );
CacheSeed seeder;
seeder.setMinLevel( minLevel );
seeder.setMaxLevel( maxLevel );
seeder.setBounds( bounds );
if (!quiet)
{
seeder.setProgressCallback(new ConsoleProgressCallback);
}
seeder.seed( mapNode->getMap() );
return 0;
}
int usage |
( |
const std::string & |
msg | ) |
|