2013-05-02 66 views
2

我正在为Geoserver wms图层创建SLD。 SLD验证没有错误,但图标不会显示在地图中。我正在使用基于属性的规则来比较字符串,以便正确显示正确的图像以显示正确的功能。这里是我的代码,并感谢您的帮助!Geoserver SLD样式问题与外部图形和属性规则

<?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"> 
<NamedLayer> 
<Name>Upper Shore Image Points</Name> 
<UserStyle> 
    <Title>Vendor Points</Title> 
    <FeatureTypeStyle> 
    <Rule> 
    <Name>Famers Market</Name> 
    <Title>All Farmers Markets</Title> 
     <ogc:Filter> 
     <ogc:PropertyIsLike wildCard="*" singleChar="." escape="!"> 
      <ogc:PropertyName>type</ogc:PropertyName> 
      <ogc:Literal>farmers maket vendor</ogc:Literal> 
     </ogc:PropertyIsLike> 
     </ogc:Filter> 
     <PointSymbolizer> 
     <Graphic> 
      <ExternalGraphic> 
      <OnlineResource 
       xlink:type="simple" 
       xlink:href="Farmers Markets.jpg" /> 
      <Format>image/jpeg</Format> 
      </ExternalGraphic> 
      <Size>32</Size> 
     </Graphic> 
     </PointSymbolizer> 
    </Rule> 
    <Rule> 
    <Name>Fruit and Vegetable</Name> 
    <Title>All Fruit and Vegetable</Title> 
     <ogc:Filter> 
     <ogc:PropertyIsLike wildCard="*" singleChar="." escape="!"> 
      <ogc:PropertyName>type</ogc:PropertyName> 
      <ogc:Literal>Fruit and Vegetable Farm</ogc:Literal> 
     </ogc:PropertyIsLike> 
     </ogc:Filter> 
     <PointSymbolizer> 
     <Graphic> 
      <ExternalGraphic> 
      <OnlineResource 
       xlink:type="simple" 
       xlink:href="Fruit and Vegetable Farms.jpg" /> 
      <Format>image/jpeg</Format> 
      </ExternalGraphic> 
      <Size>32</Size> 
     </Graphic> 
     </PointSymbolizer> 
    </Rule> 
<Rule> 
    <Name>Horse Stable</Name> 
    <Title>All Horse Stables</Title> 
     <ogc:Filter> 
     <ogc:PropertyIsLike wildCard="*" singleChar="." escape="!"> 
      <ogc:PropertyName>type</ogc:PropertyName> 
      <ogc:Literal>Horse Stable</ogc:Literal> 
     </ogc:PropertyIsLike> 
     </ogc:Filter> 
     <PointSymbolizer> 
     <Graphic> 
      <ExternalGraphic> 
      <OnlineResource 
       xlink:type="simple" 
       xlink:href="Horse Stable.jpg" /> 
      <Format>image/jpeg</Format> 
      </ExternalGraphic> 
      <Size>32</Size> 
     </Graphic> 
     </PointSymbolizer> 
    </Rule> 
    <Rule> 
    <Name>Wool Products</Name> 
    <Title>All Wool Products</Title> 
     <ogc:Filter> 
     <ogc:PropertyIsLike wildCard="*" singleChar="." escape="!"> 
      <ogc:PropertyName>type</ogc:PropertyName> 
      <ogc:Literal>Wool Products</ogc:Literal> 
     </ogc:PropertyIsLike> 
     </ogc:Filter> 
     <PointSymbolizer> 
     <Graphic> 
      <ExternalGraphic> 
      <OnlineResource 
       xlink:type="simple" 
       xlink:href="Wool Products.jpg" /> 
      <Format>image/jpeg</Format> 
      </ExternalGraphic> 
      <Size>32</Size> 
     </Graphic> 
     </PointSymbolizer> 
    </Rule> 
    <Rule> 
    <Name>Restaurant</Name> 
    <Title>All Restaurants</Title> 
     <ogc:Filter> 
     <ogc:PropertyIsLike wildCard="*" singleChar="." escape="!"> 
      <ogc:PropertyName>type</ogc:PropertyName> 
      <ogc:Literal>Restaurant</ogc:Literal> 
     </ogc:PropertyIsLike> 
     </ogc:Filter> 
     <PointSymbolizer> 
     <Graphic> 
      <ExternalGraphic> 
      <OnlineResource 
       xlink:type="simple" 
       xlink:href="Restaurant.jpg" /> 
      <Format>image/jpeg</Format> 
      </ExternalGraphic> 
      <Size>32</Size> 
     </Graphic> 
     </PointSymbolizer> 
    </Rule> 
    <Rule> 
    <Name>Coffee Roasting</Name> 
    <Title>All Coffee Roasting</Title> 
     <ogc:Filter> 
     <ogc:PropertyIsLike wildCard="*" singleChar="." escape="!"> 
      <ogc:PropertyName>type</ogc:PropertyName> 
      <ogc:Literal>Coffee Roasting</ogc:Literal> 
     </ogc:PropertyIsLike> 
     </ogc:Filter> 
     <PointSymbolizer> 
     <Graphic> 
      <ExternalGraphic> 
      <OnlineResource 
       xlink:type="simple" 
       xlink:href="Coffee Roasting.jpg" /> 
      <Format>image/jpeg</Format> 
      </ExternalGraphic> 
      <Size>32</Size> 
     </Graphic> 
     </PointSymbolizer> 
    </Rule> 
    <Rule> 
    <Name>Charter Service</Name> 
    <Title>All Charter Services</Title> 
     <ogc:Filter> 
     <ogc:PropertyIsLike wildCard="*" singleChar="." escape="!"> 
      <ogc:PropertyName>type</ogc:PropertyName> 
      <ogc:Literal>Charter Service</ogc:Literal> 
     </ogc:PropertyIsLike> 
     </ogc:Filter> 
     <PointSymbolizer> 
     <Graphic> 
      <ExternalGraphic> 
      <OnlineResource 
       xlink:type="simple" 
       xlink:href="Charter Service.jpg" /> 
      <Format>image/jpeg</Format> 
      </ExternalGraphic> 
      <Size>32</Size> 
     </Graphic> 
     </PointSymbolizer> 
    </Rule> 
    <Rule> 
    <Name>Apiary</Name> 
    <Title>All Apiaries</Title> 
     <ogc:Filter> 
     <ogc:PropertyIsLike wildCard="*" singleChar="." escape="!"> 
      <ogc:PropertyName>type</ogc:PropertyName> 
      <ogc:Literal>Apiary</ogc:Literal> 
     </ogc:PropertyIsLike> 
     </ogc:Filter> 
     <PointSymbolizer> 
     <Graphic> 
      <ExternalGraphic> 
      <OnlineResource 
       xlink:type="simple" 
       xlink:href="Apiary.jpg" /> 
      <Format>image/jpeg</Format> 
      </ExternalGraphic> 
      <Size>32</Size> 
     </Graphic> 
     </PointSymbolizer> 
    </Rule> 
    <Rule> 
    <Name>Vineyard</Name> 
    <Title>All Vineyards</Title> 
     <ogc:Filter> 
     <ogc:PropertyIsLike wildCard="*" singleChar="." escape="!"> 
      <ogc:PropertyName>type</ogc:PropertyName> 
      <ogc:Literal>Vineyard</ogc:Literal> 
     </ogc:PropertyIsLike> 
     </ogc:Filter> 
     <PointSymbolizer> 
     <Graphic> 
      <ExternalGraphic> 
      <OnlineResource 
       xlink:type="simple" 
       xlink:href="Vineyard.jpg" /> 
      <Format>image/jpeg</Format> 
      </ExternalGraphic> 
      <Size>32</Size> 
     </Graphic> 
     </PointSymbolizer> 
    </Rule> 
    <Rule> 
    <Name>Retail Seafood</Name> 
    <Title>All Retail Seafood</Title> 
     <ogc:Filter> 
     <ogc:PropertyIsLike wildCard="*" singleChar="." escape="!"> 
      <ogc:PropertyName>type</ogc:PropertyName> 
      <ogc:Literal>Retail Seafood</ogc:Literal> 
     </ogc:PropertyIsLike> 
     </ogc:Filter> 
     <PointSymbolizer> 
     <Graphic> 
      <ExternalGraphic> 
      <OnlineResource 
       xlink:type="simple" 
       xlink:href="Retail Seafood.jpg" /> 
      <Format>image/jpeg</Format> 
      </ExternalGraphic> 
      <Size>32</Size> 
     </Graphic> 
     </PointSymbolizer> 
    </Rule> 
    <Rule> 
    <Name>Bakery</Name> 
    <Title>All Bakeries</Title> 
     <ogc:Filter> 
     <ogc:PropertyIsLike wildCard="*" singleChar="." escape="!"> 
      <ogc:PropertyName>type</ogc:PropertyName> 
      <ogc:Literal>Bakery</ogc:Literal> 
     </ogc:PropertyIsLike> 
     </ogc:Filter> 
     <PointSymbolizer> 
     <Graphic> 
      <ExternalGraphic> 
      <OnlineResource 
       xlink:type="simple" 
       xlink:href="Bakery.jpg" /> 
      <Format>image/jpeg</Format> 
      </ExternalGraphic> 
      <Size>32</Size> 
     </Graphic> 
     </PointSymbolizer> 
    </Rule> 
    <Rule> 
     <Name>Dairy/Eggs</Name> 
     <Title>All Dairy/ Eggs</Title> 
     <ogc:Filter> 
     <ogc:PropertyIsLike wildCard="*" singleChar="." escape="!"> 
      <ogc:PropertyName>type</ogc:PropertyName> 
      <ogc:Literal>Dairy/Eggs</ogc:Literal> 
     </ogc:PropertyIsLike> 
     </ogc:Filter> 
     <PointSymbolizer> 
     <Graphic> 
      <ExternalGraphic> 
      <OnlineResource 
       xlink:type="simple" 
       xlink:href="Dairy_Eggs.jpg" /> 
      <Format>image/jpeg</Format> 
      </ExternalGraphic> 
      <Size>32</Size> 
     </Graphic> 
     </PointSymbolizer> 
    </Rule> 
    <Rule> 
    <Name>Christmas Tree Farm</Name> 
    <Title>All Christmas Tree Farms</Title> 
     <ogc:Filter> 
     <ogc:PropertyIsLike wildCard="*" singleChar="." escape="!"> 
      <ogc:PropertyName>type</ogc:PropertyName> 
      <ogc:Literal>Christmas Tree Farm</ogc:Literal> 
     </ogc:PropertyIsLike> 
     </ogc:Filter> 
     <PointSymbolizer> 
     <Graphic> 
      <ExternalGraphic> 
      <OnlineResource 
       xlink:type="simple" 
       xlink:href="Christmas Tree Farm.jpg" /> 
      <Format>image/jpeg</Format> 
      </ExternalGraphic> 
      <Size>32</Size> 
     </Graphic> 
     </PointSymbolizer> 
    </Rule> 
    <Rule> 
     <Name>Grains</Name> 
     <Title>All Grain Farms</Title> 
     <ogc:Filter> 
     <ogc:PropertyIsLike wildCard="*" singleChar="." escape="!"> 
      <ogc:PropertyName>type</ogc:PropertyName> 
      <ogc:Literal>Grains</ogc:Literal> 
     </ogc:PropertyIsLike> 
     </ogc:Filter> 
     <PointSymbolizer> 
     <Graphic> 
      <ExternalGraphic> 
      <OnlineResource 
       xlink:type="simple" 
       xlink:href="Grains.jpg" /> 
      <Format>image/jpeg</Format> 
      </ExternalGraphic> 
      <Size>32</Size> 
     </Graphic> 
     </PointSymbolizer> 
    </Rule> 
    <Rule> 
    <Name>Meat Products</Name> 
    <Title>All Meat Products</Title> 
     <ogc:Filter> 
     <ogc:PropertyIsLike wildCard="*" singleChar="." escape="!"> 
      <ogc:PropertyName>type</ogc:PropertyName> 
      <ogc:Literal>Meat Products</ogc:Literal> 
     </ogc:PropertyIsLike> 
     </ogc:Filter> 
     <PointSymbolizer> 
     <Graphic> 
      <ExternalGraphic> 
      <OnlineResource 
       xlink:type="simple" 
       xlink:href="Meat.jpg" /> 
      <Format>image/jpeg</Format> 
      </ExternalGraphic> 
      <Size>32</Size> 
     </Graphic> 
     </PointSymbolizer> 
    </Rule> 
    <Rule> 
    <Name>Nursery</Name> 
    <Title>All Nurseries</Title> 
     <ogc:Filter> 
     <ogc:PropertyIsLike wildCard="*" singleChar="." escape="!"> 
      <ogc:PropertyName>type</ogc:PropertyName> 
      <ogc:Literal>Nursery</ogc:Literal> 
     </ogc:PropertyIsLike> 
     </ogc:Filter> 
     <PointSymbolizer> 
     <Graphic> 
      <ExternalGraphic> 
      <OnlineResource 
       xlink:type="simple" 
       xlink:href="Nursery.jpg" /> 
      <Format>image/jpeg</Format> 
      </ExternalGraphic> 
      <Size>32</Size> 
     </Graphic> 
     </PointSymbolizer> 
    </Rule> 
    <Rule> 
    <Name>Petting Zoo</Name> 
    <Title>All Petting Zoos</Title> 
     <ogc:Filter> 
     <ogc:PropertyIsLike wildCard="*" singleChar="." escape="!"> 
      <ogc:PropertyName>type</ogc:PropertyName> 
      <ogc:Literal>Petting Zoo</ogc:Literal> 
     </ogc:PropertyIsLike> 
     </ogc:Filter> 
     <PointSymbolizer> 
     <Graphic> 
      <ExternalGraphic> 
      <OnlineResource 
       xlink:type="simple" 
       xlink:href="Petting Zoo.jpg" /> 
      <Format>image/jpeg</Format> 
      </ExternalGraphic> 
      <Size>32</Size> 
     </Graphic> 
     </PointSymbolizer> 
    </Rule> 
    </FeatureTypeStyle> 
</UserStyle> 

回答

6

我知道这个职位是旧的,但也许有人会从我的回答中受益。

我没有成功地使用相对图像路径,所以我转向使用URL路径。在$ GEOSERVER_DATA_DIR /风格

认沽图像(S),并与http://localhost:8081/geoserver/styles/some_image.png

引用它例如

<ExternalGraphic> 
    <OnlineResource xlink:type="simple" xlink:href="http://localhost:8081/geoserver/styles/some_image.png"/> 
    <Format>image/png</Format> 
</ExternalGraphic> 
+0

谢谢你,这与网址的工作路径:) – 2015-11-15 18:56:36

+0

非常感谢。我无法以任何其他方式访问图像。 – 2016-07-05 18:18:16

0

你可以把你的形象风格的文件夹