Fix bad WMS server performance

This fixes a performance problem with the WMS server. I don't like this fix, but I don't know the WMS server well enough to write a better one. Leaving the decision to @mhugent.