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>

效果如下:


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM