Configuring GeoServer

Locally hosting vector layers as WMS and WFS for Siren Investigate

If you need to display custom layers for Region Map or Coordinate Map visualizations, or want to use spatial datasets within Siren Investigate, a geospatial server may provide the solution.

A geospatial server can handle the conversion of spatial datasets, layer styling options, serve WFS and WMS simultaneously, and can integrate and serve Elasticsearch documents. The following sections explain how to set up GeoServer, a popular open-source interoperable  geospatial server.

GeoServer can serve information in WMS, WMTS, WFS, or WCS, and is easy to install and configure. Vector layers can be imported in multiple formats such as ESRI Shapefile, WFS, PostGIS, GeoPackage, and Java Properties; in addition, GeoServer can be linked with Elasticsearch using the elasticgeo plugin.

The article Going beyond “dots on a map” provides excellent background information on mapping.

Setting up a web server to serve GeoJSON for Region Maps visualization

If you just want a quick and easy way to serve GeoJSON vector layers for use with the Region Map visualization, you can use “http-server”, a command-line http server that uses NodeJS. It’s a quick and easy way to serve files locally.

First, you need to install NodeJS.

Then, install http-server:

npm install http-server -g

Navigate to the folder with the GeoJSONs and run http-server as CORs enabled, with Port 9000 as shown here:

Http-server ./ -p 9000 --cors="*"

Replace the url in the investigate.yml file (also making sure to calibrate the remainder of the fields for each GeoJSON), and start Siren Investigate.

http://localhost:9000/world_countries_v1.geo.json

Installing GeoServer

Depending on your OS, follow the instructions at the links below for installing GeoServer:

If you would like to link your Elasticsearch index with GeoServer, the latest version currently supported is v2.14.2.

Enabling Cross Origin Resource Sharing (CORS)

As GeoServer will be running on a separate domain to Siren, you may get a CORS error in your development window, something like:

image

To get around this issue:

  • Edit your web.xml file as is shown in the Enable CORs section here.

  • Download the Jetty-Utility Servlets Jar to match the version of Jetty for the specific version of GeoServer.

  • Copy this to webapps/geoserver/WEB-INF/lib inside the geoserver-[v.vv.v] directory (or wherever you unpacked the zip file).

Adding vector layers to GeoServer

Open your browser and navigate to Port 8080, the default, on your local host: http://localhost:8080/geoserver

Log in with the default credentials:

  • Username: admin

  • Password: geoserver

From here you can:

  • Add new stores, i.e. sources for your spatial data

  • Create workspaces

  • Add layers to the server (and workspaces) from your stores

  • Create groups of layers that can be returned in one request

  • Create styling for how your layers will be rendered on a map

image

Make sure that WMS and WFS are enabled by selecting both on the navigation pane on the left:

image

Creating layer styles for GeoServer

There are many examples for creating styles in the SLD cookbook. If you have a preference for a GUI-based method of styling over the XML format of SLD used in GeoServer, Quantum GIS offers a way to export styles created in their GUI to SLD format.

Styles for layers or layer groups are either set as defaults within GeoServer or specified as a parameter from Siren Investigate.

Linking Elasticsearch and GeoServer

You can add Elasticsearch indexes to your Geoserver instance by following the installation and configuration instructions of the elasticgeo plugin.

When editing your elasticsearch store, you will need to add siren/ at the very beginning of the index_name* field. This is to reference that the query should be sent to Siren Federate for processing. For example:

image

The most recent version of elasticgeo is v2.14.2, and is compatible with GeoServer v2.14.2.