[OpenLayers-Users] HELP!!! How implement Filter in WMS Layer
Arnd Wippermann
arnd.wippermann at web.de
Sat Sep 12 04:27:15 EDT 2009
Hi Andreas,
as you can see in the spec, the parameters layers and styles can be used
together with the sld parameters:
To make the HTTP-GET methods more practical for use, the SLD can also be
used in
one of two different modes depending on whether the LAYERS parameter is
present in
the request. If it is not present, then all layers identified in the SLD
document are
rendered with all defined styles, which is equivalent to the XML-POST method
of usage.
If the LAYERS parameter is present, then only the layers identified by that
parameter are
rendered and the SLD is used as a style library.
When an SLD is used as a style library, the STYLES CGI parameter is
interpreted in the
usual way in the GetMap request, except that the handling of the style names
is
organized so that the styles defined in the SLD take precedence over the
named styles
stored within the map server.
from -
Styled Layer Descriptor profile of the Web Map Service
Implementation Specification
Side 17/18 OGC 05-078r4
I'm always use it in this form with MapServer, to change the style of
specified layers.
Arnd
-----Ursprüngliche Nachricht-----
Von: users-bounces at openlayers.org [mailto:users-bounces at openlayers.org] Im
Auftrag von Andreas Hocevar
Gesendet: Samstag, 12. September 2009 09:21
An: fsalas
Cc: users at openlayers.org
Betreff: Re: [OpenLayers-Users] HELP!!! How implement Filter in WMS Layer
fsalas wrote:
> Andreas, Thanks , but I am beginner and don't have information about
> this topic.
>
> Can you send me illustrative example or information.
>
> I using GeoServer and I like obtain dynamic maps with some condition.
>
> I try with this code but don't change the maps.
>
> ....................
>
> mapa = new OpenLayers.Map('map', options);
>
> // setup tiled layer SLD:
> "http://deltha:8080/SLD/mapa.sld",
>
> faro= new OpenLayers.Layer.WMS(
> "topp:mapacuba - Tiled",
> "http://deltha:8080/geoserver/wms",
> {
> layers: 'topp:faro,
> styles: '',
> height: '300',
> width: '800',
> srs: 'EPSG:4267',
> format: 'image/png',
> tiled: 'true',
> tilesOrigin : "-85.49711392680179,19.65266328193469"
> },
> {buffer: 0}
> );
>
> map.addLayers([faro]);
>
> and after that........
>
> mapa.mergeNewParams({sld:'http://localhost:8080/SLD/faros.sld'});
> mapa.redraw();
This won't work. The WMS request requires *either* LAYERS and STYLES,
*or* just SLD or SLD_BODY. You can have a look at the Sample requests page
in your GeoServer admin frontend. There you will find the following
request:
http://localhost:8080/geoserver/wms?bbox=-130,24,-66,50&Format=image/png&req
uest=GetMap&width=550&height=250&srs=EPSG:4326&SLD_BODY=%3CStyledLayerDescri
ptor%20version%3D%221.0.0%22%3E%3CUserLayer%3E%3CName%3Etopp:states%3C/Name%
3E%3CUserStyle%3E%3CName%3EUserSelection%3C/Name%3E%3CFeatureTypeStyle%3E%3C
Rule%3E%3CFilter%20xmlns:gml%3D%22http://www.opengis.net/gml%22%3E%3CPropert
yIsEqualTo%3E%3CPropertyName%3ESTATE_NAME%3C/PropertyName%3E%3CLiteral%3EIll
inois%3C/Literal%3E%3C/PropertyIsEqualTo%3E%3C/Filter%3E%3CPolygonSymbolizer
%3E%3CFill%3E%3CCssParameter%20name%3D%22fill%22%3E%23FF0000%3C/CssParameter
%3E%3C/Fill%3E%3C/PolygonSymbolizer%3E%3C/Rule%3E%3CRule%3E%3CLineSymbolizer
%3E%3CStroke/%3E%3C/LineSymbolizer%3E%3C/Rule%3E%3C/FeatureTypeStyle%3E%3C/U
serStyle%3E%3C/UserLayer%3E%3C/StyledLayerDescriptor%3E
In your snippet, this would look as follows:
faro= new OpenLayers.Layer.WMS(
"topp:mapacuba - Tiled", "http://deltha:8080/geoserver/wms",
{
//layers: 'topp:faro,
//styles: '',
sld_body:
'%3CStyledLayerDescriptor%20version%3D%221.0.0%22%3E%3CUserLayer%3E%3CName%3
Etopp:faro%3C/Name%3E%3CUserStyle%3E%3CName%3EUserSelection%3C/Name%3E%3CFea
tureTypeStyle%3E%3CRule%3E%3CFilter%20xmlns:gml%3D%22http://www.opengis.net/
gml%22%3E%3CPropertyIsEqualTo%3E%3CPropertyName%3ESTATE_NAME%3C/PropertyName
%3E%3CLiteral%3EIllinois%3C/Literal%3E%3C/PropertyIsEqualTo%3E%3C/Filter%3E%
3CPolygonSymbolizer%3E%3CFill%3E%3CCssParameter%20name%3D%22fill%22%3E%23FF0
000%3C/CssParameter%3E%3C/Fill%3E%3C/PolygonSymbolizer%3E%3C/Rule%3E%3CRule%
3E%3CLineSymbolizer%3E%3CStroke/%3E%3C/LineSymbolizer%3E%3C/Rule%3E%3C/Featu
reTypeStyle%3E%3C/UserStyle%3E%3C/UserLayer%3E%3C/StyledLayerDescriptor%3E',
height: '300',
width: '800',
srs: 'EPSG:4267',
format: 'image/png',
tiled: 'true',
tilesOrigin : "-85.49711392680179,19.65266328193469"
},
{buffer: 0}
);
map.addLayers([faro]);
If you have the contents of sld_body in an external sld file, you just need
to replace sld_body with sld, and the value with the url of the sld file
(from the perspective of your geoserver instance).
Regards,
Andreas.
>
> Best reggards,
> Salas
>
> ----- Original Message ----- From: "Andreas Hocevar"
> <ahocevar at opengeo.org>
> To: "fsalas" <fsalas at geocuba.cu>
> Cc: <users at openlayers.org>
> Sent: Thursday, September 10, 2009 1:42 PM
> Subject: Re: [OpenLayers-Users] HELP!!! How implement Filter in WMS
> Layer
>
>
>> fsalas wrote:
>>>
>>> In this time , I have openlayer 2.8 and be studying the filter.html
>>> example.
>>>
>>> my question is
>>>
>>> 1. ¿ How I can use the WMS Layer with filter?
>>>
>>
>> If you want to do it the OGC way, you have to add a SLD_BODY param
>> with an SLD that contains the filter and the symbology you want.
>>
>> If you are using GeoServer, you can also use the FILTER param directly.
>> In that case, you may want to have a look at the CQL_FILTER param
>> which provides a more compact filter language.
>>
>> Regards,
>> Andreas.
>>
>> --
>> Andreas Hocevar
>> OpenGeo - http://opengeo.org/
>> Expert service straight from the developers.
>>
>>
>
>
> ___________________________________
> Dirección de Comunicaciones
> Grupo Empresarial GEOCUBA
> Este mensaje esta libre de virus. Revisado por Kaspersky Antivirus
> ----------------------------------------------------------------------
> Definition count: 2526893
> Definition date: 9/11/2009
> SecurityPlus version: 3.0.5
>
>
>
--
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.
_______________________________________________
Users mailing list
Users at openlayers.org
http://openlayers.org/mailman/listinfo/users
More information about the Users
mailing list