Senin, 16 April 2012

Dynamic WMS styling with GeoServer: SLD and library mode

Hi all,
today I want to delve a bit in the dynamic styling abilities that GeoServer provides.

GeoServer fully supports a client's ability to specify a custom SLD 1.0 style instead of a built-in named style, this can be done in different ways:
  1. adding a reference to a internet accessible sld file via the &sld=url parameter
  2. specifying the full SLD, url-encoded, in the request URL via the
  3. SLD_BODY=fullStyleDefinitionHere parameter
  4. POST-ing a GetMap XML document, as defined by the SLD 1.0 spec
  5. POST-ing the usual GET request, where each KVP parameter is sent over as a form parameter (this is a GeoServer extension)
Let's have a look at case 3) since it's a bit different than the others. In that case you need to post a XML document just like in WFS/WCS requests, the document looks as follows:


As you can see it's pretty much the usual GetMap request, but expressed in XML format, with the ability to embed UserStyle objects in it, which make it fully dynamic.

Ways 1, 3 and 4 rely on most of the usal GET parameters, and allow you to specify a custom SLD file, but the way the SLD file it's interpreted is radically different depending on whater you did specify the layers and styles param in your request, or not.

The simpler behavior is obtained if you don't specify layers and styles: the NamedLayer objects refer to layers in the server, the NameStyles to styles in the server, and UserStyle allow you to specify your custom style. Each layer is rendered with the style associated to it, and that's it.

However, if you specify layers in the request, the SLD document is downgraded to a "style library", this is known as library mode. Here is how this works:
  • each layer in the layers parameter is drawn in order
  • for each layer, if styles is present the name of the style is picked, otherwise the "default" style is looked for (same happens if you don't specify the style name for that layer)
  • given the layer name and the style name, a layer is searched in the SLD file that has the same name, and the styles inside it are searched for a style with the specified name. If none is found, the server is searched, if the style is not even there, an error is thrown
  • given a layer name and the indication to search the default style, a layer is searched in the SLD file that has the same name, and the user styles inside it are searched for one that has the 1 element making it the default style. If none is found the default style defined on the server side is picked instead, ignoring the SLD file contents.
Given the fact that the library mode is certainly more complex, and that you need to line up layer and style names properly, it is of course recommended not to specify the layers parameter and fall back on the simpler mode.
However, the library mode comes in handy if you are making a complex request, with many layers, and you want to provide a custom style for just a few of them: you just need to add the styles for those few in the SLD file, all the others will fall back to use the server side styles instead.

This is just one of the many ways GeoServer allows to dynamically alter the way maps are being built, others are SLD parameter substitution, dynamic filtering, and rendering transformations.

Want to hear more about dynamic styling? Let us know!

The GeoSolutions team,


Jumat, 13 April 2012

State of GeoServer presentation from FOSS4G-NA


Dear all,
we wanted share the slides from another presentation that Andrea Aime and Justin Deoliveira gave recently at the FOSS4G North America conference about the state of GeoServer.

Here below you have the complete presentation.

The GeoSolutions team,

Rabu, 11 April 2012

Unveiling upcoming GeoServer 2.2 release

Dear all,
we have created this post to share the slides from the presentation that Andrea Aime and Justin de Oliveira gave recently at the FOSS4G North America conference about the new feature that will be available in the upcoming 2.2 release of the GeoServer.

A lot of work has been performed since the first beta release of the 2.1 release, almost 2 years ago, quickly summarising some of the most interesting ones we can enumerate:
  • improved WPS
  • rendering transformation, to perform transformation on-the-fly during rendering
  • improved security subsystem
  • support for bigtiff
  • support for oracle georaster
  • support for TIME and ELEVATION in WMS and WCS
and many more.

For a complete cover of all these features, here you have the complete presentation.



View more presentations from GeoSolutions



The GeoSolutions team,

Senin, 02 April 2012

Saving the world one application at a time: Atlas of Tuna and Billfish Catches

This blog post covers some work we have done to support the FAO Fishery and Acqualture Department, specifically the FIGIS group with information dissemination about catches of Tuna and Billfish over the last 60 years globally

As stated on their website:
"... the Atlas presents the global distribution of catches by gear from 1950 to 2010, at 5° latitude by 5° longitude resolution, of those tuna and tuna-like species for which this distribution is generally well known on the global scale. These species consist of the so-called principal market tunas and some billfishes."

Atlas of Tuna and Billfish catches website


Using Geoserver, OpenLayers and Ext-JSwe built for them a simplfied viewer that allow users to access dynamically their statistics and to map them by multiple dimensions:

  • by gears (one or more)
  • by species (one or more)
  • for a certain years' range
  • for a certain quarters' range
Moreover users can decide to view the following indicators:
  • Cumulative catches across years
  • Average catches across years 
  • Average catches across quarters
The selections made by users are reflected directly on the visualization combining data from various sources through the GeoServer; animations can be created across years as well as years' quarters to show the evolution of the catches. The result can be seen here and in the pictures below.










Let's take a look at the implementation.
Background maps are served via GeoWebCache, nothing too sophisticated there, while the maps are generated on the fly by GeoServer connected to the FAO corporate Oracle instance via SQL Views that are performing join and aggregations on the fly between tables containing live information about catches and tables containing ancillary information like species and gear types. In addition, users can print the current map (together with the eventual result of a request for info on the map), as shown here below,


or they can request to generate an animated GIF, leveraging on the WMS Animator work (see this page for additional info) using a specific panel shown below where multiple dimensions can be again controlled:


Here below the resulting animations is shown.



Let us now summarise a few points for this project:
  • background maps are served with GeoWebCache which is shared with all the others mapping applications in places withing the department
  • most of the data is stored inside the corporate instance of Oracle Spatial, demonstrating perfect integration of Open Source with COTS
  • extensive usage of CQL filters and SQL Parametric Views has been made to generate dynamic maps and animations
Last but not least, we believe it is worth to mention that this work was performed via our GeoSolutions Enterprise ServicesTherefore, if you'd like to know more about what we could achieve together, do not hesitate and get in touch with us!

The GeoSolutions team,