Map calculation
Algorithm
Your map calculation formula is processed in the following simplified way:
- Tokenizer:
- breaks the expression into tokens such as special characters (e.g. brackets, commas, +, *, /, <, >, =), composed tokens (e.g. <=, lt, >=, gt), strings, and values,
- feeds the result to the parser.
- Parser:
- performs a simple syntax check on the tokens, for instance a check on the correct number of brackets,
- translates the tokens into map names, tables names, column names, constants, operators (+, *), functions, variables, brackets, etc.
- feeds the result to code generator.
- Code generator:
- performs an indepth syntax check, for instance a check on the number and type of parameters for all functions and operators used,
- determines the output domain, value range and georeference,
- creates an instruction stack.
- Calculator:
- for each line of the maps carries out all instructions on the stack.
For effiency reasons, the process is done line by line. This has the same result as when the instructions were carried out pixel by pixel.
Example 1:
OUTMAP = a+1
Stack contains following instructions:
load a
const 1
operator add
store
Example 2:
OUTMAP = (a+1) * (b+2)
Stack contains following instructions:
load a
const 1
operator add
load b
const 2
operator add
operator multiply
store
Example 3:
OUTMAP = iff(landuse="arable") and (slope<=20), "suitable", "not suitable")
Stack contains following instructions:
load landuse
const "arable"
equal
load slope
const 20
less than or equal
and
const "suitable"
const "not suitable"
call iff
store
See also:
Map Calculation