I managed to get this working with GeoServer but I'd like to see if it's also possible with MapServer.

I need to generate a dynamic copyright. I have a polygon layer in Oracle Spatial which contains the names of the data providers and the areas they provided. The copyright is updated at each pan and zoom.

With Geoserver, I created a custom function which captures all the polygons returned by the spatial query (performed by geoserver). From those, I get all the provider names (which are stored in an attribute of the polygon layer) into a string, generate a point (ex: bottom-center) and use the string as its label.

The custom function yields a single point with its label. This function is called during every WMS request to this layer.

How could I achieve the same thing with MapServer ?

Is it possible to get the resulting polygons with a mapscript ?

Is it possible to create a point at runtime with a mapscript ?

Should I capture the bbox parameter from the query :

req = mapscript.OWSRequest()
bbox = req.getValueByName('BBOX')

...and perform the spatial query myself (using the bbox) ? That way, I could get only the provider names. I could then add the point and define its label using the results of the query.

Maybe I can create a mapFile with a custom spatial query and return a single point with its label in another field. That way a simple map file could be used to achieve the same result. I read that it's not possible to have a layer with invisible features (opacity : 0) but the labels visible so it's probably not the solution.

Here's a picture of the results in GeoServer. There's a raster layer and on top of it, there's the dynamic copyright layer. This layer contains a single invisible point (opacity : 0) with its label (which is visible). The point is positioned at the bottom-center :

Dynamic Copyright picture

  • I'm confused with what you are trying to do, could you perhaps show an image your working GeoServer example. Are you trying to display a label on top of a WMS image, or are you using WFS, or is it some combination, or something else? When you say How can I get the bbox parameter from the url? what URL are you referring to – nmtoken Sep 7 '17 at 16:57
  • I'm creating a WMS layer that will be used as an overlay to other layers. It will be completely transparent except for the label at the bottom. I refer to the URL representing the WMS request which contains BBOX, LAYERS, etc ... parameters. – Olyster Sep 7 '17 at 17:44
  • 1
    This is a good starting point : lists.osgeo.org/pipermail/mapserver-users/2016-February/… The only thing would be to dynamically change the TEXT using the features returned. – Olyster Sep 7 '17 at 18:05
  • But you create the URL of a GetMap request, so you/your app will know the bbox, as you need it to make the request. – nmtoken Sep 7 '17 at 20:27
  • So in the example you give and the page it references mapserver.org/…, there is no spatial query going on. So you will need to add that aspect, that is connect to the data, and have some expression that retrieves the geometry/attribution you want, just like setting up any other WMS layer. Did you try any of this already? – nmtoken Sep 8 '17 at 7:36

I finally managed to make it work with a python script in MapServer.

With mapObj(), I load the .map file which displays all the polygons containing informations on the dataproviders.

Then I use layer.WhichShapes(mapscript.OWSRequest().getValueByName('BBOX')) to get the features in the current visible extent.

I then loop through the results to get the provider names and store them in a string.

The map file has another point layer which I use to add a point at the bottom center and set its label to the string containing the provider names.

The copyright is updated on each pan/zoom.

Here's the result :

Dynamic Copyright

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.