Search in sources :

Example 1 with Divide

use of org.opengis.filter.expression.Divide 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)

Example 2 with Divide

use of org.opengis.filter.expression.Divide in project polymap4-core by Polymap4.

the class LuceneQueryDialect method supports.

public static boolean supports(Filter _filter) {
    final List notSupported = new ArrayList();
    _filter.accept(new DefaultFilterVisitor() {

        public Object visit(Beyond filter, Object data) {
            notSupported.add(filter);
            return super.visit(filter, data);
        }

        public Object visit(Contains filter, Object data) {
            notSupported.add(filter);
            return super.visit(filter, data);
        }

        public Object visit(Crosses filter, Object data) {
            notSupported.add(filter);
            return super.visit(filter, data);
        }

        public Object visit(Disjoint filter, Object data) {
            notSupported.add(filter);
            return super.visit(filter, data);
        }

        public Object visit(Divide expression, Object data) {
            notSupported.add(expression);
            return super.visit(expression, data);
        }

        public Object visit(DWithin filter, Object data) {
            notSupported.add(filter);
            return super.visit(filter, data);
        }

        public Object visit(org.opengis.filter.expression.Function expression, Object data) {
            notSupported.add(expression);
            return super.visit(expression, data);
        }

        public Object visit(Intersects filter, Object data) {
            notSupported.add(filter);
            return super.visit(filter, data);
        }

        public Object visit(Multiply expression, Object data) {
            notSupported.add(expression);
            return super.visit(expression, data);
        }

        public Object visit(Overlaps filter, Object data) {
            notSupported.add(filter);
            return super.visit(filter, data);
        }

        public Object visit(Subtract expression, Object data) {
            notSupported.add(expression);
            return super.visit(expression, data);
        }

        public Object visit(Touches filter, Object data) {
            notSupported.add(filter);
            return super.visit(filter, data);
        }

        public Object visit(Within filter, Object data) {
            notSupported.add(filter);
            return super.visit(filter, data);
        }
    }, notSupported);
    return notSupported.isEmpty();
}
Also used : Overlaps(org.opengis.filter.spatial.Overlaps) DefaultFilterVisitor(org.geotools.filter.visitor.DefaultFilterVisitor) ArrayList(java.util.ArrayList) Beyond(org.opengis.filter.spatial.Beyond) Divide(org.opengis.filter.expression.Divide) Crosses(org.opengis.filter.spatial.Crosses) DWithin(org.opengis.filter.spatial.DWithin) Intersects(org.opengis.filter.spatial.Intersects) Multiply(org.opengis.filter.expression.Multiply) Contains(org.opengis.filter.spatial.Contains) DWithin(org.opengis.filter.spatial.DWithin) Within(org.opengis.filter.spatial.Within) Disjoint(org.opengis.filter.spatial.Disjoint) Subtract(org.opengis.filter.expression.Subtract) Touches(org.opengis.filter.spatial.Touches) List(java.util.List) ArrayList(java.util.ArrayList)

Aggregations

Divide (org.opengis.filter.expression.Divide)2 ColourMapData (com.sldeditor.ui.detail.config.colourmap.ColourMapData)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 DefaultFilterVisitor (org.geotools.filter.visitor.DefaultFilterVisitor)1 Test (org.junit.Test)1 FilterFactory (org.opengis.filter.FilterFactory)1 Expression (org.opengis.filter.expression.Expression)1 Multiply (org.opengis.filter.expression.Multiply)1 Subtract (org.opengis.filter.expression.Subtract)1 Beyond (org.opengis.filter.spatial.Beyond)1 Contains (org.opengis.filter.spatial.Contains)1 Crosses (org.opengis.filter.spatial.Crosses)1 DWithin (org.opengis.filter.spatial.DWithin)1 Disjoint (org.opengis.filter.spatial.Disjoint)1 Intersects (org.opengis.filter.spatial.Intersects)1 Overlaps (org.opengis.filter.spatial.Overlaps)1 Touches (org.opengis.filter.spatial.Touches)1 Within (org.opengis.filter.spatial.Within)1