Search in sources :

Example 1 with ParameterValueType

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

the class GTtoSE100Transformer method visitExpression.

/**
 * Transform a GT Expression in a jaxb parameter value type.
 */
public ParameterValueType visitExpression(final Expression exp) {
    final JAXBElement<?> ele = extract(exp);
    if (ele == null) {
        return null;
    } else {
        final ParameterValueType param = sld_factory_v100.createParameterValueType();
        param.getContent().add(extract(exp));
        return param;
    }
}
Also used : ParameterValueType(org.geotoolkit.sld.xml.v100.ParameterValueType)

Example 2 with ParameterValueType

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

the class SLD110Test method testUnitTranscription.

@Test
public void testUnitTranscription() {
    final SE110toGTTransformer se2gt = new SE110toGTTransformer(FILTER_FACTORY, STYLE_FACTORY);
    final GTtoSE110Transformer gt2se = new GTtoSE110Transformer();
    final TextSymbolizerType textSymbol = new TextSymbolizerType();
    final ParameterValueType labelType = new ParameterValueType();
    labelType.getContent().add("label");
    textSymbol.setLabel(labelType);
    textSymbol.setUom("km");
    TextSymbolizer transcriptedText = se2gt.visit(textSymbol);
    assertEquals("Converted unit of measure", Units.KILOMETRE, transcriptedText.getUnitOfMeasure());
    TextSymbolizerType revertedSymbol = gt2se.visit(transcriptedText, null).getValue();
    assertEquals("Reverted unit of measure", "km", revertedSymbol.getUom());
    textSymbol.setUom(null);
    transcriptedText = se2gt.visit(textSymbol);
    assertEquals("Converted unit of measure", Units.POINT, transcriptedText.getUnitOfMeasure());
    revertedSymbol = gt2se.visit(transcriptedText, null).getValue();
    assertEquals("Reverted unit of measure", "http://www.opengeospatial.org/se/units/pixel", revertedSymbol.getUom());
    textSymbol.setUom("px");
    transcriptedText = se2gt.visit(textSymbol);
    assertEquals("Converted unit of measure", Units.POINT, transcriptedText.getUnitOfMeasure());
    revertedSymbol = gt2se.visit(transcriptedText, null).getValue();
    assertEquals("Reverted unit of measure", "http://www.opengeospatial.org/se/units/pixel", revertedSymbol.getUom());
    textSymbol.setUom("meter");
    transcriptedText = se2gt.visit(textSymbol);
    assertEquals("Converted unit of measure", Units.METRE, transcriptedText.getUnitOfMeasure());
    revertedSymbol = gt2se.visit(transcriptedText, null).getValue();
    assertEquals("Reverted unit of measure", "http://www.opengeospatial.org/se/units/metre", revertedSymbol.getUom());
}
Also used : SE110toGTTransformer(org.geotoolkit.sld.xml.SE110toGTTransformer) TextSymbolizer(org.opengis.style.TextSymbolizer) TextSymbolizerType(org.geotoolkit.se.xml.v110.TextSymbolizerType) ParameterValueType(org.geotoolkit.se.xml.v110.ParameterValueType) GTtoSE110Transformer(org.geotoolkit.sld.xml.GTtoSE110Transformer) Test(org.junit.Test)

Example 3 with ParameterValueType

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

the class GTtoSE110Transformer method visitExpression.

/**
 * Transform a GT Expression in a jaxb parameter value type.
 */
public ParameterValueType visitExpression(final Expression exp) {
    if (exp == null)
        return null;
    final JAXBElement<?> ele = extract(exp);
    if (ele == null) {
        return null;
    } else {
        final ParameterValueType param = se_factory.createParameterValueType();
        param.getContent().add(extract(exp));
        return param;
    }
}
Also used : ParameterValueType(org.geotoolkit.se.xml.v110.ParameterValueType)

Example 4 with ParameterValueType

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

the class GTtoSE110Transformer method visit.

public CategorizeType visit(final Categorize categorize) {
    final CategorizeType type = se_factory.createCategorizeType();
    type.setFallbackValue(categorize.getFallbackValue().getValue().toString());
    type.setLookupValue(visitExpression(categorize.getLookupValue()));
    if (ThreshholdsBelongTo.PRECEDING == categorize.getBelongTo()) {
        type.setThreshholdsBelongTo(ThreshholdsBelongToType.PRECEDING);
    } else {
        type.setThreshholdsBelongTo(ThreshholdsBelongToType.SUCCEEDING);
    }
    final Map<Expression, Expression> steps = categorize.getThresholds();
    final List<JAXBElement<ParameterValueType>> elements = type.getThresholdAndTValue();
    elements.clear();
    int i = 0;
    for (Entry<Expression, Expression> entry : steps.entrySet()) {
        final Expression key = entry.getKey();
        final Expression val = entry.getValue();
        if (i == 0) {
            // first element is for -infinity
            type.setValue(visitExpression(val));
        } else {
            elements.add(se_factory.createThreshold(visitExpression(key)));
            elements.add(se_factory.createTValue(visitExpression(val)));
        }
        i++;
    }
    return type;
}
Also used : Expression(org.opengis.filter.Expression) JAXBElement(javax.xml.bind.JAXBElement) CategorizeType(org.geotoolkit.se.xml.v110.CategorizeType) AnchorPoint(org.opengis.style.AnchorPoint) InterpolationPoint(org.geotoolkit.style.function.InterpolationPoint)

Aggregations

ParameterValueType (org.geotoolkit.se.xml.v110.ParameterValueType)2 JAXBElement (javax.xml.bind.JAXBElement)1 CategorizeType (org.geotoolkit.se.xml.v110.CategorizeType)1 TextSymbolizerType (org.geotoolkit.se.xml.v110.TextSymbolizerType)1 GTtoSE110Transformer (org.geotoolkit.sld.xml.GTtoSE110Transformer)1 SE110toGTTransformer (org.geotoolkit.sld.xml.SE110toGTTransformer)1 ParameterValueType (org.geotoolkit.sld.xml.v100.ParameterValueType)1 InterpolationPoint (org.geotoolkit.style.function.InterpolationPoint)1 Test (org.junit.Test)1 Expression (org.opengis.filter.Expression)1 AnchorPoint (org.opengis.style.AnchorPoint)1 TextSymbolizer (org.opengis.style.TextSymbolizer)1