Search in sources :

Example 11 with FunctionName

use of org.opengis.filter.capability.FunctionName in project sldeditor by robward-scisys.

the class FunctionManager method getFunctionNameList.

/**
 * Gets the function name list for the given parameter type A
 * expectedType of null returns all functions.
 *
 * @param expectedType the expected type, restrict functions with this return type
 * @param functionNameFilterList the function name filter list
 * @return the function name list
 */
@Override
public List<FunctionName> getFunctionNameList(Class<?> expectedType, List<FunctionNameFilterInterface> functionNameFilterList) {
    if (expectedType == null) {
        return functionNameList;
    }
    if (functionNameFilterList == null) {
        functionNameFilterList = new ArrayList<FunctionNameFilterInterface>();
        functionNameFilterList.add(new FunctionNameFilterAll());
    }
    List<FunctionName> list = new ArrayList<FunctionName>();
    List<Class<?>> allowedTypes = allowedTypeMap.get(expectedType);
    if (allowedTypes != null) {
        for (FunctionName functionName : functionNameList) {
            Class<?> returnType = functionName.getReturn().getType();
            if (allowedTypes.contains(returnType) && matchesFilter(functionName, functionNameFilterList)) {
                list.add(functionName);
            }
        }
    }
    return list;
}
Also used : FunctionName(org.opengis.filter.capability.FunctionName) FunctionNameFilterAll(com.sldeditor.filter.v2.function.namefilter.FunctionNameFilterAll) FunctionNameFilterInterface(com.sldeditor.filter.v2.function.namefilter.FunctionNameFilterInterface) ArrayList(java.util.ArrayList)

Example 12 with FunctionName

use of org.opengis.filter.capability.FunctionName in project sldeditor by robward-scisys.

the class DefaultSymbols method createArrow.

/**
 * Creates the arrow.
 *
 * @return the point symbolizer containing the arrow
 */
public static PointSymbolizer createArrow(boolean isSourceArrow) {
    FunctionName angleFunction = null;
    FunctionName locationFunction = null;
    if (isSourceArrow) {
        angleFunction = FilterFunction_startAngle.NAME;
        locationFunction = FilterFunction_startPoint.NAME;
    } else {
        angleFunction = FilterFunction_endAngle.NAME;
        locationFunction = FilterFunction_endPoint.NAME;
    }
    return createArrow(angleFunction, locationFunction, DEFAULT_ARROW_SYMBOL, isSourceArrow);
}
Also used : FunctionName(org.opengis.filter.capability.FunctionName)

Example 13 with FunctionName

use of org.opengis.filter.capability.FunctionName in project sldeditor by robward-scisys.

the class RenderTransformationDialog method displayBuiltInProcessFunction.

/**
 * Display built in process function.
 *
 * @param selectedValue the selected value
 * @return true, if successful
 */
private boolean displayBuiltInProcessFunction(String selectedValue) {
    String functionNameString;
    // Strip off the prefix
    functionNameString = SelectedProcessFunction.extractLocalFunctionName(selectedValue);
    for (FunctionName name : factory.getFunctionNames()) {
        if (name.getName().compareToIgnoreCase(functionNameString) == 0) {
            functionList.setSelectedValue(functionNameString, true);
            functionParameterTableModel.populate(name, existingProcessFunction);
            return true;
        }
    }
    return false;
}
Also used : FunctionName(org.opengis.filter.capability.FunctionName)

Example 14 with FunctionName

use of org.opengis.filter.capability.FunctionName in project sldeditor by robward-scisys.

the class FieldConfigBaseTest method testPopulateExpressionExpression.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigBase#populate(org.opengis.filter.expression.Expression)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigBase#populate(org.opengis.filter.expression.Expression, org.opengis.filter.expression.Expression)}.
 */
@Test
public void testPopulateExpressionExpression() {
    FieldIdEnum expectedFieldId = FieldIdEnum.NAME;
    String expectedLabel = "test label";
    TestFieldConfigBase field = new TestFieldConfigBase(new FieldConfigCommonData(String.class, expectedFieldId, expectedLabel, false));
    AttributeSelection attributeSelectionPanel = AttributeSelection.createAttributes(String.class, field, false);
    field.testAttributeSelectionPanel(attributeSelectionPanel);
    TestUpdateSymbolInterface listener = new TestUpdateSymbolInterface();
    field.addDataChangedListener(listener);
    assertFalse(listener.hasBeenCalled());
    FilterFactory ff = CommonFactoryFinder.getFilterFactory();
    // Test function
    DefaultFunctionFactory functionFactory = new DefaultFunctionFactory();
    FunctionName functionName = null;
    for (FunctionName func : functionFactory.getFunctionNames()) {
        if (func.getName() == "greaterThan") {
            functionName = func;
            break;
        }
    }
    assertNotNull(functionName);
    Expression testExpression = ff.function(functionName.getFunctionName(), ff.literal(1), ff.literal(2));
    field.populate(testExpression);
    // Updated because the attribute pulldown changed
    assertTrue(listener.hasBeenCalled());
    assertEquals(ExpressionTypeEnum.E_EXPRESSION, field.getExpressionType());
    Expression expression = field.getExpression();
    assertTrue(expression.toString().startsWith(functionName.getName()));
    // Attribute expression wrapped in a literal expression
    String testAttributeName = "test attribute";
    NameImpl name = new NameImpl(testAttributeName);
    AttributeExpressionImpl attributeExpression = new AttributeExpressionImpl(name);
    Expression literalExpression = ff.literal(attributeExpression);
    field.populate(literalExpression);
    assertEquals(ExpressionTypeEnum.E_ATTRIBUTE, field.getExpressionType());
// Process Function
// ProcessFunctionFactory factory = new ProcessFunctionFactory();
// FunctionTableModel functionParameterTableModel = new FunctionTableModel();
// ProcessFunction processFunction = functionParameterTableModel.getExpression(factory);
// field.populate(processFunction);
// assertEquals(ExpressionTypeEnum.E_VALUE, field.getExpressionType());
}
Also used : FunctionName(org.opengis.filter.capability.FunctionName) NameImpl(org.geotools.feature.NameImpl) DefaultFunctionFactory(org.geotools.filter.function.DefaultFunctionFactory) Expression(org.opengis.filter.expression.Expression) AttributeExpressionImpl(org.geotools.filter.AttributeExpressionImpl) AttributeSelection(com.sldeditor.ui.attribute.AttributeSelection) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) FieldIdEnum(com.sldeditor.common.xml.ui.FieldIdEnum) FilterFactory(org.opengis.filter.FilterFactory) Test(org.junit.Test)

Example 15 with FunctionName

use of org.opengis.filter.capability.FunctionName in project sldeditor by robward-scisys.

the class BuiltInProcessFunctionTest method testExtractParametersFunctionName.

/**
 * Test method for
 * {@link com.sldeditor.rendertransformation.BuiltInProcessFunction#extractParameters(org.opengis.filter.capability.FunctionName, org.geotools.process.function.ProcessFunction)}.
 */
@Test
public void testExtractParametersFunctionName() {
    BuiltInProcessFunction obj = new BuiltInProcessFunction();
    List<ProcessFunctionParameterValue> valueList = obj.extractParameters(null, null);
    assertTrue(valueList.isEmpty());
    ProcessFunctionFactory processFunctionFactory = new ProcessFunctionFactory();
    List<FunctionName> functionNameList = processFunctionFactory.getFunctionNames();
    for (FunctionName functionName : functionNameList) {
        valueList = obj.extractParameters(functionName, null);
        assertEquals(functionName.getArguments().size(), valueList.size());
        for (int index = 0; index < functionName.getArguments().size(); index++) {
            Parameter<?> expectedParameter = functionName.getArguments().get(index);
            ProcessFunctionParameterValue actualParameter = valueList.get(index);
            assertTrue(functionName.getName(), expectedParameter.getName().compareTo(actualParameter.name) == 0);
            assertEquals(functionName.getName(), expectedParameter.getType(), actualParameter.type);
            assertTrue(functionName.getName(), expectedParameter.getType().getSimpleName().compareTo(actualParameter.dataType) == 0);
            assertEquals(functionName.getName(), !expectedParameter.isRequired(), actualParameter.optional);
            assertEquals(functionName.getName(), expectedParameter.getMinOccurs(), actualParameter.minOccurences);
            assertEquals(functionName.getName(), expectedParameter.getMaxOccurs(), actualParameter.maxOccurences);
        }
    }
    System.out.println(String.format("Tested %d functions", functionNameList.size()));
}
Also used : BuiltInProcessFunction(com.sldeditor.rendertransformation.BuiltInProcessFunction) FunctionName(org.opengis.filter.capability.FunctionName) ProcessFunctionParameterValue(com.sldeditor.rendertransformation.ProcessFunctionParameterValue) ProcessFunctionFactory(org.geotools.process.function.ProcessFunctionFactory) Test(org.junit.Test)

Aggregations

FunctionName (org.opengis.filter.capability.FunctionName)21 Test (org.junit.Test)12 ArrayList (java.util.ArrayList)9 Expression (org.opengis.filter.expression.Expression)7 DefaultFunctionFactory (org.geotools.filter.function.DefaultFunctionFactory)6 FunctionNameFilterInterface (com.sldeditor.filter.v2.function.namefilter.FunctionNameFilterInterface)5 FunctionExpression (org.geotools.filter.FunctionExpression)5 FunctionNameFilterAll (com.sldeditor.filter.v2.function.namefilter.FunctionNameFilterAll)4 ProcessFunctionFactory (org.geotools.process.function.ProcessFunctionFactory)4 FieldConfigString (com.sldeditor.ui.detail.config.FieldConfigString)3 AttributeExpressionImpl (org.geotools.filter.AttributeExpressionImpl)3 FieldIdEnum (com.sldeditor.common.xml.ui.FieldIdEnum)2 FunctionNameFilterRaster (com.sldeditor.filter.v2.function.namefilter.FunctionNameFilterRaster)2 BuiltInProcessFunction (com.sldeditor.rendertransformation.BuiltInProcessFunction)2 ProcessFunctionParameterValue (com.sldeditor.rendertransformation.ProcessFunctionParameterValue)2 FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)2 LineString (com.vividsolutions.jts.geom.LineString)2 Point (com.vividsolutions.jts.geom.Point)2 FunctionImpl (org.geotools.filter.FunctionImpl)2 LiteralExpressionImpl (org.geotools.filter.LiteralExpressionImpl)2