WMS supports so called VIEWSPARAMS. These allow you to filter the results of a WMS layer. More information on the Geoserver website.

It would be great if the WMS layer would support this. One way would be to get filter parameters from the view, then pass them on to the Geoserver for filterering. Another one would be to filter on the actual results of the view.

Here is a scenario of the latter: The American Elections.

In your drupal database, you have information about all states, and whether a democrat or a republican won.

On the page about the democrats you want to show all polygons of states that were won by democrats in red.
If you are going to use Openlayers and polygons for this, your page is going to weight more than 10MB, and your browser will explode.
If you let Geoserver (where you have a table with state outlines in your postGIS database) render the information, you are all fine.

So you build an Openlayers view that returns only districts that the democrats won. On your WMS layer that you use in your map/preset, you can add a VIEWPARAMS that uses the return value of the State names.

On the Geoserver you build a query that looks like:

Select * from State where name in ( %drupalvalue%)

Now, Geoserver will filter the layer of States according to a Drupal filter (democrats).

Feel free to start with this, we just had this brainwave, and might pick it up at some point.

Comments

mgifford’s picture

Seems like that would be a very neat addition. Certainly for the upcoming election! Hopefully you get it up & running and are able to contribute it back.