Search in sources :

Example 1 with StyleFunction

use of uk.me.parabola.mkgmap.osmstyle.function.StyleFunction in project mkgmap by openstreetmap.

the class ExpressionReader method saveFunction.

/**
 * Lookup a function by its name and check that it is allowed for the kind of features that we
 * are reading.
 *
 * @param functionName A name to look up.
 */
private void saveFunction(String functionName) {
    StyleFunction function = FunctionFactory.createFunction(functionName);
    if (function == null)
        throw new SyntaxException(String.format("No function with name '%s()'", functionName));
    // TODO: supportsWay split into supportsPoly{line,gon}, or one function supports(kind)
    boolean supported = false;
    switch(kind) {
        case POINT:
            if (function.supportsNode())
                supported = true;
            break;
        case POLYLINE:
            if (function.supportsWay())
                supported = true;
            break;
        case POLYGON:
            if (function.supportsWay())
                supported = true;
            break;
        case RELATION:
            if (function.supportsRelation())
                supported = true;
            break;
        case ALL:
            if (function.supportsNode() || function.supportsWay() || function.supportsRelation())
                supported = true;
            break;
    }
    if (!supported)
        throw new SyntaxException(String.format("Function '%s()' not supported for %s", functionName, kind));
    stack.push(function);
}
Also used : SyntaxException(uk.me.parabola.mkgmap.scan.SyntaxException) StyleFunction(uk.me.parabola.mkgmap.osmstyle.function.StyleFunction)

Aggregations

StyleFunction (uk.me.parabola.mkgmap.osmstyle.function.StyleFunction)1 SyntaxException (uk.me.parabola.mkgmap.scan.SyntaxException)1