Quantcast

URL Too Long for GetLegendGraphics WMS Get Request

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

URL Too Long for GetLegendGraphics WMS Get Request

jdgodchaux
Hello,

I'm using OpenLayers, GeoExt and Geoserver to create a simple map with a MapPanel, LegendPanel, and LayerTree. I'm using a standard OpenLayers.Layer.WMS instance to add a new layer to this map and I'm applying several filters to this layer to only display a small number features. With a large number of filters applied, the GetMap request URL is too long for a GET request, so I've applied tileOptions: {maxGetUrlLength: 2048} in the OpenLayers.Layer.WMS instance and the system is now using POST with no problems. My data appear on the map pane filtered and styled as I've requested (I've set the style through Geoserver; sld in the Geoserver data directory).

The problem I'm running into now is that while the GetMap request is using POST, the GetLegendGraphics request to populate the legend is still using GET and the URL is way to long for a GET request. Does anyone know of a way in OpenLayers/GeoExt to shorten GetLegendGraphics request URL? Is there some way to remove the filters from the GetLegendGraphics request and still keep them in the GetMap request?

I did see a somewhat related post here (http://osgeo-org.1560.n6.nabble.com/mergeNewParams-Legend-td3926069.html). Here Andreas suggested to "reconfigure the legend type selection sequence, so a VectorLegend rather than a WMSLegend is created," but I couldn't really translate how to implement the solution Andreas provided.

Many thanks in advance!!
JD

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: URL Too Long for GetLegendGraphics WMS Get Request

Andreas Hocevar-2
Hi,

with "reconfigure the legend type selection sequence", I meant that
you should configure your LegendPanel with

preferredTypes: ["gx_vectorlegend"]

In addition to that, the legend for your layer needs to be configured
with the rules of your SLD. So whenever you update your filter, you
have to do something like

legendPanel.items.each(function(cmp) {
    if (cmp.getXType() == "gx_vectorlegend") {
        cmp.rules = mySldRules;
        cmp.update();
    }
});

This is untested, but I hope it's enough for you to get the picture.

Andreas.

On Sat, Feb 18, 2012 at 12:46 AM, jdgodchaux <[hidden email]> wrote:

> Hello,
>
> I'm using OpenLayers, GeoExt and Geoserver to create a simple map with a
> MapPanel, LegendPanel, and LayerTree. I'm using a standard
> OpenLayers.Layer.WMS instance to add a new layer to this map and I'm
> applying several filters to this layer to only display a small number
> features. With a large number of filters applied, the GetMap request URL is
> too long for a GET request, so I've applied tileOptions: {maxGetUrlLength:
> 2048} in the OpenLayers.Layer.WMS instance and the system is now using POST
> with no problems. My data appear on the map pane filtered and styled as I've
> requested (I've set the style through Geoserver; sld in the Geoserver data
> directory).
>
> The problem I'm running into now is that while the GetMap request is using
> POST, the GetLegendGraphics request to populate the legend is still using
> GET and the URL is way to long for a GET request. Does anyone know of a way
> in OpenLayers/GeoExt to shorten GetLegendGraphics request URL? Is there some
> way to remove the filters from the GetLegendGraphics request and still keep
> them in the GetMap request?
>
> I did see a somewhat related post here
> (http://osgeo-org.1560.n6.nabble.com/mergeNewParams-Legend-td3926069.html).
> Here Andreas suggested to "reconfigure the legend type selection sequence,
> so a VectorLegend rather than a WMSLegend is created," but I couldn't really
> translate how to implement the solution Andreas provided.
>
> Many thanks in advance!!
> JD
>
>
>
> --
> View this message in context: http://osgeo-org.1560.n6.nabble.com/URL-Too-Long-for-GetLegendGraphics-WMS-Get-Request-tp4481884p4481884.html
> Sent from the OpenLayers Users mailing list archive at Nabble.com.
> _______________________________________________
> Users mailing list
> [hidden email]
> http://lists.osgeo.org/mailman/listinfo/openlayers-users



--
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.
_______________________________________________
Users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: URL Too Long for GetLegendGraphics WMS Get Request

jdgodchaux
Hi Andreas,

Thanks very much for your response! I'm new at using GeoExt, so I'm not quite following your response. I've added preferredTypes: ["gx_vectorlegend"] to my LegendPanel, but the SLD I'm using to style my filtered layers is called from the  Geoserver data directory. I'm not dynamically rewriting my SLD rules each time I'm applying new filter to the layer. I'm creating (much longer) filters like the following:

                filter_program_1 = new OpenLayers.Filter.Logical({
                    type: OpenLayers.Filter.Logical.OR,
                    filters: [
               
                                        new OpenLayers.Filter.Comparison({
                                            type: OpenLayers.Filter.Comparison.EQUAL_TO,
                                            property: "programnumber",
                                            value: "2311"
                                        }),
                                        new OpenLayers.Filter.Comparison({
                                            type: OpenLayers.Filter.Comparison.EQUAL_TO,
                                            property: "programnumber",
                                            value: "2451"
                                        })
                            ]
                        });

And then creating a variable for each WMS layer like the following:

                var program_1 = new OpenLayers.Layer.WMS("First Layer of Programs",
                        "geoserverwmsurl",
                                {'layers': 'programworkspace:programs',
                                transparent: true, tiled: true,
                                format: 'image/png',
                                filter: xml.write(filter_1_1.write(filter_program_1)),
                                styles: 'program_type'
                                },
                        {isBaseLayer: false, visibility: true, tileOptions: {maxGetUrlLength: 2048}}
                );


GeoExt pushes the same URL to geoserver for GetMap and GetLegendType, but I'm wondering if there's a way to force GeoExt to request a VectorLegend when the URL is longer than the GET request can handle. Does anyone know if that's possible? has anyone done something like this before?

Thanks again!
JD


 
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: URL Too Long for GetLegendGraphics WMS Get Request

Andreas Hocevar-2
Oh, I just realized we're on the OpenLayers list here. But I also have
an answer to you that fits here.

Looking at your filter and given the fact that your WMS is GeoServer,
why don't you use the much shorter CQL Filters? Instead of

filter: xml.write(filter_program_1),

you can configure

cql_filter: new OpenLayers.Format.CQL().write(filter_program_1)

This would result in

cql_filter: "(programnumber=2311) OR (programnumber=2451)"

Creating the cql filter string directly, you could make it even shorter:

cql_filter: "programnumber in (2311,2451)"

Obviously with such a filter you don't need POST requests at all.

Andreas.

On Mon, Feb 20, 2012 at 7:52 PM, jdgodchaux <[hidden email]> wrote:

> Hi Andreas,
>
> Thanks very much for your response! I'm new at using GeoExt, so I'm not
> quite following your response. I've added preferredTypes:
> ["gx_vectorlegend"] to my LegendPanel, but the SLD I'm using to style my
> filtered layers is called from the  Geoserver data directory. I'm not
> dynamically rewriting my SLD rules each time I'm applying new filter to the
> layer. I'm creating (much longer) filters like the following:
>
>                filter_program_1 = new OpenLayers.Filter.Logical({
>                    type: OpenLayers.Filter.Logical.OR,
>                    filters: [
>
>                                        new OpenLayers.Filter.Comparison({
>                                            type:
> OpenLayers.Filter.Comparison.EQUAL_TO,
>                                            property: "programnumber",
>                                            value: "2311"
>                                        }),
>                                        new OpenLayers.Filter.Comparison({
>                                            type:
> OpenLayers.Filter.Comparison.EQUAL_TO,
>                                            property: "programnumber",
>                                            value: "2451"
>                                        })
>                            ]
>                        });
>
> And then creating a variable for each WMS layer like the following:
>
>                var program_1 = new OpenLayers.Layer.WMS("First Layer of
> Programs",
>                        "geoserverwmsurl",
>                                {'layers': 'programworkspace:programs',
>                                transparent: true, tiled: true,
>                                format: 'image/png',
>                                filter:
> xml.write(filter_1_1.write(filter_program_1)),
>                                styles: 'program_type'
>                                },
>                        {isBaseLayer: false, visibility: true, tileOptions:
> {maxGetUrlLength: 2048}}
>                );
>
>
> GeoExt pushes the same URL to geoserver for GetMap and GetLegendType, but
> I'm wondering if there's a way to force GeoExt to request a VectorLegend
> when the URL is longer than the GET request can handle. Does anyone know if
> that's possible? has anyone done something like this before?
>
> Thanks again!
> JD
>
>
>
>
> --
> View this message in context: http://osgeo-org.1560.n6.nabble.com/URL-Too-Long-for-GetLegendGraphics-WMS-Get-Request-tp4481884p4488506.html
> Sent from the OpenLayers Users mailing list archive at Nabble.com.
> _______________________________________________
> Users mailing list
> [hidden email]
> http://lists.osgeo.org/mailman/listinfo/openlayers-users



--
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.
_______________________________________________
Users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: URL Too Long for GetLegendGraphics WMS Get Request

jdgodchaux
Thanks Andreas! This worked perfectly.
Loading...