0

I am currently doing a master's internship in a town hall. I am working on improving the interactive map of the municipality where I work; it uses the Geoserver platform to host the layers and their style, and uses the mviewer package for online publishing. Since a few days, I encounter a number of difficulties on the map. I'm still starting on geoserver and interactive mapping in general.

The first issue is the following: I made sure for a given layer that the symbology adapts to the map according to a range of scales. For example, for a scale between 10000 and 50000 (using min and maxscaledenominator), the symbol has a size of 50m on map. So I used the "rule" property for each condition. But, the problem is that my icons have been published several times in the graphic legend; basically, the same symbol appears several times for a different size, related to each which gives a different size for each scale. So I would like to know if there is a way to have only one symbol represented instead of all. Here is the problem in picture : enter image description here And this is the code of the layer's style :

     <?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>Canisite</Name>
      <UserStyle>
      <Title>Canisite</Title>
      <FeatureTypeStyle>
      <Rule>
      <MaxScaleDenominator>5000</MaxScaleDenominator>
      <MinScaleDenominator>100</MinScaleDenominator>
      <PointSymbolizer uom="http://www.opengeospatial.org/se/units/metre">
        <Graphic>
          <ExternalGraphic>
            <OnlineResource
              xlink:type="simple"
              xlink:href="https://extranet.ville-houilles.fr/mviewer/png_test/dogd.png" />
            <Format>image/png</Format>
          </ExternalGraphic>
          <Size>30</Size>
          </Graphic>
          </PointSymbolizer>
          </Rule>

          <Rule>
              <MaxScaleDenominator>10000</MaxScaleDenominator>
              <MinScaleDenominator>5000</MinScaleDenominator>
              <PointSymbolizer uom="http://www.opengeospatial.org/se/units/metre">
               <Graphic>
                <ExternalGraphic>
                 <OnlineResource
              xlink:type="simple"
              xlink:href="https://extranet.ville-houilles.fr/mviewer/png_test/dogd.png" />
                 <Format>image/png</Format>
                </ExternalGraphic>
                <Size>70</Size>
               </Graphic>
              </PointSymbolizer>
              </Rule>        

             <Rule>
             <MaxScaleDenominator>20000</MaxScaleDenominator>
             <MinScaleDenominator>10000</MinScaleDenominator>
              <PointSymbolizer uom="http://www.opengeospatial.org/se/units/metre">
                <Graphic>
                 <ExternalGraphic>
                   <OnlineResource
              xlink:type="simple"
              xlink:href="https://extranet.ville-houilles.fr/mviewer/png_test/dogd.png" />
                   <Format>image/png</Format>
                  </ExternalGraphic>
                  <Size>150</Size>
                 </Graphic>
                </PointSymbolizer>
               </Rule>     

               <Rule>
               <MaxScaleDenominator>150000</MaxScaleDenominator>
                <MinScaleDenominator>20000</MinScaleDenominator>
                <PointSymbolizer uom="http://www.opengeospatial.org/se/units/metre">
                  <Graphic>
                   <ExternalGraphic>
                    <OnlineResource
              xlink:type="simple"
              xlink:href="https://extranet.ville-houilles.fr/mviewer/png_test/dogd.png" />
                     <Format>image/png</Format>
                   </ExternalGraphic>
                   <Size>220</Size>
                  </Graphic>
                 </PointSymbolizer>
                </Rule>
              </FeatureTypeStyle>
              </UserStyle>
              </NamedLayer>
              </StyledLayerDescriptor>

Apparently, you can use a parameter called GetlegendGraphic, but I don't understand how it works, nor how to insert the links generated in the code. Another problem concerns the superposition of the layers: is there a solution so that, necessarily, the point layers are displayed over the linear and surface layers? Because these first are found hidden by these last ones when a user interacts and selects first a point, then a surface or line ... I tried the option of a group layer and sorted all the layers out, which gave me a good result in previsualization in "openlayers" in Geoserver, but they seems to be no way to publish as the official map, the group layer I created...

I'm aware that it's a lot of problems like that, a bit poorly formulated ^^, and I'm waiting for your answers, my level on geoserver just needs to improve! If needed, I can also give you the html and xml codes used for mviewer linked to the map.

  • please don't include screenshots of code or xml, it is almost impossible to read (especially for users on mobile devices). – Ian Turton Feb 8 at 8:59
  • Edited (sorry I didn't get how to insert code lines in a message) – fefe78 Feb 8 at 9:12
  • Thank you very much for your contribution @IanTurton ; I saw this question a few days ago (I knew my problem had already been asked); but I don't understand how to get links by using GetlegendGraphic, I understand the parameters in the link and what has to be added, but I don't understand how to get the link, nor where to insert it in a code... – fefe78 Feb 8 at 9:27
  • then please edit your question to focus on the part that you need help on, referring to the other question if need be – Ian Turton Feb 8 at 9:50
  • Done, I hope it is more precise for you – fefe78 Feb 8 at 10:08
1

A GetLegendGraphic without any context will render all available rules. You can pass the "SCALE" parameter to only render rules active at a given scale denominator. See documentation here: https://docs.geoserver.org/latest/en/user/services/wms/get_legend_graphic/index.html#getlegendgraphic

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.