83 | | We can use these tokens in the grammar to implement all of the MapServer supported (via GEOS) logical operators. |
| 85 | We can use these tokens in the grammar to implement all of the MapServer supported (via GEOS) logical operators. Note that in the above example fromText() appears as a function operating on a string. This is handled as a special case when tokenizing the string since we only want to do this once. So we create a shape literal based on the enclosed WKT string at this time. |
| 86 | |
| 87 | '''Extending the grammar to support spatial functions''' |
| 88 | |
| 89 | By supporting the use of more complex objects we can support functions on those objects. We could write: |
| 90 | |
| 91 | {{{ |
| 92 | EXPRESSION (area([shape]) < 100000) |
| 93 | }}} |
| 94 | |
| 95 | or rely on even more of the GEOS operators. (Note: only the area function is present in the sandbox.) To do this we need to somehow store a shapeObj's scope so that working copies can be free'd as appropriate. I would propose adding a ''int scope'' to the shapeObj structure definition. Shapes created in the course of expression evaluation would be tagged as having limited scope while literals or bindings would be left alone and presumably destroyed later. This saves having to make copies of shapes which can be expensive. |
| 96 | |
| 97 | '''Context Sensitive Parsing ''' |
| 98 | |
| 99 | We could have done this all along but this would be an opportune time to implement context sensitive parser use. Presently we expect the parser to produce a true or false result, but certainly aren't limited to that. For example, at the moment you can write: |
| 100 | |
| 101 | {{{ |
| 102 | CLASS |
| 103 | ... |
| 104 | TEXT ([area] acres) |
| 105 | END |
| 106 | }}} |
| 107 | |
| 108 | It looks as if the TEXT value is an expression (and it is stored as such) but it's not evaluated as one. It would be very useful to treat this as a true expression. This would open up a world of formatting options for drivers that don't support it otherwise (e.g. shapefiles). Ticket [http://trac.osgeo.org/mapserver/ticket/2950:2950] |
| 109 | |
| 110 | == Expression Use Elsewhere == |