planetfederal / qgis-suite-plugin

GNU General Public License v2.0
25 stars 17 forks source link

Negative numbers as class bounds can not be published properly to GeoServer #185

Closed kitzilla closed 8 years ago

kitzilla commented 9 years ago

In QGIS 2.8.2, if I use negative number as class bound for graduated layer styling, the filter part in the SLD spit by QGIS looks like this. You will see that there is unnecessarily nested <ogc:Literal> tags for "-100".

<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
  <ogc:And>
    <ogc:PropertyIsGreaterThan>
      <ogc:PropertyName>Total</ogc:PropertyName>
      <ogc:Literal>-<ogc:Literal>100</ogc:Literal></ogc:Literal>
    </ogc:PropertyIsGreaterThan>
    <ogc:PropertyIsLessThanOrEqualTo>
      <ogc:PropertyName>Total</ogc:PropertyName>
      <ogc:Literal>100</ogc:Literal>
    </ogc:PropertyIsLessThanOrEqualTo>
  </ogc:And>
</ogc:Filter>

When this is submitted to GeoServer without treatment, GeoServer automatically removes the inner <Literal> element (ie. "100") and leaves the minus sign only,

<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
  <ogc:And>
    <ogc:PropertyIsGreaterThan>
      <ogc:PropertyName>Total</ogc:PropertyName>
      <ogc:Literal>-</ogc:Literal>
    </ogc:PropertyIsGreaterThan>
    <ogc:PropertyIsLessThanOrEqualTo>
      <ogc:PropertyName>Total</ogc:PropertyName>
      <ogc:Literal>100</ogc:Literal>
    </ogc:PropertyIsLessThanOrEqualTo>
  </ogc:And>
</ogc:Filter>

Hence any graduated layers using one or more negative numbers end up to be published with malformed SLDs.

Here is a quick workaround I placed in adaptQgsToGs in sldadapter.py

sld = re.sub(r"<ogc:Literal>([^<]*)<ogc:Literal>(.+?)</ogc:Literal>([^<]*)</ogc:Literal>", r"<ogc:Literal>\1\2\3</ogc:Literal>", sld)
rduivenvoorde commented 8 years ago

hi, this was actually a QGIS issue, see http://hub.qgis.org/issues/11863

can you please check 2.10.1 or current master to see if this is still a problem.

if not you can close this issue :-)

kitzilla commented 8 years ago

I have tested without the patch above in Pisa and the confirmed issue is gone. Thank you for letting me know this.