We are using GeoServer to show a river/stream network as a tile layer. Our data store comes from a shapefile, and the layer is styled to display the stream names as a label that follows the stream path. Tile caching is enabled, which is providing excellent performance.

One requirement is that users can click a stream and have it highlight, as well as return information about the stream. I'm currently implementing this as a GetFeatureInfo request that returns the feature's data as well as its geometry as GeoJson. I'm then using the GeoJson to add a polyline in our google map, which renders on top of the tile layer.

The problem with that is that the polyline covers up the labels. I would like instead to bring back the highlighted stream as part of the tile layer.

What I'm thinking of doing is having there be two layers, say streams_unselected and streams_selected. Selected would be styled differently, say with a thick yellow stroke. Then I would pass filters for each tile layer. By default, i.e. without any stream selected, the streams_unselected layer would have a filter that always passes, and streams_unselected would have a filter that never passes.

Then, when the user selects a feature, I would modify the filters of each layer based on the feature_id (we'll call it X) of the feature selected. The filter for streams_unselcted would specify that the feature_id != to X, and for streams_selected it would specify that the feature_id == X.

First question: Does this seem like a sane approach?

Second question: I'm currently using GeoWebCache, and specifying a URL to /geoserver/gwc/service/gmaps. I don't think this will work with filtering. I do love the performance, however.

I've seen posts online about GeoWebCache direct integration with WMS (http://geoserver.geo-solutions.it/edu/en/caching_data/caching_maps.html). It looks like this may solve my problem. Am I right in assuming that I can use a WMS GetMap url instead, passing my filters in the url, and GeoServer will use GeoWebCache in the background to serve tiles from that if they are cached, and generate new tiles if not?

I've also seen something on GeoWebCache Parameter Filters, maybe that's the better route.

  • As per the Tour there should be only one question asked per question. – PolyGeo Jan 18 '17 at 21:19