[OpenLayers-Users] Re: URL Too Long for GetLegendGraphics WMS Get Request

Andreas Hocevar ahocevar at opengeo.org
Mon Feb 20 15:59:47 EST 2012


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 <jd at nijel.org> 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
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users



-- 
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.


More information about the Users mailing list