Search in sources :

Example 1 with ProcessFunctionFactory

use of org.geotools.process.function.ProcessFunctionFactory in project sldeditor by robward-scisys.

the class RenderTransformationDialogTest method testRenderTransformationDialog.

/**
 * Test method for
 * {@link com.sldeditor.rendertransformation.RenderTransformationDialog#RenderTransformationDialog(com.sldeditor.common.connection.GeoServerConnectionManagerInterface)}.
 */
@Test
public void testRenderTransformationDialog() {
    TestRenderTransformationDialog testObj = new TestRenderTransformationDialog(null);
    testObj.test_internal_showDialog(null);
    ProcessFunction actualResult = testObj.getTransformationProcessFunction();
    assertNull(actualResult);
    ProcessFunctionFactory factory = new ProcessFunctionFactory();
    FunctionName functionName = factory.getFunctionNames().get(0);
    testObj.testDisplayFunction(functionName.getName());
    actualResult = testObj.getTransformationProcessFunction();
    assertNotNull(actualResult);
    testObj.test_internal_showDialog(actualResult);
}
Also used : ProcessFunction(org.geotools.process.function.ProcessFunction) FunctionName(org.opengis.filter.capability.FunctionName) ProcessFunctionFactory(org.geotools.process.function.ProcessFunctionFactory) Test(org.junit.Test)

Example 2 with ProcessFunctionFactory

use of org.geotools.process.function.ProcessFunctionFactory in project sldeditor by robward-scisys.

the class SelectedProcessFunctionTest method testSetBuiltInProcessFunction.

/**
 * Test method for
 * {@link com.sldeditor.rendertransformation.SelectedProcessFunction#setBuiltInProcessFunction(org.opengis.filter.capability.FunctionName, org.geotools.process.function.ProcessFunction)}.
 */
@Test
public void testSetBuiltInProcessFunction() {
    SelectedProcessFunction obj = new SelectedProcessFunction();
    assertTrue(obj.isBuiltInSelected());
    assertTrue(obj.extractParameters().isEmpty());
    assertNull(obj.getFunctionName());
    assertEquals(0, obj.getRowCount());
    ProcessFunctionFactory processFunctionFactory = new ProcessFunctionFactory();
    List<FunctionName> functionNameList = processFunctionFactory.getFunctionNames();
    FunctionName functionName = functionNameList.get(0);
    obj.setBuiltInProcessFunction(functionName, null);
    assertTrue(obj.isBuiltInSelected());
    assertTrue(obj.getFunctionName().getLocalPart().compareTo(functionName.getName()) == 0);
    assertEquals(obj.getRowCount(), obj.extractParameters().size());
    assertFalse(obj.extractParameters().isEmpty());
}
Also used : SelectedProcessFunction(com.sldeditor.rendertransformation.SelectedProcessFunction) FunctionName(org.opengis.filter.capability.FunctionName) ProcessFunctionFactory(org.geotools.process.function.ProcessFunctionFactory) Test(org.junit.Test)

Example 3 with ProcessFunctionFactory

use of org.geotools.process.function.ProcessFunctionFactory 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)

Example 4 with ProcessFunctionFactory

use of org.geotools.process.function.ProcessFunctionFactory in project sldeditor by robward-scisys.

the class BuiltInProcessFunctionTest method testExtractParametersProcessFunction.

/**
 * Test method for
 * {@link com.sldeditor.rendertransformation.BuiltInProcessFunction#extractParameters(org.opengis.filter.capability.FunctionName, org.geotools.process.function.ProcessFunction)}.
 */
@Test
public void testExtractParametersProcessFunction() {
    BuiltInProcessFunction obj = new BuiltInProcessFunction();
    String testData = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>" + "<StyledLayerDescriptor version=\"1.0.0\" xsi:schemaLocation=\"http://www.opengis.net/sld StyledLayerDescriptor.xsd\" xmlns=\"http://www.opengis.net/sld\" xmlns:ogc=\"http://www.opengis.net/ogc\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" + "<ogc:Function name=\"vec:PointStacker\">" + "<ogc:Function name=\"parameter\">" + "  <ogc:Literal>data</ogc:Literal>" + "</ogc:Function>" + "<ogc:Function name=\"parameter\">" + "  <ogc:Literal>cellSize</ogc:Literal>" + "  <ogc:Literal>30</ogc:Literal>" + "</ogc:Function>" + "<ogc:Function name=\"parameter\">" + "  <ogc:Literal>outputBBOX</ogc:Literal>" + "  <ogc:Function name=\"env\">" + "        <ogc:Literal>wms_bbox</ogc:Literal>" + "  </ogc:Function>" + "</ogc:Function>" + "<ogc:Function name=\"parameter\">" + "  <ogc:Literal>outputWidth</ogc:Literal>" + "  <ogc:Function name=\"env\">" + "        <ogc:Literal>wms_width</ogc:Literal>" + "  </ogc:Function>" + "</ogc:Function>" + "<ogc:Function name=\"parameter\">" + " <ogc:Literal>outputHeight</ogc:Literal>" + "  <ogc:Function name=\"env\">" + "        <ogc:Literal>wms_height</ogc:Literal>" + "  </ogc:Function>" + " </ogc:Function>" + "</ogc:Function>" + "</StyledLayerDescriptor>";
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder;
    ProcessFunction tx = null;
    try {
        builder = factory.newDocumentBuilder();
        InputSource is = new InputSource(new StringReader(testData));
        Document doc = builder.parse(is);
        ExpressionDOMParser parser = new ExpressionDOMParser(CommonFactoryFinder.getFilterFactory2(null));
        tx = (ProcessFunction) parser.expression(doc.getDocumentElement().getFirstChild());
    } catch (ParserConfigurationException e) {
        e.printStackTrace();
    } catch (SAXException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    List<ProcessFunctionParameterValue> valueList = obj.extractParameters(null, tx);
    assertTrue(valueList.isEmpty());
    ProcessFunctionFactory processFunctionFactory = new ProcessFunctionFactory();
    for (FunctionName functionName : processFunctionFactory.getFunctionNames()) {
        if (functionName.getName().compareTo("PointStacker") == 0) {
            valueList = obj.extractParameters(functionName, tx);
            assertEquals(functionName.getArguments().size(), valueList.size());
        }
    }
}
Also used : InputSource(org.xml.sax.InputSource) DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) ProcessFunctionParameterValue(com.sldeditor.rendertransformation.ProcessFunctionParameterValue) IOException(java.io.IOException) ProcessFunctionFactory(org.geotools.process.function.ProcessFunctionFactory) Document(org.w3c.dom.Document) SAXException(org.xml.sax.SAXException) BuiltInProcessFunction(com.sldeditor.rendertransformation.BuiltInProcessFunction) ProcessFunction(org.geotools.process.function.ProcessFunction) BuiltInProcessFunction(com.sldeditor.rendertransformation.BuiltInProcessFunction) FunctionName(org.opengis.filter.capability.FunctionName) DocumentBuilder(javax.xml.parsers.DocumentBuilder) StringReader(java.io.StringReader) ExpressionDOMParser(org.geotools.filter.ExpressionDOMParser) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) Test(org.junit.Test)

Aggregations

ProcessFunctionFactory (org.geotools.process.function.ProcessFunctionFactory)4 Test (org.junit.Test)4 FunctionName (org.opengis.filter.capability.FunctionName)4 BuiltInProcessFunction (com.sldeditor.rendertransformation.BuiltInProcessFunction)2 ProcessFunctionParameterValue (com.sldeditor.rendertransformation.ProcessFunctionParameterValue)2 ProcessFunction (org.geotools.process.function.ProcessFunction)2 SelectedProcessFunction (com.sldeditor.rendertransformation.SelectedProcessFunction)1 IOException (java.io.IOException)1 StringReader (java.io.StringReader)1 DocumentBuilder (javax.xml.parsers.DocumentBuilder)1 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 ExpressionDOMParser (org.geotools.filter.ExpressionDOMParser)1 Document (org.w3c.dom.Document)1 InputSource (org.xml.sax.InputSource)1 SAXException (org.xml.sax.SAXException)1