Search in sources :

Example 1 with InterpolationPointType

use of org.geotoolkit.se.xml.v110.InterpolationPointType in project geotoolkit by Geomatys.

the class GTtoSE110Transformer method visit.

public InterpolateType visit(final Interpolate interpolate) {
    final InterpolateType type = se_factory.createInterpolateType();
    type.setFallbackValue(interpolate.getFallbackValue().toString());
    type.setLookupValue(visitExpression(interpolate.getLookupValue()));
    if (interpolate.getMethod() == Method.COLOR) {
        type.setMethod(MethodType.COLOR);
    } else {
        type.setMethod(MethodType.NUMERIC);
    }
    final Mode mode = interpolate.getMode();
    if (mode == Mode.COSINE) {
        type.setMode(ModeType.COSINE);
    } else if (mode == Mode.CUBIC) {
        type.setMode(ModeType.CUBIC);
    } else {
        type.setMode(ModeType.LINEAR);
    }
    final List<InterpolationPointType> points = type.getInterpolationPoint();
    points.clear();
    for (final InterpolationPoint ip : interpolate.getInterpolationPoints()) {
        final InterpolationPointType point = se_factory.createInterpolationPointType();
        point.setData(ip.getData().doubleValue());
        point.setValue(visitExpression(ip.getValue()));
        points.add(point);
    }
    return type;
}
Also used : InterpolationPoint(org.geotoolkit.style.function.InterpolationPoint) InterpolateType(org.geotoolkit.se.xml.v110.InterpolateType) Mode(org.geotoolkit.style.function.Mode) InterpolationPointType(org.geotoolkit.se.xml.v110.InterpolationPointType)

Example 2 with InterpolationPointType

use of org.geotoolkit.se.xml.v110.InterpolationPointType in project geotoolkit by Geomatys.

the class SE110toGTTransformer method visit.

/**
 *  Transform a SLD v1.1 interpolate function in GT interpolate function.
 */
public Interpolate visit(final InterpolateType interpolate) {
    if (interpolate == null)
        return null;
    final Literal fallback = filterFactory.literal(interpolate.getFallbackValue());
    final Expression lookup = visitExpression(interpolate.getLookupValue());
    final Method method;
    if (MethodType.COLOR.equals(interpolate.getMethod())) {
        method = Method.COLOR;
    } else {
        method = Method.NUMERIC;
    }
    final Mode mode;
    if (ModeType.COSINE.equals(interpolate.getMode())) {
        mode = Mode.COSINE;
    } else if (ModeType.CUBIC.equals(interpolate.getMode())) {
        mode = Mode.CUBIC;
    } else {
        mode = Mode.LINEAR;
    }
    final List<InterpolationPoint> values = new ArrayList<InterpolationPoint>();
    for (final InterpolationPointType ip : interpolate.getInterpolationPoint()) {
        values.add(styleFactory.interpolationPoint(ip.getData(), visitExpression(ip.getValue())));
    }
    return styleFactory.interpolateFunction(lookup, values, method, mode, fallback);
}
Also used : InterpolationPoint(org.geotoolkit.style.function.InterpolationPoint) Expression(org.opengis.filter.Expression) Literal(org.opengis.filter.Literal) Mode(org.geotoolkit.style.function.Mode) InterpolationPointType(org.geotoolkit.se.xml.v110.InterpolationPointType) ArrayList(java.util.ArrayList) Method(org.geotoolkit.style.function.Method) ContrastMethod(org.opengis.style.ContrastMethod)

Aggregations

InterpolationPointType (org.geotoolkit.se.xml.v110.InterpolationPointType)2 InterpolationPoint (org.geotoolkit.style.function.InterpolationPoint)2 Mode (org.geotoolkit.style.function.Mode)2 ArrayList (java.util.ArrayList)1 InterpolateType (org.geotoolkit.se.xml.v110.InterpolateType)1 Method (org.geotoolkit.style.function.Method)1 Expression (org.opengis.filter.Expression)1 Literal (org.opengis.filter.Literal)1 ContrastMethod (org.opengis.style.ContrastMethod)1