114 | | Which converts area from sq. meters to acres, truncates the result to two decimal places adds commas (213234.123455 => 213,234.12) for crowd pleasing display. |
| 114 | Which converts area from sq. meters to acres, truncates the result to two decimal places adds commas (213234.123455 => 213,234.12) for crowd pleasing display. To add this support, in addition to grammar changes, we add these declarations to mapserver.h: |
| 115 | |
| 116 | {{{ |
| 117 | enum MS_PARSE_RESULT_TYPE_ENUM { MS_PARSE_RESULT_BOOLEAN, MS_PARSE_RESULT_STRING, MS_PARSE_RESULT_SHAPE }; |
| 118 | |
| 119 | typedef union { |
| 120 | int intval; |
| 121 | char *strval; |
| 122 | shapeObj *shpval; |
| 123 | } parseResultObj; |
| 124 | }}} |
| 125 | |
| 126 | Then in the grammar we set a parse result type and set the result accordingly. One side effect is that we have to define a standard way to convert numbers to strings when in the string context and simply using "%g" as a format string for snprintf does wonders to output. |
| 127 | |
| 128 | We can also extend the parser to output shapeObj's and I could see this manifesting itself via the GEOMTRANSFORM mechanism already in place. It would be relatively easy to add many of the GEOS supported operators to the grammar and expose them this way. Buffering would be an obvious candidate. |
| 129 | |
| 130 | == Expression Use Elsewhere == |