[OpenLayers-Users] OpenLayers.Filter.Comparison.LIKE and singleChar

Arnd Wippermann arnd.wippermann at web.de
Thu Aug 5 08:28:33 EDT 2010


Hi Eric,

thanks for the reply and the hint. It's a more complex situation.

It's not a problem with the filter, but with OpenLayers.Format.SLD().read:

I create a SLD and apply it to a vector layer

var formatSLD = new OpenLayers.Format.SLD();
var sld       = formatSLD.read(theSLD_BODY);
...

It works perfect, but only the LIKE-filter with "." works not.

The filterpart from theSLD_BODY for this case looks like

<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
<ogc:PropertyIsLike wildCard="*" singleChar="." escape="!">
<ogc:PropertyName>indice</ogc:PropertyName>
<ogc:Literal>.2</ogc:Literal>
</ogc:PropertyIsLike>
</ogc:Filter>

The ".2" enters the function OpenLayers.Filter.Comparison.value2regex

as 0.2 as number (typeof this.value -> number ?!)

and causes the error "this.value.replace is not a function".

if I overwrite the function by adding this.value=this.value.toString(), then
the error vanishes, but the applied rule to the vector layer doesn't result
in a correct style.

Appling the same SLD to the WMS layer, shows the correct style. It seems,
the SLD is correct.

I remember a case with labels like 02.09, that change to 2.09. Perhaps the
same issue.

If you have any hint, where to further look? 

The little testcode from you was a great help for me to get to the right
error.


And this is still the same:
>>Also I don't understand, why '*2' finds items like 21, 23, 24.

>>>>What would you expect? From the Filter Encoding specs: "The wildCard
character matches zero or more characters".
 
I would expect '2' or 'adadas2', but not '2klkölk'

Many thanks
Arnd


-----Ursprüngliche Nachricht-----
Von: Eric Lemoine [mailto:eric.lemoine at camptocamp.com] 
Gesendet: Donnerstag, 5. August 2010 09:20
An: Arnd Wippermann
Cc: users at openlayers.org
Betreff: Re: [OpenLayers-Users] OpenLayers.Filter.Comparison.LIKE and
singleChar

On Wed, Aug 4, 2010 at 12:28 PM, Arnd Wippermann <arnd.wippermann at web.de>
wrote:
> Hi
>
> Why is it not possible to use '.' (point for singleChar) in a 
> OpenLayers.Filter.Comparison.LIKE?

What do you mean exactly?

>
> The Comparision filter 'like' seems not to work as expected.
> It's not possible to use an expression only with a point for a single 
> char
> (.2) or a static string (22).

Again, I don't understand what you mean.

>>> f = new OpenLayers.Filter.Comparison({type: 
>>> OpenLayers.Filter.Comparison.LIKE, property: "foo", value: ".2"});
>>> f.evaluate({foo: "1"})
false
>>> f.evaluate({foo: "22"})
true
>>> f.evaluate({foo: "12"})
true
>>> f.evaluate({foo: "2"})
false

It looks good to me.


> It causes an error 'this.value.replace is not a function'. It works 
> only in conjunction with '*' (*.2, 22*).

Could you please provide an example.

>
> Also I don't understand, why '*2' finds items like 21, 23, 24.

What would you expect? From the Filter Encoding specs: "The wildCard
character matches zero or more characters".

Cheers,

--
Eric Lemoine

Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex

Tel : 00 33 4 79 44 44 96
Mail : eric.lemoine at camptocamp.com
http://www.camptocamp.com




More information about the Users mailing list