osgEarth cache

classic Classic list List threaded Threaded
5 messages Options
SJ SJ
Reply | Threaded
Open this post in threaded view
|

osgEarth cache

osgEarth Developers Guide tell us how to add, remove and move image

and heightfield sources. But how to set cache for one MapLayer in

OSG? Who can tell me an example?
Adam Adam
Reply | Threaded
Open this post in threaded view
|

Re: osgEarth cache

As stated here: http://n2.nabble.com/Problem-with-cache-only-tp3787940p3788023.html

You specify the cache at map level only.
SJ SJ
Reply | Threaded
Open this post in threaded view
|

Re: osgEarth cache

How can we programmatically create a map and set its osgEarth cache at runtime using the osgEarth API?

For example: how to set several cache parameters of the osmLayer in our OSG application using the osgEarth API.

// Add an OpenStreetMap image source
Properties conf;
conf["url"] = "http://tile.openstreetmap.org/";
conf["format"] = "png";
conf["tms_type"] = "google";
MapLayer* osmLayer = new MapLayer("OSM", MapLayer::TYPE_IMAGE, "tms", conf);
osmLayer->setProfileConfig( ProfileConfig( "global-mercator" ) );
mapNode->getMap()->addMapLayer( osmLayer );
jasonbeverage jasonbeverage
Reply | Threaded
Open this post in threaded view
|

Re: osgEarth cache

Hi SJ,

What version of osgEarth are you using?  If you are using the SVN trunk, you can specify a cache on a map by simply assigning it via the setCache method.

osgEarth::Map* map = new osgEarth::Map* map;
map->setCache( new TMSCache( cache_path ) );
//Add layers like normal.

If you are wanting to specify a cache that all new maps loaded via readNodeFile are assigned, you can use the the osgEarth::Registry::instance()->setCacheOverride function.

So something like:

osgEarth::Cache* globalcache = new TMSCache( global_cache_path );
osgEarth::Registry::instance()->setCacheOverride ( globalcache );

//The map loaded here will automatically be assigned globalcache as it's cache.
osg::Node* map = osgDB::readNodeFile("mymap.earth");

Thanks,

Jason

On Thu, Oct 29, 2009 at 2:04 PM, SJ [via osgEarth] <[hidden email]> wrote:
How can we programmatically create a map and set its osgEarth cache at runtime using the osgEarth API?

For example: how to set several cache parameters of the osmLayer in our OSG application using the osgEarth API.

// Add an OpenStreetMap image source
Properties conf;
conf["url"] = "http://tile.openstreetmap.org/";
conf["format"] = "png";
conf["tms_type"] = "google";
MapLayer* osmLayer = new MapLayer("OSM", MapLayer::TYPE_IMAGE, "tms", conf);
osmLayer->setProfileConfig( ProfileConfig( "global-mercator" ) );
mapNode->getMap()->addMapLayer( osmLayer );



View message @ http://n2.nabble.com/osgEarth-cache-tp3887862p3914534.html
To start a new topic under osgEarth, email [hidden email]
To unsubscribe from osgEarth, click here.


SJ SJ
Reply | Threaded
Open this post in threaded view
|

Re: osgEarth cache

it can work correctly. thank you very much!