Geoserver SLD风格 - 带盾牌的标签线

时间:2016-12-21 02:38:34

标签: geoserver sld

我是Geoserver的新手(Tomcat 9中的Geoserver 2.10.0 + Win 10 Pro x64上的Apache 2.14)  并且有一段时间试图将道路标签设计为高速公路的盾牌,主要的高速公路......

检查了Geoserver培训/ sld-references / cookbook但无法找到任何现实生活中的#34;完整代码的示例。

使用QGIS 2.18.1制作和导出线条样式的SLD,但由于不支持标签,因此使用OSGB SLD作为源代码:

https://github.com/OrdnanceSurvey/Strategi-stylesheets/blob/master/ESRI%20Shapefile%20stylesheets/GeoServer%20stylesheets%20(SLD)/Full%20Colour%20style/motorway.sld#L348

将有关标签屏蔽的代码的 TextSymbolizer ... / TextSymbolizer 部分复制/粘贴到Geoserver sld文件中 -

还使用se:,ogc:,se:SvgParameter 编辑原始代码)          

  <se:FeatureTypeStyle>
    <se:Rule>
      <se:Name>MARKED_TR labels</se:Name>
      <se:Description>
        <se:Title>MARKED_TR</se:Title>
      </se:Description>
      <ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
        <ogc:PropertyIsEqualTo>
          <ogc:PropertyName>GRMN_TYPE</ogc:PropertyName>
          <ogc:Literal>MARKED_TR</ogc:Literal>
        </ogc:PropertyIsEqualTo>
      </ogc:Filter>
      <se:MaxScaleDenominator>250000</se:MaxScaleDenominator>
     <se:TextSymbolizer>
       <se:Label>
         <ogc:PropertyName>NAME_UTF</ogc:PropertyName>
       </se:Label>
       <se:Font>
         <se:SvgParameter name="font-family">Arial</se:SvgParameter>
         <se:SvgParameter name="font-size">9</se:SvgParameter>
         <se:SvgParameter name="font-weight">bold</se:SvgParameter>
       </se:Font>
        <se:LabelPlacement>
          <se:PointPlacement>
            <se:AnchorPoint>
              <se:AnchorPointX>0.5</se:AnchorPointX>
              <se:AnchorPointY>0.5</se:AnchorPointY>
            </se:AnchorPoint>
            <se:Displacement>
              <se:DisplacementX>0</se:DisplacementX>
              <se:DisplacementY>0</se:DisplacementY>
            </se:Displacement>
          </se:PointPlacement>
        </se:LabelPlacement>
       <se:Fill>
         <se:SvgParameter name="fill">#FFFFFF</se:SvgParameter>
       </se:Fill>
       **<se:Graphic>**
         <se:Mark>
           <se:WellKnownName>square</se:WellKnownName>
           <se:Fill>
             <se:SvgParameter name="fill">#009FB8</se:SvgParameter>
           </se:Fill>
         </se:Mark>
         <se:Size>6</se:Size>
       </se:Graphic>
       <se:Priority>450</se:Priority>
       <se:VendorOption name="graphic-resize">stretch</se:VendorOption>
       <se:VendorOption name="graphic-margin">2.3</se:VendorOption>
       <se:VendorOption name="maxDisplacement">200</se:VendorOption>
       <se:VendorOption name="repeat">500</se:VendorOption>       
       <se:VendorOption name="spaceAround">10</se:VendorOption>
       <se:VendorOption name="group">yes</se:VendorOption>  
     </se:TextSymbolizer>          
   </se:Rule>
  </se:FeatureTypeStyle>

不幸的是,Geoserver Validation会返回错误,如屏幕截图所示:

Geoserver screenshot

2 个答案:

答案 0 :(得分:0)

您的代码无法验证,因为它是SLD标准架构的扩展。如果按submit并查看地图,您会看到它正常工作。

答案 1 :(得分:0)

Screenshot with "invisible" shield

到目前为止,似乎是部分语法 图形 - /图形不正确?!