<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.2912" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Hi , </FONT></DIV>
<DIV><FONT size=2><FONT size=3>We have been at work with the filters of layers
and we like tho share the created functions. <FONT size=3>We hoped that help to
them.</FONT></FONT></FONT></DIV>
<DIV><FONT size=2><FONT size=3></FONT></FONT> </DIV>
<DIV><FONT size=2><FONT
size=3>***********************************************************</FONT></FONT></DIV>
<DIV><FONT size=2><FONT face=Arial size=2>//Function for apply filters on WMS
Layers using selecting value, the main objetive of this function is make one sld
and then //apply to point layers, although with some simple modification is
extensive to another layers Ej. Polygon.....
</FONT></FONT></DIV>
<DIV> </DIV><FONT size=2><FONT face=Arial size=2>
<DIV><BR>//***** Function for make one filter of point layer
***********//</DIV>
<DIV> </DIV>
<DIV>function
Crear_PropertyIsEqualTo(pPropertyName,pLiteral)<BR>{<BR> var
PropertyIsEqualTo = '<PropertyIsEqualTo>';<BR>
PropertyIsEqualTo +=
'<PropertyName>'+pPropertyName+'</PropertyName>';<BR>
PropertyIsEqualTo +=
'<Literal>'+pLiteral+'</Literal>';<BR> PropertyIsEqualTo
+= '</PropertyIsEqualTo>';<BR> <BR> return
PropertyIsEqualTo;<BR>} </DIV>
<DIV> </DIV>
<DIV>// this function make one properties for filters </DIV>
<DIV> </DIV>
<DIV>function
Crear_PropertyIsLessThanOrEqualTo(pPropertyName,pLiteral)<BR>{<BR> var
PropertyIsLessThanOrEqualTo =
'<PropertyIsLessThanOrEqualTo>';<BR>
PropertyIsLessThanOrEqualTo +=
'<PropertyName>'+pPropertyName+'</PropertyName>';<BR>
PropertyIsLessThanOrEqualTo +=
'<Literal>'+pLiteral+'</Literal>';<BR> PropertyIsLessThanOrEqualTo
+= '</PropertyIsLessThanOrEqualTo>';<BR> <BR> return
PropertyIsLessThanOrEqualTo;<BR>} </DIV>
<DIV> </DIV>
<DIV>function
Crear_PropertyIsGreaterThanOrEqualTo(pPropertyName,pLiteral)<BR>{<BR> var
PropertyIsGreaterThanOrEqualTo =
'<PropertyIsGreaterThanOrEqualTo>';<BR>
PropertyIsGreaterThanOrEqualTo +=
'<PropertyName>'+pPropertyName+'</PropertyName>';<BR>
PropertyIsGreaterThanOrEqualTo +=
'<Literal>'+pLiteral+'</Literal>';<BR> PropertyIsGreaterThanOrEqualTo
+= '</PropertyIsGreaterThanOrEqualTo>';<BR> <BR> return
PropertyIsGreaterThanOrEqualTo;<BR>} <BR> <BR>// thsi function make
one filters for inside SLD using the propperties list meke before </DIV>
<DIV> </DIV>
<DIV><BR>function Crear_Filter(Lista_Propertys,Cantidad)<BR>{<BR> var
Filter = '<Filter xmlns:gml="<A
href="http://www.opengis.net/gml">'">http://www.opengis.net/gml">'</A>; <BR> <BR>
if(Cantidad == 0)<BR> {<BR> Filter =
'';<BR> } <BR> else if(Cantidad ==
1)<BR> {<BR> Filter +=
Lista_Propertys; <BR> Filter +=
'</Filter>';<BR> }<BR> else
<BR> {<BR> Filter +=
'<And>';<BR> for( var i = 0;i < Cantidad
;i++)<BR> {<BR> Filter +=
Lista_Propertys[i]; <BR> }<BR> Filter +=
'</And>';<BR> Filter += '</Filter>';<BR> }
<BR> <BR> return Filter;<BR>}</DIV>
<DIV> </DIV>
<DIV>// This function return the image name that wil be show in the SLD
simbology </DIV>
<DIV> </DIV>
<DIV>function GetImagen()<BR>{<BR>
if(document.getElementById('tipo_anav').value != "-1")<BR>
{<BR> if(document.getElementById('tipo_anav').value ==
"FV")<BR> return "FV.gif";<BR>
<BR> if(document.getElementById('tipo_anav').value ==
"FA")<BR> return "FA.gif";<BR>
<BR> if(document.getElementById('tipo_anav').value ==
"BY")<BR> return "BY.gif";<BR>
<BR> if(document.getElementById('tipo_anav').value ==
"BZ")<BR> return "BZ.gif";
<BR> <BR>
if(document.getElementById('tipo_anav').value == "ENF")<BR>
return "ENF.gif"; <BR> } <BR>
else<BR> return "FV.gif"; <BR>}<BR> <BR>// This function
create the Rule contained into the SLD </DIV>
<DIV> </DIV>
<DIV><BR>function Crear_Rule(pFilter)<BR>{ <BR> var Rule
='<Rule>';<BR> if(pFilter != '') <BR> Rule +=
pFilter;<BR> Rule
+='<PointSymbolizer><Graphic><ExternalGraphic><OnlineResource
xmlns:xlink="<A
href="http://www.w3.org/1999/xlink">http://www.w3.org/1999/xlink</A>"
xlink:type="simple"
xlink:href="file:/D:/AppServ/www/SIGANAV/images/'+GetImagen()+'"/><Format>image/gif</Format></ExternalGraphic><Opacity><Literal>1.0</Literal></Opacity><Size><Literal>20.0</Literal></Size><Rotation><Literal>0.0</Literal></Rotation></Graphic></PointSymbolizer>';
<BR> Rule +='</Rule>'; <BR> return Rule;
<BR>}<BR> <BR>// This function create the SLD using the rule </DIV>
<DIV> </DIV>
<DIV><BR>function Crear_StyledLayerDescriptor(pRule) <BR>{<BR>
var StyledLayerDescriptor;<BR> StyledLayerDescriptor
='<StyledLayerDescriptor
version="1.0.0"><UserLayer><Name>topp:sennal</Name><UserStyle><Name>UserSelection</Name><FeatureTypeStyle>'+pRule+'</FeatureTypeStyle></UserStyle></UserLayer></StyledLayerDescriptor>';<BR> <BR>
return StyledLayerDescriptor;<BR>}<BR> <BR> <BR>// This function is
one example tha How filter the layer using the selecting elements
<BR> <BR>function FiltrarCapa()<BR>{<BR> var listaPropiedades = new
Array();<BR> var Cant = 0; <BR> <BR>
if(document.getElementById('emp').value != "-1")<BR>
{<BR> listaPropiedades[Cant++] =
Crear_PropertyIsEqualTo('empresa',document.getElementById('emp').value
);<BR> }<BR> if(document.getElementById('est').value !=
"-1")<BR> {<BR> listaPropiedades[Cant++] =
Crear_PropertyIsEqualTo('estacion',document.getElementById('est').value
);<BR> }<BR> if(document.getElementById('tipo_anav').value !=
"-1")<BR> {<BR> listaPropiedades[Cant++] =
Crear_PropertyIsEqualTo('tipo_senal',document.getElementById('tipo_anav').value
);<BR> }</DIV>
<DIV> </DIV>
<DIV> if(document.getElementById('categoria').value != "-1")<BR>
{<BR> listaPropiedades[Cant++] =
Crear_PropertyIsEqualTo('categoria',document.getElementById('categoria').value
);<BR> }<BR> <BR>
if(document.getElementById('ciega').checked == true)<BR>
{<BR> listaPropiedades[Cant++] =
Crear_PropertyIsEqualTo('ciega_luminica','C');<BR> }
<BR> if(document.getElementById('luminica').checked == true)<BR>
{<BR> listaPropiedades[Cant++] =
Crear_PropertyIsEqualTo('ciega_luminica','L');<BR> }
<BR> </DIV>
<DIV> </DIV>
<DIV> if(document.getElementById('sennal_fuera_serv').checked ==
true)<BR> {<BR> var valor =
"true";<BR>listaPropiedades[Cant++] =
Crear_PropertyIsEqualTo('fuera_servicio',valor);<BR> <BR>
if(document.getElementById('fecha_ini').value != "")<BR>
{<BR> listaPropiedades[Cant++] =
Crear_PropertyIsLessThanOrEqualTo('fecha_falla',document.getElementById('fecha_ini').value
);<BR> } </DIV>
<DIV> </DIV>
<DIV>
if(document.getElementById('fecha_fin').value != "")<BR>
{<BR> listaPropiedades[Cant++] =
Crear_PropertyIsGreaterThanOrEqualTo('fecha_falla',document.getElementById('fecha_fin').value
);<BR> }</DIV>
<DIV> </DIV>
<DIV>
if(document.getElementById('tipo_falla').value != "-1")<BR>
{<BR> listaPropiedades[Cant++] =
Crear_PropertyIsEqualTo('tipo_falla',document.getElementById('tipo_falla').value
);<BR> }
<BR> if(document.getElementById('origen_falla').value !=
"-1")<BR> {<BR> listaPropiedades[Cant++] =
Crear_PropertyIsEqualTo('origen_falla',document.getElementById('origen_falla').value
);<BR> } <BR> <BR> }<BR>
<BR> if(document.getElementById('mant_plan').checked == true)<BR>
{<BR>
if(document.getElementById('fecha_ini').value != "-1")<BR>
{<BR> listaPropiedades[Cant++] =
Crear_PropertyIsLessThanOrEqualTo('fecha_mant_planificado',document.getElementById('fecha_ini').value
);<BR> } </DIV>
<DIV> </DIV>
<DIV>
if(document.getElementById('fecha_fin').value != "-1")<BR>
{<BR> listaPropiedades[Cant++] =
Crear_PropertyIsGreaterThanOrEqualTo('fecha_mant_planificado',document.getElementById('fecha_fin').value
);<BR> }</DIV>
<DIV> </DIV>
<DIV>
if(document.getElementById('tipo_mant').value != "-1")<BR>
{<BR> listaPropiedades[Cant++] =
Crear_PropertyIsEqualTo('tipo_mant_realizado',document.getElementById('tipo_mant').value
);<BR> } <BR> }<BR>
if(document.getElementById('mant_ejec').checked == true)<BR>
{<BR>
if(document.getElementById('fecha_ini').value != "-1")<BR>
{<BR> listaPropiedades[Cant++] =
Crear_PropertyIsLessThanOrEqualTo('fecha_mant_realizado',document.getElementById('fecha_ini').value
);<BR> } </DIV>
<DIV> </DIV>
<DIV>
if(document.getElementById('fecha_fin').value != "-1")<BR>
{<BR> listaPropiedades[Cant++] =
Crear_PropertyIsGreaterThanOrEqualTo('fecha_mant_realizado',document.getElementById('fecha_fin').value
);<BR> }</DIV>
<DIV> </DIV>
<DIV>
if(document.getElementById('tipo_mant').value != "-1")<BR>
{<BR> listaPropiedades[Cant++] =
Crear_PropertyIsEqualTo('tipo_mant_realizado',document.getElementById('tipo_mant').value
);<BR> } <BR>
}<BR>//********************** Example of Call this
functions ************************//</DIV>
<DIV> </DIV>
<DIV> var Filtro =
Crear_Filter(listaPropiedades,Cant);<BR> var Regla =
Crear_Rule(Filtro);<BR> var StyledLayerDescriptor =
Crear_StyledLayerDescriptor(Regla); <BR>
map.layers[2].mergeNewParams({SLD_BODY:StyledLayerDescriptor});
<BR>} </FONT></FONT></DIV>
<DIV><FONT size=2><FONT face=Arial size=2></FONT></FONT> </DIV>
<DIV><FONT size=2><FONT
size=3>************************************************************</FONT></FONT></DIV>
<DIV><FONT face=Arial size=2><FONT size=2>
<P>Best Regards , Salas</P>
<P> </P></FONT></FONT></DIV>
<DIV><FONT size=2><FONT face=Arial size=2></FONT></FONT> </DIV>
<DIV><FONT size=2><FONT size=3></FONT> </DIV></FONT></BODY></HTML>