Creating a parametric view

A parametric SQL view is based on a SQL query containing the named parameters with values provided dynamically in WMS and WFS requests.

How to do it…

  1. We will now create a new view by extending the code of the previous step. What if you want to have a dynamic view that works for each continent? You need to start the same way as we did previously: select Add a new resource from the Layer menu.
  2. Select the data store pointing to PostGIS or your preferred RDBMS. Instead of selecting a table from the list, select the Configure new SQL view… link:
  3. In the form, insert ContinentView as View Name and the following code as the SQL statement:
    SELECT 
      ADMIN,
      GEOM
    FROM 
      COUNTRIES
    WHERE 
      CONTINENT = '%continent%'
  4. Go to the SQL view parameters ...

Get GeoServer Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.