osgEarth样式筛选 11. feature_style_selector.earth

osgEarth 样式筛选 11. feature_style_selector.earth


1) 案例概述

矢量样式筛选器案例

 

2) 软件环境

osgEarth:官方代码库2017.11.09最新代码地址:www.github.com/gwaldron/osgearth

osgEarth编辑器:SXEarth2.8及以上,下载地址:www.sxsim.com

 

3) 硬件环境

本文编写和案例测试使用的硬件环境:CPU: i5四核,显卡:GTX660,内存:8GB。

(推荐使用英伟达显卡,intel显卡,会出现三维场景中文字显示不全的问题,笔记本双显卡,需要切换到独显。)

 

4) 编辑测试

在场景面板,选中countries图层,在属性面板,右键单击“代码段”,选择编辑菜单,弹出代码编辑对话框,类似feature_scripted_styling_2.earth案例,getStyleClass函数返回了样式类别,增加两种返回条件,国别名称首字母,如果是A,无样式,如果是C,矢量拉起250000米,中国和加拿大首字母C,矢量被拉起了。如下代码:

if ( feature.properties.cntry_name.charAt(0) === 'A' )

return null;

if ( feature.properties.cntry_name.charAt(0) == 'C' )

return '{ fill: #ffc838; stroke: #8f8838; extrusion-height: 250000; }';


osgEarth样式筛选 11. feature_style_selector.earth