Re: [QGIS-Developer] Inconsistency in QgsServerRequest parameter handling ?

2019-04-10 Thread pblottiere
Hi David,


> If you try:
>
> request.setParameter('FOOBAR','foobar')
>
> then
>
> request.parameter('FOOBAR')
>
> then you get an empty string,
>> Even if I add  an 'allowed' parameter by hand:
>>
>>> request.setParameter('FI_POINT_TOLERANCE','25')

Actually, QgsServerRequest and QgsServerParameters are high level
classes which are not aware of valid parameters defined in services. For
example, FI_POINT_TOLERANCE is a valid parameter in WMS service, and
defined within the WMS module. But it's totally encapsulated within the
module (a shared library so), and considered as unknown from
QgsServerParameters. The only valid parameters from the
QgsServerParameters point of view are those which are common for all
services (WMS, WFS, and so on) like SERVICE, VERSION, REQUEST, ...

If you want to retrieve the full query from the request without any
filter on valid parameters, you may use request.url(). However, I think
we could probably add a fallback on the `parameter()` method to return
invalid parameters too. I'll do a PR tomorrow and I'll ping you to check
if the behaviour suits you.


Regards,

Paul


On 4/10/19 10:37 PM, David Marteau wrote:
> To add some precision:
>
> Even if I add  an 'allowed' parameter by hand:
>
>> request.setParameter('FI_POINT_TOLERANCE','25')
> then
>
>> request.parameter('FI_POINT_TOLERANCE')
> return an empty string
>
>> Le 10 avr. 2019 à 19:46, David Marteau  a écrit :
>>
>>
>> Hi devs,
>>
>> I found a strange and seemingly inconsistent behavior when accessing 
>> QgsServerRequest parameters:
>>
>> If you try:
>>
>> request.setParameter('FOOBAR','foobar')
>>
>> then
>>
>> request.parameter('FOOBAR')
>>
>> then you get an empty string,
>>
>> If you call
>>
>> request.parameters() 
>>
>> Then your get a dictionary with all the values previously set.
>>
>> At first glance it seems that request.setParameter enforce use of a limited 
>> set of keys (SERVICE…..
>>
>> This does not seem very consistent with the fact parameter() should return 
>> any value previously set with setParameter and also the fact that
>> request.parameters()  return all previously defined  parameters key/values .
>>
>> Furthemore this may be  problematic with plugins that define services in 
>> python and thus may define any other set of allowed parameters.
>>
>> Should I open an issue ?
>>
>> David

___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Re: [QGIS-Developer] QGIS-Server: filter by categories in an OGC compatible way

2019-04-09 Thread pblottiere
Hi Andreas,


> Can you point me to an example how to create a valid GetMap request
with an SLD submitted?


There's a basic example in unit tests:
https://github.com/qgis/QGIS/blob/master/tests/src/python/test_qgsserver_wms_getmap.py#L1309-L1325


Regards,

Paul


On 4/9/19 4:14 PM, Andreas Neumann wrote:
>
> Hi,
>
> I did some test:
>
> Here is a long URL with the SLD (originally sent by QGIS server,
> stripped away some RULES manually) and sending it back in a GetMap
> request:
>
> https://services.geo.zg.ch/ows-oereb/Grundwasserschutz?SERVICE=WMS=1.3.0=GetMap=2682932,1225299,2684213,1226054=EPSG:2056=1615=952=ch.zg.grundwasserschutz.gwszonen==image/png=96_RESOLUTION=96_OPTIONS=dpi:96=TRUE=%3CStyledLayerDescriptor+xmlns%3D%22http%3A%2F%2Fwww.opengis.net%2Fsld%22+xmlns%3Axlink%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxlink%22+xmlns%3Axsi%3D%22http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema-instance%22+xsi%3AschemaLocation%3D%22http%3A%2F%2Fwww.opengis.net%2Fsld+http%3A%2F%2Fschemas.opengis.net%2Fsld%2F1.1.0%2FStyledLayerDescriptor.xsd%22+xmlns%3Ase%3D%22http%3A%2F%2Fwww.opengis.net%2Fse%22+version%3D%221.1.0%22+xmlns%3Aogc%3D%22http%3A%2F%2Fwww.opengis.net%2Fogc%22%3E%0D%0A+%3CNamedLayer%3E%0D%0A++%3Cse%3AName%3Ech.zg.grundwasserschutz.gwszonen%3C%2Fse%3AName%3E%0D%0A++%3CUserStyle%3E%0D%0A+++%3Cse%3AName%3Edefault%3C%2Fse%3AName%3E%0D%0A+++%3Cse%3AFeatureTypeStyle%3E%0D%0A%3Cse%3ARule%3E%0D%0A+%3Cse%3AName%3EGrundwasserschutzzone+S1%3C%2Fse%3AName%3E%0D%0A+%3Cse%3ADescription%3E%0D%0A++%3Cse%3ATitle%3EGrundwasserschutzzone+S1%3C%2Fse%3ATitle%3E%0D%0A+%3C%2Fse%3ADescription%3E%0D%0A+%3Cogc%3AFilter+xmlns%3Aogc%3D%22http%3A%2F%2Fwww.opengis.net%2Fogc%22%3E%0D%0A++%3Cogc%3APropertyIsEqualTo%3E%0D%0A+++%3Cogc%3APropertyName%3Etyp_code%3C%2Fogc%3APropertyName%3E%0D%0A+++%3Cogc%3ALiteral%3ES1%3C%2Fogc%3ALiteral%3E%0D%0A++%3C%2Fogc%3APropertyIsEqualTo%3E%0D%0A+%3C%2Fogc%3AFilter%3E%0D%0A+%3Cse%3APolygonSymbolizer%3E%0D%0A++%3Cse%3AFill%3E%0D%0A+++%3Cse%3ASvgParameter+name%3D%22fill%22%3E%23003bb3%3C%2Fse%3ASvgParameter%3E%0D%0A++%3C%2Fse%3AFill%3E%0D%0A++%3Cse%3AStroke%3E%0D%0A+++%3Cse%3ASvgParameter+name%3D%22stroke%22%3E%2380%3C%2Fse%3ASvgParameter%3E%0D%0A+++%3Cse%3ASvgParameter+name%3D%22stroke-width%22%3E1%3C%2Fse%3ASvgParameter%3E%0D%0A+++%3Cse%3ASvgParameter+name%3D%22stroke-linejoin%22%3Ebevel%3C%2Fse%3ASvgParameter%3E%0D%0A++%3C%2Fse%3AStroke%3E%0D%0A+%3C%2Fse%3APolygonSymbolizer%3E%0D%0A%3C%2Fse%3ARule%3E%0D%0A+++%3C%2Fse%3AFeatureTypeStyle%3E%0D%0A++%3C%2FUserStyle%3E%0D%0A+%3C%2FNamedLayer%3E%0D%0A%3C%2FStyledLayerDescriptor%3E
>
> The response is:
>
> http://www.opengis.net/ogc" version="1.3.0;>
> 
> SLD ('http://www.opengis.net/sld;
> xmlns:xlink="http://www.w3.org/1999/xlink;
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance;
> xsi:schemaLocation="http://www.opengis.net/sld
> http://schemas.opengis.net/sld/1.1.0/StyledLayerDescriptor.xsd;
> xmlns:se="http://www.opengis.net/se; version="1.1.0"
> xmlns:ogc="http://www.opengis.net/ogc;> 
> ch.zg.grundwasserschutz.gwszonen 
> default  
> Grundwasserschutzzone S1 
> Grundwasserschutzzone S1 
> http://www.opengis.net/ogc;>
>  typ_code
> S1  
>name="fill">#003bb3  
> #80
> 1
> bevel
>
>   ') cannot be
> converted into QString
> 
> 
>  
> So apparently the SLD cannot be converted to a QString. Is my encoding
> in the URL above wrong or am I missing a required additional parameter?
>  
> Can you point me to an example how to create a valid GetMap request
> with an SLD submitted?
>  
> Thanks a lot,
> Andreas
>
> On 2019-04-09 15:38, Andreas Neumann wrote:
>
>> Hi,
>>
>> Does QGIS-Server support SLD styles to filter away RULEs in a GetMap
>> Request?
>>
>> I would assume, yes, but in what encoding would I submit such an SLD
>> in a GET request? I know that one should rather use POST reqests for
>> such long parameters, but for experimenting, it would be ok to use GET.
>>
>> The idea would be to allow users to enable/disable categories within
>> a given layer.
>>
>> The WMS client would first request the available rules with a
>> GetStyles command (that part works fine) and would then filter the
>> RULE (strip away the unwanted RULEs) and resubmit the GetMap with an
>> SLD. Does that work with QGIS server?
>>
>> I know that one can also use the FILTER parameter, but we want to do
>> it in an OGC compatible way, since the client being developed should
>> work with any OGC compatible WMS server.
>>
>> Thanks for your reply,
>>
>> Andreas
>>
>>
>> ___
>> QGIS-Developer mailing list
>> QGIS-Developer@lists.osgeo.org 
>> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>
>
>
> ___
> QGIS-Developer mailing list
> QGIS-Developer@lists.osgeo.org
>