目标:(二十九)中的问题87
osgEarth如何对投影坐标系和大地坐标系进行显示处理的
为什么一个能显示成球,一个显示成平面
<map name="MBTiles" type="geocentric" version="2">
<options>
<profile>epsg:4326</profile>
<terrain driver="rex"/>
</options>
<image name="Sample MBTiles Database" driver="mbtiles">
<filename>world_countries.mbtiles</filename>
</image>
</map>
<map name="MBTiles" type="projected" version="2">
<options>
<profile>epsg:4326</profile>
<terrain driver="rex"/>
</options>
<image name="Sample MBTiles Database" driver="mbtiles">
<filename>world_countries.mbtiles</filename>
</image>
</map>
这是因为每个TileNode的显示信息,会根据投影关系进行调整。TileNode显示信息的生成过程如下:
1、TileNode在创建时会生成显示信息
osgEarthDrivers/engine_rex/TileNode.cpp
void
TileNode::create(const TileKey& key, TileNode* parent, EngineContext* context)
{
osg::ref_ptr<SharedGeometry> geom;
context->getGeometryPool()->getPooledGeometry(
key,
mapInfo,
context->getOptions().tileSize().get(),
masks.get(),
geom);
TileDrawable* surfaceDrawable = new TileDrawable(
key,
geom.get(),
context->getOptions().tileSize().get() );
// Give the tile Drawable access to the render model so it can properly
// calculate its bounding box and sphere.
surfaceDrawable->setModifyBBoxCallback(context->getModifyBBoxCallback());
// Create the node to house the tile drawable:
_surface = new SurfaceNode(
key,
mapInfo,
context->getRenderBindings(),
surfaceDrawable );
}
2、1会从瓦片几何图形池中寻找该瓦片的几何图形,注意几何图形池中的几何图形只和lod级别有关,而和水平垂直方向的位置无关,如果几何图形池中没有对应lod级别的瓦片,则几何图形池会创建,创建过程就会考虑地图的投影方式,从而确保这些几何图形拼接气起来是平面或球面。创建过程如下:
osgEarthDrivers/engine_rex/GeometryPool.cpp
SharedGeometry*
GeometryPool::createGeometry(const TileKey& tileKey,
const MapInfo& mapInfo,
unsigned tileSize,
MaskGenerator* mask