[OpenLayers-Users] Filter evaluates only string values

Andreas Hocevar ahocevar at opengeo.org
Wed Apr 21 09:17:03 EDT 2010


Hi,

On Apr 21, 2010, at 15:02 , sasamil wrote:

> 
> Hallo All,
> 
> this piece of code (filter) evaluates only string values??!
> 
> var strFilter =
> '<ogc:Filter
> xmlns:ogc="http://www.opengis.net/ogc"><ogc:PropertyIsGreaterThan><ogc:PropertyName>numberOfCitizens</ogc:PropertyName><ogc:Literal>'+value+'</ogc:Literal></ogc:PropertyIsGreaterThan></ogc:Filter>';
> 
> var wfsurl =
> "http://localhost:81/ogc/cities.phpSERVICE=WFS&VERSION=1.0.0&SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=mycities&FILTER="
> + strFilter;
> 
> OpenLayers.loadURL(wfsurl, "", null, highlight_received_features);

The above code has nothing to do with OpenLayers - you create an XML filter as string, and it gets processed by your server.

> So, I get the surprising results; the (highlighted) town with 7500
> inhabitats IS GREATER THAN the city of 10000 inhabitants!?
> 
> It is obvious that the filter evaluates only string values. If I change the
> value 7500 to 07500 (in my gml input file), I get the correct results.
> 
> How can I overcome this problem?

* Check if the numberOfCitizens field on your server is a numeric field
* Ask the support of your server if you still have problems

> How can I say to my filter - "compare numbers not strings"?

Usually this is determined by the type of the field you use the filter on.

Regards,
Andreas.

> 
> Regards!
> 
> -- 
> View this message in context: http://n2.nabble.com/Filter-evaluates-only-string-values-tp4936788p4936788.html
> Sent from the OpenLayers Users mailing list archive at Nabble.com.
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users



-- 
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.




More information about the Users mailing list