这是一个非常小的技术点,本拟放在另外一篇文章中介绍,但考虑到其相对独立性,因此独立成篇。
当osgEarth的earth文件中将map的type设置为"projected"时,将以二维形式显示地球,可用于表现二维态势。
一、时变对象
在态势系统中,存在道路、城市等基本固定的二维对象,即传统上采用点、线、面表示的GIS数据,这些可以通过earth文件或者编码进行加载显示即可。
osgEarth对于点、线、面对象提供支持,如从一个矢量文件中加载线对象
void AddVector(osg::ref_ptr<osgEarth::Map> map){
std::string filePath = "world.shp";
osgEarth::Drivers::OGRFeatureOptions featureData;
featureData.url() = filePath;
osgEarth::Features::FeatureSourceLayerOptions ogrLayer;
ogrLayer.name() = filePath + "_source";
ogrLayer.featureSource() = featureData;
osgEarth::Features::FeatureSourceLayer* featureSourceLayer = new osgEarth::Features::FeatureSourceLayer(ogrLayer);
map->addLayer(featureSourceLayer);
osgEarth::Features::FeatureSource *features = featureSourceLayer->getFeatureSource();
osgEarth::Symbology::Style style;
osgEarth::Symbology::RenderSymbol* rs = style.getOrCreate<osgEarth::Symbology::RenderSymbol>()

本文详细介绍了如何在osgEarth中处理时变对象,包括使用预定义类型和直接使用osg几何对象的方法。针对动态对象,通过回调类模板实现数据更新,但效率问题需要注意。文中给出了实例,展示了采用osg几何对象绘制时变对象能有效提升效率,并提供了实际应用的效果图。
最低0.47元/天 解锁文章
207

被折叠的 条评论
为什么被折叠?



