osgEarth2.10.2中添加城市名称标签的一种方法

最近想添加一个城市标签名,折腾半天,后来发现,在osgEarth的安装文档里,有一个tests文件夹,里面有一个叫做feature_labels.earth的文件,里面如下显示:

<!--
osgEarth Sample
This shows how to label point features with an attribute.
-->

<map name="Feature Geometry Demo" type="geocentric" version="2">
            
    <image name="World Imagery" driver="gdal">
        <url>../data/world.tif</url>
    </image>
    
    <feature_source name="city-data" driver="ogr">
        <url>../data/cities.gpkg</url>
    </feature_source>
    
    <feature_model name="cities" feature_source="city-data">        
        <feature_indexing enabled="false"/>
        <styles>
            <selector class="cities">
                <query><expr><![CDATA[rank_max >= 8]]></expr></query>
            </selector>
            <style type="text/css">              
                cities {
                    icon:           "../data/downarrow.png";
                    icon-placement: centroid;
                    icon-declutter: true;
                    icon-align:     center-bottom;
                    text-content:   [name];
                    text-encoding:  utf-8;
                    text-priority:  [rank_max];
                    text-align:     center-bottom;
                    text-halo:      #1f1f1f;
                    text-size:      6+2*[rank_max];
                }     
            </style>
        </styles>
    </feature_model>
    
    <screen_space_layout>
        <out_animation_time>  0.0  </out_animation_time>
        <in_animation_time>   0.25 </in_animation_time>
        <min_animation_scale> 0.45 </min_animation_scale>
        <min_animation_alpha> 0.0  </min_animation_alpha>
        <sort_by_priority>    true </sort_by_priority>
    </screen_space_layout>
  
</map>

可以看见,其实osgearth里自带了城市名称的标签,不过是英文的,位置就在../data/cities.gpkg。对,就是这个cities.gpkg文件。就在osgearth的安装包的data文件夹下。
根据feature_labels.earth的内容可以猜测,之前试图通过shp文件来导入城市坐标点,却一直失败的原因,可能是因为shp文件中的键值对的键,和osgearth中的不匹配。
启发,应该没事多看看tests和data文件夹下的东西,osgearth带了很多例子,很有启发性。

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

鱼月半

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值