[OpenLayers-Users] Like query with "singleChar" does not work correctly in OpenLayers.StyleMap

Ruff, Thomas Thomas.Ruff at solers.com
Mon Apr 27 09:52:06 PDT 2015


Are you sure that no other rule applies?  I've found that when rules' comparison filters are not mutually exclusive the one that gets fired in a particular situation is not easily predictable.  Best to always make sure that only one rule will ever be 'true'.



________________________________
From: openlayers-users-bounces at lists.osgeo.org [openlayers-users-bounces at lists.osgeo.org] on behalf of joaorodr84 [joaorodr84 at gmail.com]
Sent: Monday, April 27, 2015 3:59 AM
To: openlayers-users at lists.osgeo.org
Subject: [OpenLayers-Users] Like query with “singleChar” does not work correctly in OpenLayers.StyleMap

I am working on a GIS API, based on OpenLayers 2.13. I want to represent my
data using WMS and Vector layers.

Recently, I have started developing the support for LIKE queries in filters
and in style maps.

*WMS (green stroke color)*

For WMS layers, the filter is quite simle, as you may know. It must respect
the CQL syntax, for example: `"STATE_NAME LIKE 'N%'"` would match all states
which name starts with an "N".

For the style map, I build a little structure with OpenLayers,
Style/Rule/Filter, I convert it to an SLD BODY using this `var sld = new
OpenLayers.Format.SLD().write(structure)`, and it works fine.

*Vector (default orange fill color)*

As for Vector layers, the filter is an instance of OpenLayers.Filter, which
is easy to build and works fine.

Here come the strange, and maybe tricky, part. for the style map, it does
not work. I build an OpenLayers.StyleMap, using OpenLayers
Style/Rule/Filter, and I get wrong results. What really bothers me is that I
use a given OpenLayers.Filter as filter and it works fine. But when I use
the same instance of OpenLayers.Filter inside a Rule, inside a Style, inside
a StyleMap, I get wrong results.

*...*

The filter expression I am using is:

    var filter = new OpenLayers.Filter.Comparison({
        property: 'STATE_NAME',
        type: OpenLayers.Filter.Comparison.LIKE,
        value: '.....'
    });

It should show states which name has 5 letters (it only does not work for
the style map of the vector layer).

Please check out  this CodePen <<about:blank>https://urldefense.proofpoint.com/v2/url?u=http-3A__codepen.io_joaorodr84_pen_qdErdv&d=BQICAg&c=gpp0UHgwH8jd0f0gRc5QaF0zPfGT1csUQXD9eLov3hQ&r=iiS-4SY2BTp-9WmUwQb3-zEL2tnO_1j_07NMJG-MZ0s&m=yKztGleKJxXFpB9AGFMqsLmYfgmynaVng4ybWtjNkt4&s=bpfuZXMtYI1V9ACCTZmULvikiU8ncMEZB7pqBAa3-Oo&e= >  ,
where I have an example code that can easily be changed. Green contour is
the three states that have 5-letter names. In yellow it shows all the states
with 5 or more letters, which is incorrect)

Thanks a lot



--
View this message in context: https://urldefense.proofpoint.com/v2/url?u=http-3A__osgeo-2Dorg.1560.x6.nabble.com_Like-2Dquery-2Dwith-2DsingleChar-2Ddoes-2Dnot-2Dwork-2Dcorrectly-2Din-2DOpenLayers-2DStyleMap-2Dtp5203061.html&d=BQICAg&c=gpp0UHgwH8jd0f0gRc5QaF0zPfGT1csUQXD9eLov3hQ&r=iiS-4SY2BTp-9WmUwQb3-zEL2tnO_1j_07NMJG-MZ0s&m=yKztGleKJxXFpB9AGFMqsLmYfgmynaVng4ybWtjNkt4&s=iOov9phVHUY7Qbv5B-NJhajFidTZSxZP92076BJdfEw&e=
Sent from the OpenLayers Users mailing list archive at Nabble.com.
_______________________________________________
Users mailing list
Users at lists.osgeo.org
https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.osgeo.org_mailman_listinfo_openlayers-2Dusers&d=BQICAg&c=gpp0UHgwH8jd0f0gRc5QaF0zPfGT1csUQXD9eLov3hQ&r=iiS-4SY2BTp-9WmUwQb3-zEL2tnO_1j_07NMJG-MZ0s&m=yKztGleKJxXFpB9AGFMqsLmYfgmynaVng4ybWtjNkt4&s=TVLCFYvtYBgJsAqFs_scvLIVs--3Ktqw8QBRyhRY8II&e=
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20150427/c93d2dbe/attachment.html>


More information about the Users mailing list