[Geoserver-users] Advice for shortening a 68 rule SLD!

Hi, I was wondering whether anyone might have some useful advice regarding
how i can shorten the length of my SLD? My SLD is currently composed of one
transformation and 68 rules, and is currently over 2000 lines long! The
reason it is so long is because the SLD classifies data into wind barb
symbols (currently external graphics, but these will be replaced to a font
once the font has been uploaded onto my companies geoserver), therefore
there are two filters the data must go through; the first filter assigns the
data to the northern or southern hemisphere, and the second filter then
assigns the data to the correct wind barb symbol according to wind speed
(the wind barbs are not the same in both hemispheres, hence the first
filter).

In essence, it would be great if i could combine these two filters within
one rule, so that there will only be 34 rules instead or, better yet, maybe
there is a way i can call a maths filter function to filter the data
according to the relationship between wind barb font name and the variable
range? (these are suggestions that have been made to me but as i am quite
new to SLD's, i have little idea of if/ how i can do this).

Any advice would be greatly appreciated,

Christine

FYI: Below is a copy of my transformation and the first two rules:

<NamedLayer>
    <Name>geos:mideast_prmsl.t00z.pgrbf24</Name>
    <UserStyle>
      <Title>y component</Title>
      <Abstract>Symbol</Abstract>
      <FeatureTypeStyle>
        <Transformation>
          <ogc:Function name="gs:RasterAsPointCollection">
            <ogc:Function name="parameter">
              <ogc:Literal>data</ogc:Literal>
            </ogc:Function>
          </ogc:Function>
        </Transformation>
        <Rule>
          <Name>Northern Hemisphere - 0 knotts </Name>
          <ogc:Filter>
            <And>
              <ogc:PropertyIsGreaterThanOrEqualTo>
                <ogc:Function name="getY">
                  <ogc:PropertyName>the_geom</ogc:PropertyName>
                </ogc:Function>
                <ogc:Literal>0</ogc:Literal>
              </ogc:PropertyIsGreaterThanOrEqualTo>
              <ogc:PropertyIsLessThan>
                <ogc:PropertyName>GRAY_INDEX</ogc:PropertyName>
                <ogc:Literal>2.5</ogc:Literal>
              </ogc:PropertyIsLessThan>
            </And>
          </ogc:Filter>
          <PointSymbolizer>
            <Graphic>
              <ExternalGraphic>
                <OnlineResource xlink:type="simple"
                               
xlink:href="http://fgwfhp014/pics/wind_barb_symbology/0knots.png&quot;/&gt;
                <Format>image/png</Format>
              </ExternalGraphic>
              <Size>30</Size>
              <Rotation>
                <ogc:Sub>
                  <ogc:Function name="IEEERemainder">
                    <ogc:PropertyName>GRAY_INDEX</ogc:PropertyName>
                    <ogc:Function name="parseDouble">
                      <ogc:Literal>360</ogc:Literal>
                    </ogc:Function>
                  </ogc:Function>
                  <ogc:Literal>90</ogc:Literal>
                </ogc:Sub>
              </Rotation>
            </Graphic>
          </PointSymbolizer>
        </Rule>
        <Rule>
          <Name>Southern Hemisphere - 0 knotts </Name>
          <ogc:Filter>
            <And>
              <ogc:PropertyIsLessThan>
                <ogc:Function name="getY">
                  <ogc:PropertyName>the_geom</ogc:PropertyName>
                </ogc:Function>
                <ogc:Literal>0</ogc:Literal>
              </ogc:PropertyIsLessThan>
              <ogc:PropertyIsLessThan>
                <ogc:PropertyName>GRAY_INDEX</ogc:PropertyName>
                <ogc:Literal>2.5</ogc:Literal>
              </ogc:PropertyIsLessThan>
            </And>
          </ogc:Filter>
          <PointSymbolizer>
            <Graphic>
              <ExternalGraphic>
                <OnlineResource xlink:type="simple"
                               
xlink:href="http://fgwfhp014/pics/wind_barb_symbology/0knots.png&quot;/&gt;
                <Format>image/png</Format>
              </ExternalGraphic>
              <Size>30</Size>
              <Rotation>
                <ogc:Sub>
                  <ogc:Function name="IEEERemainder">
                    <ogc:PropertyName>GRAY_INDEX</ogc:PropertyName>
                    <ogc:Function name="parseDouble">
                      <ogc:Literal>360</ogc:Literal>
                    </ogc:Function>
                  </ogc:Function>
                  <ogc:Literal>90</ogc:Literal>
                </ogc:Sub>
              </Rotation>
            </Graphic>
          </PointSymbolizer>
        </Rule>

--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Advice-for-shortening-a-68-rule-SLD-tp5056349.html
Sent from the GeoServer - User mailing list archive at Nabble.com.

On Tue, May 28, 2013 at 11:11 AM, cjones <c.jones@anonymised.com> wrote:

Hi, I was wondering whether anyone might have some useful advice regarding
how i can shorten the length of my SLD? My SLD is currently composed of one
transformation and 68 rules, and is currently over 2000 lines long! The
reason it is so long is because the SLD classifies data into wind barb
symbols (currently external graphics, but these will be replaced to a font
once the font has been uploaded onto my companies geoserver), therefore
there are two filters the data must go through; the first filter assigns
the
data to the northern or southern hemisphere, and the second filter then
assigns the data to the correct wind barb symbol according to wind speed
(the wind barbs are not the same in both hemispheres, hence the first
filter).

Hum, this seems a good fit for dynamic symbolizers:

http://blog.geoserver.org/2008/12/08/dynamic-symbolizers-part-1/

Basically, you can embed whatever cql expression referring to your data
in the external graphic URLs.
However, in your case the expression would be rather complicated, see
the filter function reference for inspiration:
http://docs.geoserver.org/stable/en/user/filter/function_reference.html

I believe that using one of the scripting modules you could also roll
your own filter function to factor the code out of the SLD, but I'm not
up to speed with the details, cc'ing Justin about it.

Cheers
Andrea

--

GeoServer training in Milan, 6th & 7th June 2013! Visit
http://geoserver.geo-solutions.it 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

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

Hi Andrea,

Thank you for response and apologies for my late reply.

I've had a look at what you suggested and have carried out some of my own
research but I am unsure of how I would apply a complex filter to an
external graphic URL, with the filter obviously being then further
complicated by the embedded function that i call upon within the first
instance.

Do you think it would make more sense to embed a cql expression that
implements the second filter within the external graphic URL, and then leave
the first filter within the SLD config?

Thanks,

Christine

--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Advice-for-shortening-a-68-rule-SLD-tp5056349p5057443.html
Sent from the GeoServer - User mailing list archive at Nabble.com.

For example, how would i (more to the point, can i?) put the following into
an external graphic URL as an embedded cql expression? (the line break
separates the two rules, with the second section being the rule that i
believe i should try to embed within the expression).

<ogc:Filter>
            <ogc:And>
              <ogc:PropertyIsGreaterThanOrEqualTo>
                <ogc:Function name="getY">
                  <ogc:PropertyName>the_geom</ogc:PropertyName>
                </ogc:Function>
                <ogc:Literal>0</ogc:Literal>
              </ogc:PropertyIsGreaterThanOrEqualTo>

              <ogc:PropertyIsGreaterThanOrEqualTo>
                <ogc:PropertyName>GRAY_INDEX</ogc:PropertyName>
                <ogc:Literal>7.5</ogc:Literal>
              </ogc:PropertyIsGreaterThanOrEqualTo>
              <ogc:PropertyIsLessThan>
                <ogc:PropertyName>GRAY_INDEX</ogc:PropertyName>
                <ogc:Literal>12.5</ogc:Literal>
              </ogc:PropertyIsLessThan>
            </ogc:And>
          </ogc:Filter>

--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Advice-for-shortening-a-68-rule-SLD-tp5056349p5057449.html
Sent from the GeoServer - User mailing list archive at Nabble.com.

On Mon, Jun 3, 2013 at 1:10 PM, cjones <c.jones@anonymised.com> wrote:

For example, how would i (more to the point, can i?) put the following into
an external graphic URL as an embedded cql expression? (the line break
separates the two rules, with the second section being the rule that i
believe i should try to embed within the expression).

<ogc:Filter>
            <ogc:And>
              <ogc:PropertyIsGreaterThanOrEqualTo>
                <ogc:Function name="getY">
                  <ogc:PropertyName>the_geom</ogc:PropertyName>
                </ogc:Function>
                <ogc:Literal>0</ogc:Literal>
              </ogc:PropertyIsGreaterThanOrEqualTo>

              <ogc:PropertyIsGreaterThanOrEqualTo>
                <ogc:PropertyName>GRAY_INDEX</ogc:PropertyName>
                <ogc:Literal>7.5</ogc:Literal>
              </ogc:PropertyIsGreaterThanOrEqualTo>
              <ogc:PropertyIsLessThan>
                <ogc:PropertyName>GRAY_INDEX</ogc:PropertyName>
                <ogc:Literal>12.5</ogc:Literal>
              </ogc:PropertyIsLessThan>
            </ogc:And>
          </ogc:Filter>

I guess so yes... there is no way to make the combination "pretty" afaik,
but putting togheter calls to if_then_else and other functions you should
be able to get a shorter SLD (with a very long image location expression I'm
afraid).

Hum... I guess if you rename appropriately your icons you could maybe do
some
math and shorten the expression. Something like:

knots_${if_then_else(greaterThan(getY(the_geom), 0), 'north',
'south')}_${GRAY_INDEX / 5}

The second part could also use the categorize function:

categorize(GRAY_INDEX, 0, '0n', 2.5, '2n', 7.5, '7n')

There are many possibilities, it's just hard to tell what's going to work
or not based
on a quick look at the style.

Cheers
Andrea

--

GeoServer training in Milan, 6th & 7th June 2013! Visit
http://geoserver.geo-solutions.it 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 Andrea; your example has provided me with some much needed clarity
regarding the CQL structure.

Would you happen to know whether there is a file outlining all the different
CQL functions that i can implement and call upon? ie, you mentioned the
'if_then_else' function - i have read the 'CQL Parser Design' webpage, as
well as the obvious sections within the GeoServer manual but I am still no
clearer on whether there are set functions to implement or if i 'create' my
own.....

--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Advice-for-shortening-a-68-rule-SLD-tp5056349p5057705.html
Sent from the GeoServer - User mailing list archive at Nabble.com.

On Tue, Jun 4, 2013 at 11:59 AM, cjones <c.jones@anonymised.com> wrote:

Would you happen to know whether there is a file outlining all the
different
CQL functions that i can implement and call upon? ie, you mentioned the
'if_then_else' function - i have read the 'CQL Parser Design' webpage, as
well as the obvious sections within the GeoServer manual but I am still no
clearer on whether there are set functions to implement or if i 'create' my
own.....

I did link to the filter function reference in my first answer, here it is
again:
http://docs.geoserver.org/stable/en/user/filter/function_reference.html

Cheers
Andrea

--

GeoServer training in Milan, 6th & 7th June 2013! Visit
http://geoserver.geo-solutions.it 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 - i was just unclear on whether i could use those filter functions 'as
they are' within the dynamic symbolizer or whether i was to use them as
inspiration to create my own unique functions! All has become clearer now
though; I have stumbled across a useful blog post which has outlined the
functions i can use in a really simple direct way:

http://www.azavea.com/blogs/labs/2011/06/using-the-cql_filter-parameter-with-openlayers-wms-layers/

I'm still very new to Geoserver so it takes me a while to get my head around
things! But here's hoping with time and patience everything will become a
bit clearer :slight_smile:

--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Advice-for-shortening-a-68-rule-SLD-tp5056349p5057734.html
Sent from the GeoServer - User mailing list archive at Nabble.com.

There’s also the ECQL Language Reference page:

http://docs.geoserver.org/stable/en/user/filter/ecql_reference.html

There are quite a few logic elements which are expressed using direct syntax constructs, rather than functions.

···

On Tue, Jun 4, 2013 at 3:09 AM, Andrea Aime <andrea.aime@anonymised.com> wrote:

On Tue, Jun 4, 2013 at 11:59 AM, cjones <c.jones@anonymised.com> wrote:


How ServiceNow helps IT people transform IT departments:

  1. A cloud service to automate IT design, transition and operations
  2. Dashboards that offer high-level views of enterprise services
  3. A single system of record for all IT processes
    http://p.sf.net/sfu/servicenow-d2d-j

Geoserver-users mailing list
Geoserver-users@anonymised.comsts.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Would you happen to know whether there is a file outlining all the different
CQL functions that i can implement and call upon? ie, you mentioned the
‘if_then_else’ function - i have read the ‘CQL Parser Design’ webpage, as
well as the obvious sections within the GeoServer manual but I am still no
clearer on whether there are set functions to implement or if i ‘create’ my
own…

I did link to the filter function reference in my first answer, here it is again:
http://docs.geoserver.org/stable/en/user/filter/function_reference.html

Cheers

Andrea

==
GeoServer training in Milan, 6th & 7th June 2013! Visit http://geoserver.geo-solutions.it 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


On Tue, Jun 4, 2013 at 6:02 PM, Martin Davis <mtnclimb@anonymised.com> wrote:

There's also the ECQL Language Reference page:

http://docs.geoserver.org/stable/en/user/filter/ecql_reference.html

There are quite a few logic elements which are expressed using direct
syntax constructs, rather than functions.

Except you cannot use them to build an expression.
In the OGC world you can have Expressions, that generally produce a value,
and Filter,
that give you a yes/no (boolean) answer.
Unfortunately Filter is not an expression, so while it can contain them, it
cannot be mixed
among them, filter is always the "root" or your evaluation tree.

Cheers
Andrea
--

GeoServer training in Milan, 6th & 7th June 2013! Visit
http://geoserver.geo-solutions.it 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

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