---
title: "GeoServer中使用SLD表现伪3D建筑"
author: "cjx186"
date: "2012-08-29T00:28:39Z"
tags: []
categories: ["开源软件"]
slug: "geoserver-sld-3d"
draft: false
lastmod: "2012-08-29T01:00:01Z"
id: 1666190
url: "https://xml.iteye.com/blog/1666190"
---

[原文链接：pseudo-3D buildings in Geoserver](http://mapping-malaysia.blogspot.com/2010/07/pseudo-3d-buildings-in-geoserver.html)
<span style="color:green">Pseudo-3D or 2.5D or 3/4 perspective can be done in Geoserver using isometric function. </span>
![](http://dl.iteye.com/upload/attachment/0073/0073/00ad3652-4d8c-3624-bdf0-933d6f8519c7.png)

```xml
<FeatureTypeStyle>
  <Rule>
    <PolygonSymbolizer>
      <Geometry>
        <ogc:Function name="isometric">
          <ogc:PropertyName>geom</ogc:PropertyName>
          <ogc:Literal>7</ogc:Literal>
        </ogc:Function>
      </Geometry>
      <Fill>
        <CssParameter name="fill">#dddddd</CssParameter>
      </Fill>
      <Stroke>
        <CssParameter name="stroke">#999999</CssParameter>
      </Stroke>
    </PolygonSymbolizer>
  </Rule>
</FeatureTypeStyle>

```
<span style="color:green">房顶的样式</span>
```xml

<FeatureTypeStyle>
  <Rule>
    <PolygonSymbolizer>
      <Geometry>
         <ogc:Function name="offset">
            <ogc:PropertyName>geom</ogc:PropertyName>
            <ogc:Literal>0</ogc:Literal>
            <ogc:Literal>7</ogc:Literal>
         </ogc:Function>
      </Geometry>
      <Fill>
        <CssParameter name="fill">#FFDCC7</CssParameter>
      </Fill>
      <Stroke>
        <CssParameter name="stroke">#999999</CssParameter>
      </Stroke>
    </PolygonSymbolizer>
  </Rule>
</FeatureTypeStyle>

```
<span style="color:green">完整的例子</span>
```xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<StyledLayerDescriptor version="1.0.0" 
    xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd" 
    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">
    <!-- a Named Layer is the basic building block of an SLD document -->
    <NamedLayer>
        <Name>default_polygon</Name>
        <UserStyle>
            <!-- Styles can have names, titles and abstracts -->
            <Title>Default Polygon</Title>
            <Abstract>A sample style that draws a polygon</Abstract>
            <!-- FeatureTypeStyles describe how to render different features -->
            <!-- A FeatureTypeStyle for rendering polygons -->
            <FeatureTypeStyle>
                <Rule>
                    <PolygonSymbolizer>
                        <Geometry>
                            <ogc:Function name="isometric">
                                <ogc:PropertyName>the_geom</ogc:PropertyName>
                                <ogc:Literal>5</ogc:Literal>
                            </ogc:Function>
                        </Geometry>
                        <Fill>
                            <CssParameter name="fill">#dddddd</CssParameter>
                        </Fill>
                        <Stroke>
                            <CssParameter name="stroke">#999999</CssParameter>
                            <CssParameter name="stroke-width">0.1</CssParameter>
                        </Stroke>
                    </PolygonSymbolizer>
                </Rule>
            </FeatureTypeStyle>
            <FeatureTypeStyle>
                <Rule>
                    <PolygonSymbolizer>
                        <Geometry>
                            <ogc:Function name="offset">
                                <ogc:PropertyName>the_geom</ogc:PropertyName>
                                <ogc:Literal>0</ogc:Literal>
                                <ogc:Literal>5</ogc:Literal>
                            </ogc:Function>
                        </Geometry>
                        <Fill>
                            <CssParameter name="fill">#cccccc</CssParameter>
                        </Fill>
                        <Stroke>
                            <CssParameter name="stroke">#999999</CssParameter>
                            <CssParameter name="stroke-width">0.1</CssParameter>
                        </Stroke>
                    </PolygonSymbolizer>
                </Rule>
            </FeatureTypeStyle>
        </UserStyle>
    </NamedLayer>
</StyledLayerDescriptor>

```