通过sld样式拉伸渲染为伪3d建筑的地图效果通过geoserver发布

伪三维图形,类似百度地图的建筑,sld设置
参考:https://www.jianshu.com/p/c157ee1bb0b7
参考:https://www.cnblogs.com/shitao/archive/2012/08/29/2661611.html

sld的样式一般都是在uDig中进行样式编辑和查看,随后导入到geoserver里面,用于地理要素的显示样式设置

sld样式的具体内容就不再赘述,sld相关标准链接:http://docs.geoserver.org/stable/en/user/styling/sld/reference/

首先要知道拉伸的对象是建筑或者其他附着设施,即面图层,点和线要素不存在高度的拉伸。

配置中关注一下内容:

   主要是isometric和offset两个ogc:function的名称
   isometric方法名中

     <Geometry>
          <ogc:Function name="isometric">
            <ogc:PropertyName>the_geom</ogc:PropertyName>
            <ogc:Literal>150</ogc:Literal>
          </ogc:Function>
     </Geometry>

/*
第一个参数the_geom是指空间数据类型的字段名称,在geoserver中发布矢量数据的时候能看到要素
的属性字段,一般情况下空间数据类型的默认字段名称就是the_geom。
    第二个参数是指拉伸长度值单位与要素所在坐标系一致
*/

一开始不知道这个the_geom是从哪里来的,也不知道空间数据类型的字段名称具体指什么,知道在发布服务的时候,看到下图中的内容才恍然大悟

dzjGISERthe_geom的来源

       

offset方法名中 the_geom同上,
    下面两个参数分别表示x左右,y上下的偏移量

<PolygonSymbolizer>
        <Geometry>
          <ogc:Function name="offset">
            <ogc:PropertyName>the_geom</ogc:PropertyName>
            <ogc:Literal>0</ogc:Literal>
            <ogc:Literal>150</ogc:Literal>
          
          </ogc:Function>
        </Geometry>
        <Fill>
          <CssParameter name="fill">#BAD8E2</CssParameter>
          <CssParameter name="fill-opacity">1</CssParameter>
        </Fill>
    
</PolygonSymbolizer>


/*
    这里都是固定的拉伸值和偏移量,在实际应用中可以借助地理要的字段进行要素的拉伸,将
    <ogc:Literal>的属性换成<ogc:PropertyName>height</ogc:PropertyName>height是指字段名
*/

    下面上完整的配置信息:

<?xml version="1.0" encoding="UTF-8"?><sld:StyledLayerDescriptor xmlns="http://www.opengis.net/sld" xmlns:sld="http://www.opengis.net/sld" xmlns:gml="http://www.opengis.net/gml" xmlns:ogc="http://www.opengis.net/ogc" version="1.0.0">
    <sld:UserLayer>
        <sld:LayerFeatureConstraints>
            <sld:FeatureTypeConstraint/>
        </sld:LayerFeatureConstraints>
        <sld:UserStyle>
            <sld:Name>Default Styler</sld:Name>
            <sld:FeatureTypeStyle>
                <sld:Name>group0</sld:Name>
                <sld:FeatureTypeName>Feature</sld:FeatureTypeName>
                <sld:Rule>
                    <sld:Name>default rule</sld:Name>
                    <sld:PolygonSymbolizer>
                        <sld:Geometry>
                            <ogc:Function name="isometric">
                                <ogc:PropertyName>the_geom</ogc:PropertyName>
                                <ogc:Literal>10</ogc:Literal>
                            </ogc:Function>
                        </sld:Geometry>
                        <sld:Fill>
                            <sld:CssParameter name="fill">#999797</sld:CssParameter>
                            <sld:CssParameter name="fill-opacity">0.61</sld:CssParameter>
                        </sld:Fill>
                    </sld:PolygonSymbolizer>
                    <sld:PolygonSymbolizer>
                        <sld:Geometry>
                            <ogc:Function name="offset">
                                <ogc:PropertyName>the_geom</ogc:PropertyName>
                                <ogc:Literal>0</ogc:Literal>
                                <ogc:Literal>10</ogc:Literal>
                            </ogc:Function>
                        </sld:Geometry>
                        <sld:Fill>
                            <sld:CssParameter name="fill">#D5CECE</sld:CssParameter>
                        </sld:Fill>
                    </sld:PolygonSymbolizer>
                </sld:Rule>
            </sld:FeatureTypeStyle>
        </sld:UserStyle>
    </sld:UserLayer>
</sld:StyledLayerDescriptor>

因为在用geoserver发布的时候无法直接看到效果,因此我们可直接在UDig中导入相关的地理要素比如shp文件等,进行sld的编辑和查看效果,将符合要求的sld导出即可。具体如何用geoserver发布相关服务,网上例子很多

上效果图:

示例效果图

 

转载自:https://blog.csdn.net/qq_26991807/article/details/81087016

You may also like...