1. 程式人生 > >GeoServer中使用SLD表現偽3D建築

GeoServer中使用SLD表現偽3D建築

看到一篇博文,通過SLD來完成3D效果的,記得在OSM的站點上看到過這樣的配置,還是值得一看的。轉自:http://xml.iteye.com/blog/1666190

Pseudo-3D or 2.5D or 3/4 perspective can be done in Geoserver using isometric function. 

Xml程式碼  收藏程式碼
  1. <FeatureTypeStyle>  
  2.   <Rule>  
  3.     <PolygonSymbolizer>  
  4.       <Geometry>  
  5.         <ogc:Function
     name="isometric">  
  6.           <ogc:PropertyName>geom</ogc:PropertyName>  
  7.           <ogc:Literal>7</ogc:Literal>  
  8.         </ogc:Function>  
  9.       </Geometry>  
  10.       <Fill>  
  11.         <CssParameter name="fill">#dddddd</CssParameter>  
  12.       </Fill
    >  
  13.       <Stroke>  
  14.         <CssParameter name="stroke">#999999</CssParameter>  
  15.       </Stroke>  
  16.     </PolygonSymbolizer>  
  17.   </Rule>  
  18. </FeatureTypeStyle>  
房頂的樣式 Xml程式碼  收藏程式碼
  1. <FeatureTypeStyle>  
  2.   <Rule>  
  3.     <PolygonSymbolizer>  
  4.       <
    Geometry>  
  5.          <ogc:Function name="offset">  
  6.             <ogc:PropertyName>geom</ogc:PropertyName>  
  7.             <ogc:Literal>0</ogc:Literal>  
  8.             <ogc:Literal>7</ogc:Literal>  
  9.          </ogc:Function>  
  10.       </Geometry>  
  11.       <Fill>  
  12.         <CssParameter name="fill">#FFDCC7</CssParameter>  
  13.       </Fill>  
  14.       <Stroke>  
  15.         <CssParameter name="stroke">#999999</CssParameter>  
  16.       </Stroke>  
  17.     </PolygonSymbolizer>  
  18.   </Rule>  
  19. </FeatureTypeStyle>  
完整的例子 Xml程式碼  收藏程式碼
  1. <?xml version="1.0" encoding="ISO-8859-1"?>  
  2. <StyledLayerDescriptor version="1.0.0"   
  3.     xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd"   
  4.     xmlns="http://www.opengis.net/sld"   
  5.     xmlns:ogc="http://www.opengis.net/ogc"   
  6.     xmlns:xlink="http://www.w3.org/1999/xlink"   
  7.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">  
  8.     <!-- a Named Layer is the basic building block of an SLD document -->  
  9.     <NamedLayer>  
  10.         <Name>default_polygon</Name>  
  11.         <UserStyle>  
  12.             <!-- Styles can have names, titles and abstracts -->  
  13.             <Title>Default Polygon</Title>  
  14.             <Abstract>A sample style that draws a polygon</Abstract>  
  15.             <!-- FeatureTypeStyles describe how to render different features -->  
  16.             <!-- A FeatureTypeStyle for rendering polygons -->  
  17.             <FeatureTypeStyle>  
  18.                 <Rule>  
  19.                     <PolygonSymbolizer>  
  20.                         <Geometry>  
  21.                             <ogc:Function name="isometric">  
  22.                                 <ogc:PropertyName>the_geom</ogc:PropertyName>  
  23.                                 <ogc:Literal>5</ogc:Literal>  
  24.                             </ogc:Function>  
  25.                         </Geometry>  
  26.                         <Fill>  
  27.                             <CssParameter name="fill">#dddddd</CssParameter>  
  28.                         </Fill>  
  29.                         <Stroke>  
  30.                             <CssParameter name="stroke">#999999</CssParameter>  
  31.                             <CssParameter name="stroke-width">0.1</CssParameter>  
  32.                         </Stroke>  
  33.                     </PolygonSymbolizer>  
  34.                 </Rule>  
  35.             </FeatureTypeStyle>  
  36.             <FeatureTypeStyle>  
  37.                 <Rule>  
  38.                     <PolygonSymbolizer>  
  39.                         <Geometry>  
  40.                             <ogc:Function name="offset">  
  41.                                 <ogc:PropertyName>the_geom</ogc:PropertyName>  
  42.                                 <ogc:Literal>0</ogc:Literal>  
  43.                                 <ogc:Literal>5</ogc:Literal>  
  44.                             </ogc:Function>  
  45.                         </Geometry>  
  46.                         <Fill>  
  47.                             <CssParameter name="fill">#cccccc</CssParameter>  
  48.                         </Fill>  
  49.                         <Stroke>  
  50.                             <CssParameter name="stroke">#999999</CssParameter>  
  51.                             <CssParameter name="stroke-width">0.1</CssParameter>  
  52.                         </Stroke>  
  53.                     </PolygonSymbolizer>  
  54.                 </Rule>  
  55.             </FeatureTypeStyle>  
  56.         </UserStyle>  
  57.     </NamedLayer>  
  58. </StyledLayerDescriptor>