Commit Graph

800 Commits

Author SHA1 Message Date
Bart van den Eijnden
ab40ab6208 Add parser for OGC Filter 1.0 and 1.1 (read/write)
This work is based on the ol.expr package by @tschaub.
It adds a few named expression functions to that package:

 * INTERSECTS, CONTAINS, DWITHIN, WITHIN (no client-side implementation as yet)
 * LIKE (like comparison with wildcard, singleChar and escapeChar)
 * IEQ (case-insensitive equality)
 * INEQ (case-insensitive non-equality)

It also adds a few extra parameters to the existing EXTENT function to be able
to deserialize and serialize all info (i.e. projection and property name).

Some changes were needed for the GML parser as well:

 * createGeometry function needed to be public
 * when parsing Box (GML2) and Envelope (GML3) also parse the srsName
 * fix up writing for Box and Envelope now that bounds is an array

Also added createDocumentFragment function to the XML parser. Implementation
is similar to OpenLayers 2.

Some addtional notes on the implementation:

 * PropertyIsBetween was implemented as an ol.expr.Logical with operator
   ol.expr.LogicalOp.AND and two ol.expr.Comparison instances with operator
   ol.expr.ComparisonOp.GTE and ol.expr.ComparisonOp.LTE
 * In OGC Filter And and Or can contain more than 2 sub filters, so this
   is translated into a hierarchy of ol.expr.Logical
2013-07-03 13:09:25 +02:00
Tim Schaub
fa4d2d485d Merge pull request #829 from tschaub/kml
Parse MultiGeometry in KML
2013-06-27 06:35:50 -07:00
Frédéric Junod
07d790260c Merge pull request #690 from fredj/layer-options
ol.layer.Layer: default values
2013-06-27 04:35:02 -07:00
Tim Schaub
42aa94de21 KML MultiGeometry may contain other MultiGeometry
As demonstrated in the tests, a MultiGeometry may contain other MultiGeometry nodes.  We can support this with heterogenous GeometryCollection instances - though these are not currently rendered.
2013-06-26 12:31:08 -06:00
Tim Schaub
4e5ef05e5e Expression for evaluating feature ids 2013-06-25 12:15:34 -06:00
Tim Schaub
70fef73869 Testing operator precedence 2013-06-25 12:15:34 -06:00
Tim Schaub
c81057780a More tests for binary operators 2013-06-25 12:15:34 -06:00
Tim Schaub
1f23a245e4 More tests for unary expression 2013-06-25 12:15:34 -06:00
Tim Schaub
2577d3f7d6 Rename ol.expression to ol.expr 2013-06-25 12:15:34 -06:00
Tim Schaub
9928730bd3 Tests for ol.expression.register() 2013-06-25 12:15:33 -06:00
Tim Schaub
b04a36ede7 Replace use of filter with expressions
The canvas vector layer still has the (API candidate) `getFeatures` method that accepts an arbitrary expression (was filter).  This, and the `getFeaturesObject` method under it are only used in the tests.  The rendering code that was using filters is now calling `layer.getFeaturesObjectForExtent` with an explicit extent and optional geometry type.
2013-06-25 12:15:33 -06:00
Tim Schaub
a663d8fcae Accept an expression string for rule filter 2013-06-25 12:11:50 -06:00
Tim Schaub
38b784d672 Support +/- unary operators for literals 2013-06-25 12:11:50 -06:00
Tim Schaub
d70a9eba01 Lib for well-known functions
This reveals a lexer bug that needs addressing.
2013-06-25 12:11:50 -06:00
Tim Schaub
bd5d9d572e Lint 2013-06-25 12:11:50 -06:00
Tim Schaub
5e309e244b Using ol.expression.parse 2013-06-25 12:11:50 -06:00
Tim Schaub
72d32ec71a Correct index for tokens 2013-06-25 12:11:50 -06:00
Tim Schaub
f0567f5053 Expect the unexpected 2013-06-25 12:11:49 -06:00
Tim Schaub
62eb0dd72b Give token an index and throw unexpected token from a common place 2013-06-25 12:11:49 -06:00
Tim Schaub
bb1b0cba95 Getter for not expression argument 2013-06-25 12:11:49 -06:00
Tim Schaub
c05fb8c61b Getters for member expression properties 2013-06-25 12:11:49 -06:00
Tim Schaub
2528581642 Getters for math expression properties 2013-06-25 12:11:49 -06:00
Tim Schaub
4a617871da Getters for logical expression properties 2013-06-25 12:11:49 -06:00
Tim Schaub
3de330eb99 Getter for literal expression value 2013-06-25 12:11:49 -06:00
Tim Schaub
6d6ec357e1 Getter for identifier expression name 2013-06-25 12:11:48 -06:00
Tim Schaub
582a52849c Getters for comparison expression properties 2013-06-25 12:11:48 -06:00
Tim Schaub
be636d7f46 Getters for call expression properties 2013-06-25 12:11:48 -06:00
Tim Schaub
6458f98996 Describing the extent of support for ES-5 expressions 2013-06-25 12:11:48 -06:00
Tim Schaub
2fd8f4cb00 Integration testing for binary logical operators 2013-06-25 12:11:48 -06:00
Tim Schaub
973606e67a Integration tests for equality operators 2013-06-25 12:11:48 -06:00
Tim Schaub
3a3f9bc20b Integration testing for relational operators
No `instanceof` or `in` operator support.
2013-06-25 12:11:47 -06:00
Tim Schaub
9d5424236c Integration testing for additive operators 2013-06-25 12:11:47 -06:00
Tim Schaub
7c2550fefa Integration testing for multiplicative operators 2013-06-25 12:11:47 -06:00
Tim Schaub
2492515e8f Integration testing for unary operators
Only supporting ! at the moment.
2013-06-25 12:11:47 -06:00
Tim Schaub
e6f03c8f22 Confirm whitespace is consumed as expected 2013-06-25 12:11:47 -06:00
Tim Schaub
26a7d907a2 Test unary expression parsing 2013-06-25 12:11:47 -06:00
Tim Schaub
a0bd736948 Left-hand-side expression parsing 2013-06-25 12:11:47 -06:00
Tim Schaub
803b3a3f7d Binary expression parsing 2013-06-25 12:11:46 -06:00
Tim Schaub
40b12410f0 Increment after scanning >= and <= (and expect EOF in tests) 2013-06-25 12:11:46 -06:00
Tim Schaub
379ac82688 Test argument parsing 2013-06-25 12:11:46 -06:00
Tim Schaub
6d0badcf2a Optional scope (works for expressions without identifiers) 2013-06-25 12:11:46 -06:00
Tim Schaub
d920d8e578 Test left-hand-side expression parsing 2013-06-25 12:11:46 -06:00
Tim Schaub
13d0b8b084 Provide ol.expression.parse method
This is the only method needed in the API.
2013-06-25 12:11:46 -06:00
Tim Schaub
3643ea164f Cast boolean and null before creating literal expression 2013-06-25 12:11:46 -06:00
Tim Schaub
ce67aa2617 Make way for convenience functions in ol.expression package 2013-06-25 12:11:45 -06:00
Tim Schaub
7a1e69e288 Initial parsing tests 2013-06-25 12:11:45 -06:00
Tim Schaub
cb9725bdfb Provide static method to check for valid operators 2013-06-25 12:11:45 -06:00
Tim Schaub
29b77a2dac Member expressions 2013-06-25 12:11:45 -06:00
Tim Schaub
fbb028e15e Call expressions 2013-06-25 12:11:45 -06:00
Tim Schaub
f050546fe2 Logical expressions 2013-06-25 12:11:44 -06:00