[Geoserver-users] How to use "gs:Reproject" in sld ? How to set forcedCRS and targetCRS?

Hi,
I want to reproject data via 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>RAIN_SLD</Name>
    <UserStyle>
      <Title>RAIN</Title>
      <FeatureTypeStyle>
        <Transformation>
          <ogc:Function name="gs:BufferFeatureCollection">
            <ogc:Function name="parameter">
              <ogc:Literal>features</ogc:Literal>
              <ogc:Function name="gs:Reproject">
                <ogc:Function name="parameter">
                  <ogc:Literal>features</ogc:Literal>
                </ogc:Function> <!-- end parameter -->
                <ogc:Function name="parameter">
                  <ogc:Literal>forcedCRS</ogc:Literal>
                  <ogc:Literal>EPSG:4326</ogc:Literal>
                </ogc:Function> <!-- end parameter -->
                <ogc:Function name="parameter">
                  <ogc:Literal>targetCRS</ogc:Literal>
                  <ogc:Literal>EPSG:900913</ogc:Literal> <!-- end parameter -->
                </ogc:Function> <!-- end targetCRS -->
              </ogc:Function> <!-- end reporject -->
            </ogc:Function> <!-- end parameter -->
            <ogc:Function name="parameter">
              <ogc:Literal>distance</ogc:Literal>
              <ogc:Function name="env">
                <ogc:Literal>BUFFER_DIS</ogc:Literal>
                <ogc:Literal>10000</ogc:Literal>
              </ogc:Function>
            </ogc:Function> <!-- end parameter -->
          </ogc:Function>
        </Transformation>

        <Rule>
          <Name>BUFFER</Name>
          <Title>BUFFER</Title>
          <ogc:Filter>
            <ogc:PropertyIsEqualTo>
              <ogc:PropertyName>SN</ogc:PropertyName>
              <ogc:Literal>A0001</ogc:Literal>
            </ogc:PropertyIsEqualTo>
          </ogc:Filter>

          <PolygonSymbolizer>
            <Stroke>
              <CssParameter name="stroke">#d3d3d3</CssParameter>
              <CssParameter name="stroke-width">2</CssParameter>
            </Stroke>
          </PolygonSymbolizer>

          <PointSymbolizer>
            <Graphic>
              <Mark>
                <WellKnownName>circle</WellKnownName>
                <Fill>
                  <CssParameter name="fill">#ff0000</CssParameter>
                </Fill>
              </Mark>
              <Size>6</Size>
            </Graphic>
          </PointSymbolizer>
        </Rule>
      </FeatureTypeStyle>
    </UserStyle>
  </NamedLayer>
</StyledLayerDescriptor>

When i requested the layer with the SLD above, i got an error:

Could not convert the value EPSG:4326 into the expected type interface org.opengis.referencing.crs.CoordinateReferenceSystem for parameter forcedCRS.

I found an example: Geoserver: Georectification via SLD fails

It is useful. But in my situation, 2 CRSs(forcedCRS and targetCRS) must be set.

How could I do with it?

GeoServer:
Version 2.5.1
Git version: d0961aa9d87ccaca185b89b339d053ae91a6fa35
GeoTools version: 11.1 (rev d0db3a062cbcf1e6751db061d5b347e0af228ce6)
GeoWebCache version: 1.5.2 (rev 1.5.x/aac4b4f7ad149a4d36df3997e21709501ce56186)

Best regards,
L

On Mon, Jun 16, 2014 at 4:44 AM, Like-Self <like_self@anonymised.com> wrote:

Hi,
I want to reproject data via sld:

Which does not make much sense... WMS is built to do reprojection on its
own, you just
specify the target SRS in the request, while the source one is associated
in the layer configuration instead.

Cheers
Andrea

--

GeoServer Professional Services from the experts! Visit
http://goo.gl/NWWaa2 for more information.

Ing. Andrea Aime
@geowolf
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549

http://www.geo-solutions.it
http://twitter.com/geosolutions_it

-------------------------------------------------------

Thanks for your reply.
I remove the forcedCRS in the transformation block in sld, and it works well.

But there is another problem:
My source data is ESPG:4326, the tranformation process in sld:
Step 1. project EPSG:4326 to EPSG:900913
Step 2. get buffer of the feature (reprojected in step 1, so I think the unit of buffer is Meters)

I tried the wps process in “WPS request builder” demo in GeoServer, and checked the result in ArcMap, it seems to be right.

But when I requested layer with the style, i got a wrong buffered result. It looks like buffered in demical degree but not meters.

Best Regards
L

···

On Mon, Jun 16, 2014 at 4:44 AM, Like-Self <like_self@…887…> wrote:

Hi,
I want to reproject data via sld:

Which does not make much sense… WMS is built to do reprojection on its own, you just
specify the target SRS in the request, while the source one is associated in the layer configuration instead.

Cheers
Andrea

==

GeoServer Professional Services from the experts! Visit
http://goo.gl/NWWaa2 for more information.

==

Ing. Andrea Aime

@geowolf
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549

http://www.geo-solutions.it
http://twitter.com/geosolutions_it