Didrik Pinte wrote:
> Hi,
>
> I'm updating a wms extension for Thuban using OWSLib 0.3.
>
> I have the following problem. The image read from the WMS server is
> considered as broken by the wxWindow frontend. The "workaround" I found
> is saving the stream to a file and then open it in "rb" mode ... :
>
> -----------------------------------------------------------------------------------------
> wms_response = self.wmsserver.getmap(layers=self.wms_layers,
> styles=None,
> srs="EPSG:%s" % epsg_id,
> bbox=bbox,
> size=(width, height),
> format=self.wmsformat,
> transparent=True)
> out = open('wms_image.png', 'wb')
> out.write(wms_response.read())
> out.close()
> return open('wms_image.png', "rb").read(), self.format
> -----------------------------------------------------------------------------------------
>
> The stream is then read by a cStringIO.StringIO object and passed to a
> wx.ImageFromStream object ...
>
> Returning wms_response.read() does not work and gives an WX error
> message saying the file is corrupted.
>
> Is this a known problem ?
>
> Didrik
>
Hi Didrik,
The wms_response is a urllib "file". Check it out by calling its info()
before you hand it over to Wx -- if your WMS doesn't provide service
exceptions properly, it is possible that XML error messages might slip
into the response.
You might also want to check that Wx can read from a urllib file.
Sean
_______________________________________________
Community mailing list
[email protected]
http://lists.gispython.org/mailman/listinfo/community