Map Callbacks

classic Classic list List threaded Threaded
9 messages Options
kostinio1 kostinio1
Reply | Threaded
Open this post in threaded view
|

Map Callbacks

I need to know when Map layer does its update. This occurs when zoom or rotation changes and low resolution tile is replaced by detalized one. I tried to find some callbacks or virtual functions but could not. At least i need recieve event when whole map is updated, but it would be great to get it on each tile of each layer.
Please, help me to find some methods or different solution.
gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|

Re: Map Callbacks

Kostinio,
You can try MapNode->getTerrain()->addTerrainCallback.
Glenn Waldron / Pelican Mapping
kostinio1 kostinio1
Reply | Threaded
Open this post in threaded view
|

Re: Map Callbacks

Thank you for advice, gwaldron, but it is not exactly what i need.
My primary purpose is to draw as less frames as it possible. I call frame() method manually only on several conditions. Now i need to update tiles after camera changes. As i discovered from code inspection, tiles getting their updates from traverse() method that is result of frame() call. That is mean that i need to call frame() on my Viewer many times untill all tiles are ready. But when i should stop doing my calls?
For example RexTerrainEngineNode has PageLoader object as child which has Requests map which i could analize and check if it contains not finished requests. Requests field is protected, but i can inherit from PageLoader and get it. But i cant create PageLoader object getting unresolved refference link errors (mb because it is in library osgdb_osgearth_engine_rex).
There is also TileNodeRegistry object in RexTerrainEngineNode, but it is private.
gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|

Re: Map Callbacks

Kostinio,
What you are after (I believe) is called an ON_DEMAND frame scheme, in which the OSG viewer will only call frame() when something changes. Although you can request this scheme through the osgViewer::Viewer API, the REX terrain engine does not support it. It's on the to-do list but we don't have a specific time frame for it.

The REX terrain engine is encapsulated in a plugin - it is an internal library and API access is not available.
Glenn Waldron / Pelican Mapping
kostinio1 kostinio1
Reply | Threaded
Open this post in threaded view
|

Re: Map Callbacks

Gwaldron,
I saw frame scheme option and reworked Viewer::checkNeedToDoFrame() method in my class to not get spam from RexTerrainEngineNode. Anyway can i do something to check tile's state or something else for my needs?
gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|

Re: Map Callbacks

No. Support for the ON_DEMAND scheme will require internal changes to the rex engine. Several elements currently expect a continuous update traversal and we will need to rework that.

Currently your only option for ON_DEMAND support is to revert to using the legacy mp terrain engine.
Glenn Waldron / Pelican Mapping
kostinio1 kostinio1
Reply | Threaded
Open this post in threaded view
|

Re: Map Callbacks

I extremely need last ImageLayer support for textures input :)
In my ON_DEMAND implementation only one need is to know when i should stop call frame(). For example if i do it N times, it can be enough for tiles to be updated. But if connection is too slow it can be not enough.
OK, looks like there are no api abilities.
kostinio1 kostinio1
Reply | Threaded
Open this post in threaded view
|

Re: Map Callbacks

In reply to this post by gwaldron
Can I draw MapNode continuously and other nodes on demand?
kostinio1 kostinio1
Reply | Threaded
Open this post in threaded view
|

Re: Map Callbacks

In reply to this post by kostinio1
Finaly i did what i want.
I use this code to update tiles continuously (in osgViewer::Viewer inheritor)
        mapNode->accept(*_eventVisitor);
        if (getDatabasePager())
        {
             getDatabasePager()->updateSceneGraph(*(_updateVisitor->getFrameStamp()));
        }

        if (getSceneData())
        {
            _updateVisitor->setImageRequestHandler(getImagePager());
            mapNode->accept(*_updateVisitor);
        }
And this generates callbacks on MapNode's terrain, which i use to call frame() method when tile is added.