[Geoserver-users] BGCOLOR=0xFFFFFF with cascaded WMS

Hello list,

I noticed that geoserver adds BG=0xFFFFFF to the requests when connecting to a remote wms service. In my case this is a mapserver service where we hardcoded the png outputformat to never be transparent and blue so we get the correct ocean-effect.

Is there a way to bypass the BGCOLOR parameter? Or does this require enhancements to geoserver itself?

Thanks and kind regards,

Milo

Good question, let me check the code … looking at the implementation of GetMap we have:

if (!merged) {
WMSLayer Layer = new WMSLayer(wms, gt2Layer);
Layer.setTitle(wmsLayer.prefixedName());
mapContent.addLayer(Layer);
}

So GeoServer sets a title, but does not set the background color.

Looking at the GeoTools implementation in WMSLayer that does the work … it uses transparent by default:

if(backgroundColor == null) {
mapRequest.setTransparent(true);
} else {
String rgba = Integer.toHexString(backgroundColor.getRGB());
String rgb = rgba.substring(2, rgba.length());
mapRequest.setBGColour(“0x” + rgb.toUpperCase());
mapRequest.setTransparent(backgroundColor.getAlpha() < 255);
}

Expect we need a bug report for this one, I did update the communication page with handy search boxes if you want to check if the issue is reported already. http://geoserver.org/comm/

···

Jody Garnett

On Wed, Jul 30, 2014 at 1:55 PM, Milo van der Linden <milo@anonymised.com> wrote:

Hello list,

I noticed that geoserver adds BG=0xFFFFFF to the requests when connecting to a remote wms service. In my case this is a mapserver service where we hardcoded the png outputformat to never be transparent and blue so we get the correct ocean-effect.

Is there a way to bypass the BGCOLOR parameter? Or does this require enhancements to geoserver itself?

Thanks and kind regards,

Milo


Infragistics Professional
Build stunning WinForms apps today!
Reboot your WinForms applications with our WinForms controls.
Build a bridge from your legacy apps to the future.
http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.clktrk


Geoserver-users mailing list
Geoserver-users@anonymised.comsts.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Hello Jody,

Thanks for the response! I browsed jira first but decided to check with the mailinglist before filing a ticket. As far as I can see there is no entry in jira covering cascaded wms background bgcolor parameter, so if it is ok with you, I will create the ticket.

Kind regards,

Milo

···

2014-07-31 5:30 GMT+02:00 Jody Garnett <jody.garnett@anonymised.com>:

Good question, let me check the code … looking at the implementation of GetMap we have:

if (!merged) {
WMSLayer Layer = new WMSLayer(wms, gt2Layer);
Layer.setTitle(wmsLayer.prefixedName());
mapContent.addLayer(Layer);
}

So GeoServer sets a title, but does not set the background color.

Looking at the GeoTools implementation in WMSLayer that does the work … it uses transparent by default:

if(backgroundColor == null) {
mapRequest.setTransparent(true);
} else {
String rgba = Integer.toHexString(backgroundColor.getRGB());
String rgb = rgba.substring(2, rgba.length());
mapRequest.setBGColour(“0x” + rgb.toUpperCase());
mapRequest.setTransparent(backgroundColor.getAlpha() < 255);
}

Expect we need a bug report for this one, I did update the communication page with handy search boxes if you want to check if the issue is reported already. http://geoserver.org/comm/

Jody Garnett

On Wed, Jul 30, 2014 at 1:55 PM, Milo van der Linden <milo@anonymised.com> wrote:

Hello list,

I noticed that geoserver adds BG=0xFFFFFF to the requests when connecting to a remote wms service. In my case this is a mapserver service where we hardcoded the png outputformat to never be transparent and blue so we get the correct ocean-effect.

Is there a way to bypass the BGCOLOR parameter? Or does this require enhancements to geoserver itself?

Thanks and kind regards,

Milo


Infragistics Professional
Build stunning WinForms apps today!
Reboot your WinForms applications with our WinForms controls.
Build a bridge from your legacy apps to the future.
http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.clktrk


Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

On Wed, Jul 30, 2014 at 10:55 PM, Milo van der Linden <milo@anonymised.com>
wrote:

Hello list,

I noticed that geoserver adds BG=0xFFFFFF to the requests when connecting
to a remote wms service. In my case this is a mapserver service where we
hardcoded the png outputformat to never be transparent and blue so we get
the correct ocean-effect.

Is there a way to bypass the BGCOLOR parameter? Or does this require
enhancements to geoserver itself?

The problem with cascaded wms layers is that they can be used for overlay,
without control on our side.
One way to handle this would be to allow the admin to setup the
transparency flag at the layer definition level.

A probably better approach would be to do that dynamically, and setup the
transparency flag only when the layer
is not the first in the list.

About requests that do specify both bgcolor and transparent=true, the spec
seems to advise that
transparent takes over bgcolor:

When TRANSPARENT is set to TRUE and the FORMAT parameter contains a Picture
format (e.g., image/gif), then a WMS shall return (when permitted by the
requested
format) a result where all of the pixels not representing features or data
values in that
Layer are set to a transparent value. For example, a "roads" layer would be
transparent
wherever no road is shown. When TRANSPARENT is set to FALSE, those pixels
shall
be set to the value of BGCOLOR (Section 7.2.3.10).

Also, setting bgcolor to 0xFFFFFF is the same as not setting it, from the
spec:

The optional BGCOLOR parameter specifies the color to be used as the
background of
the map ...
The default value is 0xFFFFFF
(corresponding to the color white) if this parameter is absent from the
request

Cheers
Andrea

--

GeoServer Professional Services from the experts! Visit
http://goo.gl/NWWaa2 for more information.

Ing. Andrea Aime
@geowolf
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549

http://www.geo-solutions.it
http://twitter.com/geosolutions_it

-------------------------------------------------------