[OpenLayers-Users] Like query with “singleChar” does not work correctly in OpenLayers.StyleMap
joaorodr84
joaorodr84 at gmail.com
Mon Apr 27 03:59:43 PDT 2015
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 <http://codepen.io/joaorodr84/pen/qdErdv> ,
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: http://osgeo-org.1560.x6.nabble.com/Like-query-with-singleChar-does-not-work-correctly-in-OpenLayers-StyleMap-tp5203061.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
More information about the Users
mailing list