zoukankan      html  css  js  c++  java
  • SLD 样式 之GeoServer中设计2.5维建筑物

    昨天GIS群里谈论到在GeoServer中创建google 、百度地图中的伪三维建筑物如:

    几番搜索,geoserver中用SLD的isometric可以实现这种效果:

    isometric geometry:Geometry,extrusion:Double Returns a multi-polygon containing the isometric extrusions of all segments part of the original geometry. The extrusion distance is extrusionand it’s assume to be expressed in the same unit as the geometry coordinates. Can be used to get a cheap pseudo-3d map effect

    具体的SLD文件为如下

    <?xml version="1.0" encoding="UTF-8"?>
    <StyledLayerDescriptor version="1.0.0"
      xmlns="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc"
      xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.0.0/StyledLayerDescriptor.xsd">
      <NamedLayer>
        <Name>alt-buildings</Name>
        <UserStyle>
          <FeatureTypeStyle>
            <Rule>
              <PolygonSymbolizer>
                <Geometry>
                  <ogc:Function name="isometric">
                    <ogc:PropertyName>geom</ogc:PropertyName>
                    <ogc:Literal>0.0001</ogc:Literal>
                  </ogc:Function>
                </Geometry>
                <Fill>
                  <CssParameter name="fill">#7B8F96</CssParameter>
                  <CssParameter name="fill-opacity">1</CssParameter>
                </Fill>
              </PolygonSymbolizer>
              <PolygonSymbolizer>
                <Geometry>
                  <ogc:Function name="offset">
                    <ogc:PropertyName>geom</ogc:PropertyName>
                    <ogc:Literal>0</ogc:Literal>
                    <ogc:Literal>0.0001</ogc:Literal>
                  </ogc:Function>
                </Geometry>
                <Fill>
                  <CssParameter name="fill">#BAD8E2</CssParameter>
                  <CssParameter name="fill-opacity">1</CssParameter>
                </Fill>
              </PolygonSymbolizer>
             </Rule>
          </FeatureTypeStyle>
          </UserStyle>
      </NamedLayer>
    </StyledLayerDescriptor>

    效果:

    这种情况下所有的建筑物的高度都是一样的 如果要实现高度不等具体操作如下:

    首先我的数据是从OpenStreetMap下载的并存到了PostGis数据库

    然后添加一个height字段默认值都为0.0001 并把上图最中间的那个半圆形建筑物的height改为0.0002

    然后修改sld文件把

    <ogc:Literal>0.0001</ogc:Literal>替换为<ogc:PropertyName>height</ogc:PropertyName>
    <?xml version="1.0" encoding="UTF-8"?>
    <StyledLayerDescriptor version="1.0.0"
      xmlns="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc"
      xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.0.0/StyledLayerDescriptor.xsd">
      <NamedLayer>
        <Name>alt-buildings</Name>
        <UserStyle>
          <FeatureTypeStyle>
            <Rule>
              <PolygonSymbolizer>
                <Geometry>
                  <ogc:Function name="isometric">
                    <ogc:PropertyName>geom</ogc:PropertyName>
                    <ogc:PropertyName>height</ogc:PropertyName>
                  </ogc:Function>
                </Geometry>
                <Fill>
                  <CssParameter name="fill">#7B8F96</CssParameter>
                  <CssParameter name="fill-opacity">1</CssParameter>
                </Fill>
                
              </PolygonSymbolizer>
              <PolygonSymbolizer>
                <Geometry>
                  <ogc:Function name="offset">
                    <ogc:PropertyName>geom</ogc:PropertyName>
                    <ogc:Literal>0</ogc:Literal>
                   <ogc:PropertyName>height</ogc:PropertyName>
                  </ogc:Function>
                </Geometry>
                <Fill>
                  <CssParameter name="fill">#BAD8E2</CssParameter>
                  <CssParameter name="fill-opacity">1</CssParameter>
                </Fill>
            
              </PolygonSymbolizer>
             </Rule>
          </FeatureTypeStyle>
          </UserStyle>
      </NamedLayer>
    </StyledLayerDescriptor>

    效果如下:

  • 相关阅读:
    验证email的正则表达式
    时间管理的小技巧
    如何在项目中进行畅快的沟通
    为什么你总成为不了架构师?
    我的时间管理Color My Time
    《重来》值得你多看几遍
    程序员如何成为一位出色的项目经理?
    大学毕业后拉开差距的真正原因
    [精华] FreeBSD-FAQ集锦(一)
    awk 常用信息
  • 原文地址:https://www.cnblogs.com/shitao/p/2661611.html
Copyright © 2011-2022 走看看