Search in sources :

Example 16 with FilterFactory

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

the class ArrowUtilsTest method testEncode.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.vendor.geoserver.marker.arrow.ArrowUtils#encode(org.opengis.filter.expression.Expression, org.opengis.filter.expression.Expression, org.opengis.filter.expression.Expression)}.
 */
@Test
public void testEncode() {
    FilterFactory ff = CommonFactoryFinder.getFilterFactory(null);
    assertEquals("extshape://arrow?hr=1.2&t=0.34&ab=0.56", ArrowUtils.encode(ff.literal(1.2), ff.literal(0.34), ff.literal(0.56)));
    assertEquals("extshape://arrow?hr=2.0&t=0.34&ab=0.56", ArrowUtils.encode(null, ff.literal(0.34), ff.literal(0.56)));
    assertEquals("extshape://arrow?hr=1.2&t=0.2&ab=0.56", ArrowUtils.encode(ff.literal(1.2), null, ff.literal(0.56)));
    assertEquals("extshape://arrow?hr=1.2&t=0.34&ab=0.5", ArrowUtils.encode(ff.literal(1.2), ff.literal(0.34), null));
}
Also used : FilterFactory(org.opengis.filter.FilterFactory) Test(org.junit.Test)

Example 17 with FilterFactory

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

the class VOGeoServerContrastEnhancementNormalizeGreyTest method createChannelSelection.

/**
 * Creates the channel selection object.
 *
 * @param styleFactory the style factory
 * @param contrastMethod the contrast method
 * @return the channel selection
 */
private ChannelSelection createChannelSelection(StyleFactoryImpl styleFactory, ContrastMethod contrastMethod) {
    ContrastEnhancement contrastEnhancement = (ContrastEnhancement) styleFactory.contrastEnhancement(null, contrastMethod.name());
    FilterFactory ff = CommonFactoryFinder.getFilterFactory();
    Map<String, Expression> options = contrastEnhancement.getOptions();
    options.put("algorithm", ff.literal("StretchToMinimumMaximum"));
    options.put("minValue", ff.literal("1"));
    options.put("maxValue", ff.literal("5"));
    SelectedChannelType channelType = styleFactory.createSelectedChannelType("channel name", contrastEnhancement);
    SelectedChannelType[] channels = new SelectedChannelType[3];
    channels[0] = channelType;
    channels[1] = channelType;
    channels[2] = channelType;
    ChannelSelection channelSelection = styleFactory.createChannelSelection(channels);
    return channelSelection;
}
Also used : SelectedChannelType(org.geotools.styling.SelectedChannelType) ContrastEnhancement(org.geotools.styling.ContrastEnhancement) Expression(org.opengis.filter.expression.Expression) ChannelSelection(org.geotools.styling.ChannelSelection) FilterFactory(org.opengis.filter.FilterFactory)

Example 18 with FilterFactory

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

the class VOGeoServerContrastEnhancementNormalizeRedTest method createChannelSelectionError.

/**
 * Creates the channel selection error object.
 *
 * @param styleFactory the style factory
 * @param contrastMethod the contrast method
 * @return the channel selection
 */
private ChannelSelection createChannelSelectionError(StyleFactoryImpl styleFactory, ContrastMethod contrastMethod) {
    ContrastEnhancement contrastEnhancement = (ContrastEnhancement) styleFactory.contrastEnhancement(null, contrastMethod.name());
    FilterFactory ff = CommonFactoryFinder.getFilterFactory();
    Map<String, Expression> options = contrastEnhancement.getOptions();
    options.put("algorithm", ff.literal("TestStretchToMinimumMaximum"));
    options.put("minValue", ff.literal("1.0"));
    options.put("maxValue", ff.literal("5.0"));
    SelectedChannelType channelType = styleFactory.createSelectedChannelType("channel name", contrastEnhancement);
    SelectedChannelType[] channels = new SelectedChannelType[3];
    channels[0] = channelType;
    channels[1] = channelType;
    channels[2] = channelType;
    ChannelSelection channelSelection = styleFactory.createChannelSelection(channels);
    return channelSelection;
}
Also used : SelectedChannelType(org.geotools.styling.SelectedChannelType) ContrastEnhancement(org.geotools.styling.ContrastEnhancement) Expression(org.opengis.filter.expression.Expression) ChannelSelection(org.geotools.styling.ChannelSelection) FilterFactory(org.opengis.filter.FilterFactory)

Example 19 with FilterFactory

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

the class VOGeoServerTextSymbolizer2Test method testVOGeoServerTextSymbolizer2.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.vendor.geoserver.text.VOGeoServerTextSymbolizer2#VOGeoServerTextSymbolizer2(java.lang.Class, com.sldeditor.filter.v2.function.FunctionNameInterface)}.
 */
@Test
public void testVOGeoServerTextSymbolizer2() {
    TextSymbolizerDetails panel = new TextSymbolizerDetails();
    TextSymbolizer2 textSymbolizer = null;
    VOGeoServerTextSymbolizer2 testObj = new VOGeoServerTextSymbolizer2(panel.getClass());
    testObj.setParentPanel(panel);
    testObj.populate(textSymbolizer);
    testObj.updateSymbol(textSymbolizer);
    StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory();
    textSymbolizer = (TextSymbolizer2) styleFactory.createTextSymbolizer();
    FilterFactory ff = CommonFactoryFinder.getFilterFactory();
    Literal featureDescription = ff.literal("feature description");
    textSymbolizer.setFeatureDescription(featureDescription);
    OtherText otherText = new OtherTextImpl();
    otherText.setTarget("target");
    Literal otherTextExpression = ff.literal("other text");
    otherText.setText(otherTextExpression);
    textSymbolizer.setOtherText(otherText);
    Literal snippet = ff.literal("snippet");
    textSymbolizer.setSnippet(snippet);
    // Try with marker symbol
    Graphic graphic = styleFactory.createDefaultGraphic();
    graphic.graphicalSymbols().add(styleFactory.createMark());
    textSymbolizer.setGraphic(graphic);
    Controller.getInstance().setPopulating(true);
    testObj.populate(textSymbolizer);
    Controller.getInstance().setPopulating(false);
    testObj.updateSymbol(textSymbolizer);
    // Try with external graphic
    graphic = styleFactory.createDefaultGraphic();
    try {
        graphic.graphicalSymbols().add(styleFactory.createExternalGraphic(new File("test.png").toURI().toURL(), "png"));
    } catch (MalformedURLException e) {
        e.printStackTrace();
    }
    textSymbolizer.setGraphic(graphic);
    Controller.getInstance().setPopulating(true);
    testObj.populate(textSymbolizer);
    Controller.getInstance().setPopulating(false);
    testObj.updateSymbol(textSymbolizer);
    // Find minimum version with textSymbolizer2 values set
    List<VendorOptionPresent> vendorOptionsPresentList = new ArrayList<VendorOptionPresent>();
    testObj.getMinimumVersion(null, textSymbolizer, vendorOptionsPresentList);
    assertEquals(1, vendorOptionsPresentList.size());
    // Find minimum version with no textSymbolizer2 values set
    vendorOptionsPresentList.clear();
    testObj.getMinimumVersion(null, styleFactory.createTextSymbolizer(), vendorOptionsPresentList);
    assertEquals(0, vendorOptionsPresentList.size());
    // Get the code coverage values up
    testObj.populate(SelectedSymbol.getInstance());
    PolygonSymbolizer polygon = null;
    testObj.populate(polygon);
    testObj.updateSymbol(polygon);
    RasterSymbolizer raster = null;
    testObj.populate(raster);
    testObj.updateSymbol(raster);
    testObj.preLoadSymbol();
    assertTrue(testObj.isDataPresent());
}
Also used : VendorOptionPresent(com.sldeditor.common.vendoroption.minversion.VendorOptionPresent) MalformedURLException(java.net.MalformedURLException) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) Graphic(org.geotools.styling.Graphic) ArrayList(java.util.ArrayList) OtherText(org.geotools.styling.OtherText) FilterFactory(org.opengis.filter.FilterFactory) RasterSymbolizer(org.geotools.styling.RasterSymbolizer) OtherTextImpl(org.geotools.styling.OtherTextImpl) TextSymbolizer2(org.geotools.styling.TextSymbolizer2) VOGeoServerTextSymbolizer2(com.sldeditor.ui.detail.vendor.geoserver.text.VOGeoServerTextSymbolizer2) StyleFactoryImpl(org.geotools.styling.StyleFactoryImpl) Literal(org.opengis.filter.expression.Literal) VOGeoServerTextSymbolizer2(com.sldeditor.ui.detail.vendor.geoserver.text.VOGeoServerTextSymbolizer2) File(java.io.File) TextSymbolizerDetails(com.sldeditor.ui.detail.TextSymbolizerDetails) Test(org.junit.Test)

Example 20 with FilterFactory

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

the class EnvironmentVariableManagerTest method testGetDataType.

/**
 * Test method for
 * {@link com.sldeditor.filter.v2.envvar.EnvironmentVariableManager#getDataType(org.opengis.filter.expression.Expression)}.
 */
@Test
public void testGetDataType() {
    Class<?> dataType = EnvironmentVariableManager.getInstance().getDataType(null);
    assertEquals(Object.class, dataType);
    dataType = EnvironmentVariableManager.getInstance().getDataType(ConstantExpression.TWO);
    assertEquals(Object.class, dataType);
    FilterFactory ff = CommonFactoryFinder.getFilterFactory();
    Expression literal = ff.literal("wms_width");
    dataType = EnvironmentVariableManager.getInstance().getDataType(literal);
    assertEquals(Integer.class, dataType);
}
Also used : ConstantExpression(org.geotools.filter.ConstantExpression) Expression(org.opengis.filter.expression.Expression) 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