Search in sources :

Example 6 with FilterFactory

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

the class DetailsUtilitiesTest method testIsSameDisplacementDisplacement.

/**
 * Test method for {@link com.sldeditor.ui.detail.DetailsUtilities#isSame(org.geotools.styling.Displacement, org.geotools.styling.Displacement)}.
 */
@Test
public void testIsSameDisplacementDisplacement() {
    assertFalse(DetailsUtilities.isSame((Displacement) null, (Displacement) null));
    FilterFactory ff = CommonFactoryFinder.getFilterFactory();
    // Try values that are the same
    Displacement displacement1 = new DisplacementImpl();
    displacement1.setDisplacementX(ff.literal(42));
    displacement1.setDisplacementY(ff.literal(-2));
    Displacement displacement2 = new DisplacementImpl();
    displacement2.setDisplacementX(ff.literal("42"));
    displacement2.setDisplacementY(ff.literal(-2));
    assertTrue(DetailsUtilities.isSame(displacement1, displacement2));
    // Try values that are not the same
    Displacement displacement3 = new DisplacementImpl();
    displacement3.setDisplacementX(ff.literal(1));
    displacement3.setDisplacementY(ff.literal(-2));
    assertFalse(DetailsUtilities.isSame(displacement1, displacement3));
    assertFalse(DetailsUtilities.isSame(displacement2, displacement3));
    Displacement displacement4 = new DisplacementImpl();
    displacement4.setDisplacementX(ff.literal((Long) 1L));
    displacement4.setDisplacementY(ff.literal(-2));
    assertFalse(DetailsUtilities.isSame(displacement1, displacement4));
    assertFalse(DetailsUtilities.isSame(displacement2, displacement4));
}
Also used : DisplacementImpl(org.geotools.styling.DisplacementImpl) Displacement(org.geotools.styling.Displacement) FilterFactory(org.opengis.filter.FilterFactory) Test(org.junit.Test)

Example 7 with FilterFactory

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

the class DetailsUtilitiesTest method testIsSameAnchorPointAnchorPoint.

/**
 * Test method for {@link com.sldeditor.ui.detail.DetailsUtilities#isSame(org.geotools.styling.AnchorPoint, org.geotools.styling.AnchorPoint)}.
 */
@Test
public void testIsSameAnchorPointAnchorPoint() {
    assertFalse(DetailsUtilities.isSame((AnchorPoint) null, (AnchorPoint) null));
    FilterFactory ff = CommonFactoryFinder.getFilterFactory();
    // Try values that are the same
    AnchorPoint anchorPoint1 = new AnchorPointImpl();
    anchorPoint1.setAnchorPointX(ff.literal(0.58));
    anchorPoint1.setAnchorPointY(ff.literal(0.1));
    AnchorPoint anchorPoint2 = new AnchorPointImpl();
    anchorPoint2.setAnchorPointX(ff.literal(0.58));
    anchorPoint2.setAnchorPointY(ff.literal("0.1"));
    assertTrue(DetailsUtilities.isSame(anchorPoint1, anchorPoint2));
    // Try values that are not the same
    AnchorPoint anchorPoint3 = new AnchorPointImpl();
    anchorPoint3.setAnchorPointX(ff.literal(1.0));
    anchorPoint3.setAnchorPointY(ff.literal(0.1));
    assertFalse(DetailsUtilities.isSame(anchorPoint1, anchorPoint3));
    assertFalse(DetailsUtilities.isSame(anchorPoint2, anchorPoint3));
}
Also used : AnchorPoint(org.geotools.styling.AnchorPoint) FilterFactory(org.opengis.filter.FilterFactory) AnchorPointImpl(org.geotools.styling.AnchorPointImpl) Test(org.junit.Test)

Example 8 with FilterFactory

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

the class FieldConfigBaseTest method testExpressionUpdated.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigBase#expressionUpdated(org.opengis.filter.expression.Expression)}.
 */
@Test
public void testExpressionUpdated() {
    FieldIdEnum expectedFieldId = FieldIdEnum.NAME;
    String expectedLabel = "test label";
    TestFieldConfigBase field = new TestFieldConfigBase(new FieldConfigCommonData(String.class, expectedFieldId, expectedLabel, false));
    TestUpdateSymbolInterface listener = new TestUpdateSymbolInterface();
    field.addDataChangedListener(listener);
    String expressionName = "test expression";
    assertFalse(listener.hasBeenCalled());
    FilterFactory ff = CommonFactoryFinder.getFilterFactory();
    Expression testExpression = ff.literal(expressionName);
    field.expressionUpdated(testExpression);
    assertTrue(listener.hasBeenCalled());
    assertEquals(ExpressionTypeEnum.E_EXPRESSION, field.getExpressionType());
    Expression expression = field.getExpression();
    assertTrue(expressionName.compareTo(expression.toString()) == 0);
}
Also used : Expression(org.opengis.filter.expression.Expression) 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 9 with FilterFactory

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

the class FieldConfigBaseTest method testFunctionUpdated.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigBase#functionUpdated(org.opengis.filter.expression.Expression)}.
 */
@Test
public void testFunctionUpdated() {
    FieldIdEnum expectedFieldId = FieldIdEnum.NAME;
    String expectedLabel = "test label";
    TestFieldConfigBase field = new TestFieldConfigBase(new FieldConfigCommonData(String.class, expectedFieldId, expectedLabel, false));
    TestUpdateSymbolInterface listener = new TestUpdateSymbolInterface();
    field.addDataChangedListener(listener);
    assertFalse(listener.hasBeenCalled());
    FilterFactory ff = CommonFactoryFinder.getFilterFactory();
    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.functionUpdated(testExpression);
    assertTrue(listener.hasBeenCalled());
    assertEquals(ExpressionTypeEnum.E_FUNCTION, field.getExpressionType());
    Expression expression = field.getExpression();
    assertTrue(expression.toString().startsWith(functionName.getName()));
}
Also used : FunctionName(org.opengis.filter.capability.FunctionName) DefaultFunctionFactory(org.geotools.filter.function.DefaultFunctionFactory) Expression(org.opengis.filter.expression.Expression) 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 10 with FilterFactory

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

the class ColourMapDataTest method testColourMapData.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.colourmap.ColourMapData#ColourMapData()}.
 */
@Test
public void testColourMapData() {
    FilterFactory ff = CommonFactoryFinder.getFilterFactory();
    ColourMapData actual = new ColourMapData();
    String expectedLabel = "abc";
    String expectedColour = "#123456";
    double expectedOpacity = 0.5;
    int expectedQuantity = 42;
    actual.setLabel(expectedLabel);
    actual.setColour(ff.literal(expectedColour));
    actual.setOpacity(ff.literal(expectedOpacity));
    actual.setQuantity(ff.literal(expectedQuantity));
    assertEquals(actual.getLabel(), expectedLabel);
    assertEquals(ColourUtils.fromColour(actual.getColour()), expectedColour);
    assertEquals(actual.getOpacity().toString(), String.valueOf(expectedOpacity));
    assertEquals(actual.getQuantity().toString(), String.valueOf(expectedQuantity));
    // Test getNextQuantity with a value
    Expression nextQuantity = actual.getNextQuantity();
    int iValue = Double.valueOf(nextQuantity.toString()).intValue();
    assertTrue(iValue == (expectedQuantity + 1));
    // Test getNextQuantity with a function expression set
    Divide divide = ff.divide(ff.literal(10.0), ff.literal(2.0));
    actual.setQuantity(divide);
    nextQuantity = actual.getNextQuantity();
    assertEquals(nextQuantity.toString(), actual.getQuantity().toString());
    actual.update(null);
    // Label
    ColourMapData update = new ColourMapData();
    String updatedLabel = "new label";
    update.setLabel(updatedLabel);
    actual.update(update);
    assertEquals(actual.getLabel(), updatedLabel);
    // Colour
    ColourMapData updateColour = new ColourMapData();
    String updatedColour = "#234567";
    updateColour.setColour(ff.literal(updatedColour));
    actual.update(updateColour);
    assertEquals(actual.getColourString(), updatedColour);
    // Opacity
    ColourMapData updateOpacity = new ColourMapData();
    double updatedOpacity = 0.25;
    updateOpacity.setOpacity(ff.literal(updatedOpacity));
    actual.update(updateOpacity);
    assertEquals(actual.getOpacity().toString(), String.valueOf(updatedOpacity));
    // Quantity
    ColourMapData updateQuantity = new ColourMapData();
    int updatedQuantity = 78;
    updateQuantity.setQuantity(ff.literal(updatedQuantity));
    actual.update(updateQuantity);
    assertEquals(actual.getQuantity().toString(), String.valueOf(updatedQuantity));
}
Also used : Divide(org.opengis.filter.expression.Divide) Expression(org.opengis.filter.expression.Expression) ColourMapData(com.sldeditor.ui.detail.config.colourmap.ColourMapData) FilterFactory(org.opengis.filter.FilterFactory) Test(org.junit.Test)

Aggregations

FilterFactory (org.opengis.filter.FilterFactory)88 Test (org.junit.Test)72 FilterFactoryImpl (org.geotools.filter.FilterFactoryImpl)42 Filter (org.opengis.filter.Filter)38 QueryImpl (ddf.catalog.operation.impl.QueryImpl)33 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)30 Expression (org.opengis.filter.expression.Expression)24 SourceResponse (ddf.catalog.operation.SourceResponse)21 ArrayList (java.util.ArrayList)18 Metacard (ddf.catalog.data.Metacard)17 SolrProviderTest (ddf.catalog.source.solr.SolrProviderTest)17 ContrastEnhancement (org.geotools.styling.ContrastEnhancement)12 SelectedChannelType (org.geotools.styling.SelectedChannelType)12 Date (java.util.Date)11 StyleFactoryImpl (org.geotools.styling.StyleFactoryImpl)11 ChannelSelection (org.geotools.styling.ChannelSelection)10 FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)8 Result (ddf.catalog.data.Result)8 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)8 QueryResponse (ddf.catalog.operation.QueryResponse)8