Patchs for OWSLib

View: New views
2 Messages — Rating Filter:   Alert me  

Patchs for OWSLib

by Nabil Servais :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

I would like to suggest 2 patchs.
The first is  for supporting custom parameters of WMS, I don't know if it's normalize by OGC, but it's supported by Mapserver.
For exemple I have this request  in openlayers:

http://wmshost/cgi-bin/xyea?LAYERS=oursindep%2Cetablissement&FORMAT=jpg&IDOURSIN=%20uai_dger%7C%7Cinsee_resplegal%20%7C%7Cfiliere_code%7C%7Csecteur_pro_code%7C%7Coption_code&GROUPBYCLAUSE=%20GROUP%20BY%20%20uai_dger&WHERECLAUSE=%20WHERE%20secteur_code%20%3D%201&GEOMSUFFIXE=_rel&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application%2Fvnd.ogc.se_inimage&SRS=EPSG%3A27572&BBOX=-679807.84,1230100.62,1925309.84,2987770.38&WIDTH=996&HEIGHT=672

And this is the request with my owslib patched :

      url_wms = 'http://wmshost/cgi-bin/xyea'
      layers = [ 'oursindep', 'etablissement', 'responsables_legaux', 'regions']
      bbox = (-10.900634765625, 36.857250976562, 15.400634765625, 55.742749023437)
      styles = ''
      custom = {'WHERECLAUSE':'WHERE secteur_code = 1',
                'GROUPBYCLAUSE':'GROUP BY uai_dger',
                'IDOURSIN':'uai_dger||insee_resplegal ||filiere_code||secteur_pro_code||option_code'}
img = wms.getmap(layers=layers,
                       styles=styles,
                       bbox=bbox,
                       size=(1197, 859),
                       format='image/jpeg',
                       srs='EPSG:4326',
                       custom = custom
                       )

And the second is for solve encoding problem when the return of the wms server is not ascii.

--- wms2.py 2009-10-09 18:45:46.000000000 +0200
+++ wms.py 2009-10-09 11:39:14.000000000 +0200
@@ -153,7 +153,8 @@
                format=None, size=None, time=None, transparent=False,
                bgcolor='#FFFFFF',
                exceptions='application/vnd.ogc.se_xml',
-               method='Get'
+               method='Get',
+               custom = []
                ):
         """Request and return an image from the WMS as a file-like object.
         
@@ -178,7 +179,8 @@
             Optional. Image background color.
         method : string
             Optional. HTTP DCP method name: Get or Post.
-        
+        vendor : dict
+            OPtionnal : vendor parameters for wms server
         Example
         -------
             >>> img = wms.getmap(layers=['global_mosaic'],
@@ -188,6 +190,7 @@
             ...                  format='image/jpeg',
             ...                  size=(300,250),
             ...                  transparent=True,
+            ...                  vendor = {'filter':'river'},
             ...                  )
             >>> out = open('example.jpg', 'wb')
             >>> out.write(img.read())
@@ -216,6 +219,7 @@
         request['transparent'] = str(transparent).upper()
         request['bgcolor'] = '0x' + bgcolor[1:7]
         request['exceptions'] = str(exceptions)
+        request.update(custom)
         
         if time is not None:
             request['time'] = str(time)


_______________________________________________
Community mailing list
Community@...
http://lists.gispython.org/mailman/listinfo/community

patch-wms2.patch (1K) Download Attachment

Re: Patchs for OWSLib

by Dominic Lowe-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

Many thanks for both these contributions.
Do you have a service running anywhere where I can test your patches?

Actually I've implemented custom parameters in the WCS just using the python
**kwargs parameter. So we could do it that way in the WMS too (just to make
them the same).

Ok, I've made tickets for both these patches and will address them shortly -
unless anyone else does first!

http://trac.gispython.org/lab/ticket/192
http://trac.gispython.org/lab/ticket/193

Many thanks indeed,

Dom








On Wednesday 14 October 2009 13:10:24 Servais Nabil wrote:

>  Hello,
>
> I would like to suggest 2 patchs.
> The first is  for supporting custom parameters of WMS, I don't know if it's
> normalize by OGC, but it's supported by Mapserver.
> For exemple I have this request  in openlayers:
>
> http://wmshost/cgi-bin/xyea?LAYERS=oursindep%2Cetablissement&FORMAT=jpg&IDO
>URSIN=%20uai_dger%7C%7Cinsee_resplegal%20%7C%7Cfiliere_code%7C%7Csecteur_pro
>_code%7C%7Coption_code&GROUPBYCLAUSE=%20GROUP%20BY%20%20uai_dger&WHERECLAUSE
>=%20WHERE%20secteur_code%20%3D%201&GEOMSUFFIXE=_rel&SERVICE=WMS&VERSION=1.1.
>1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application%2Fvnd.ogc.se_inimage&SRS=EPS
>G%3A27572&BBOX=-679807.84,1230100.62,1925309.84,2987770.38&WIDTH=996&HEIGHT=
>672
>
> And this is the request with my owslib patched :
>
>       url_wms = 'http://wmshost/cgi-bin/xyea'
>       layers = [ 'oursindep', 'etablissement', 'responsables_legaux',
> 'regions']
>       bbox = (-10.900634765625, 36.857250976562, 15.400634765625,
> 55.742749023437)
>       styles = ''
>       custom = {'WHERECLAUSE':'WHERE secteur_code = 1',
>                 'GROUPBYCLAUSE':'GROUP BY uai_dger',
>                 'IDOURSIN':'uai_dger||insee_resplegal
>
> ||filiere_code||secteur_pro_code||option_code'}
>
> img = wms.getmap(layers=layers,
>                        styles=styles,
>                        bbox=bbox,
>                        size=(1197, 859),
>                        format='image/jpeg',
>                        srs='EPSG:4326',
>                        custom = custom
>                        )
>
> And the second is for solve encoding problem when the return of the wms
> server is not ascii.


_______________________________________________
Community mailing list
Community@...
http://lists.gispython.org/mailman/listinfo/community