Search in sources :

Example 56 with FilterFactory

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

the class SelectedSymbolTest method testGetSymbolList.

/**
 * Test method for
 * {@link com.sldeditor.common.data.SelectedSymbol#getSymbolList(org.opengis.style.GraphicalSymbol)}.
 */
@Test
public void testGetSymbolList() {
    StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory();
    FilterFactory ff = CommonFactoryFinder.getFilterFactory();
    Stroke stroke = null;
    Fill fill = styleFactory.createFill(ff.literal(DefaultSymbols.defaultColour()));
    GraphicalSymbol symbolToAdd = styleFactory.mark(ff.literal("circle"), fill, stroke);
    List<GraphicalSymbol> symbolList = SelectedSymbol.getInstance().getSymbolList(symbolToAdd);
    assertEquals(1, symbolList.size());
    assertEquals(symbolToAdd, symbolList.get(0));
}
Also used : Stroke(org.opengis.style.Stroke) Fill(org.geotools.styling.Fill) StyleFactoryImpl(org.geotools.styling.StyleFactoryImpl) GraphicalSymbol(org.opengis.style.GraphicalSymbol) FilterFactory(org.opengis.filter.FilterFactory) Test(org.junit.Test)

Example 57 with FilterFactory

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

the class ColourUtilsTest method testGetIntColour.

/**
 * Test method for {@link com.sldeditor.common.utils.ColourUtils#getIntColour(org.opengis.filter.expression.Expression)}.
 */
@Test
public void testGetIntColour() {
    FilterFactory ff = CommonFactoryFinder.getFilterFactory();
    Expression colourExpression = ff.literal("#FF00FF");
    int colourValue = ColourUtils.getIntColour(colourExpression);
    assertEquals(0xff00ff, colourValue);
    colourValue = ColourUtils.getIntColour(null);
}
Also used : Expression(org.opengis.filter.expression.Expression) FilterFactory(org.opengis.filter.FilterFactory) Test(org.junit.Test)

Example 58 with FilterFactory

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

the class SLDEditorBufferedImageLegendGraphicBuilder method buildLegendGraphic.

/**
 * Takes a GetLegendGraphicRequest and produces a BufferedImage that then can be used by a
 * subclass to encode it to the appropriate output format.
 *
 * @param request the "parsed" request, where "parsed" means that it's values are already
 *        validated so this method must not take care of verifying the requested layer exists
 *        and the like.
 *
 * @throws ServiceException if there are problems creating a "sample" feature instance for the
 *         FeatureType <code>request</code> returns as the required layer (which should not
 *         occur).
 */
public BufferedImage buildLegendGraphic(GetLegendGraphicRequest request) throws ServiceException {
    // list of images to be rendered for the layers (more than one if
    // a layer group is given)
    List<RenderedImage> layersImages = new ArrayList<RenderedImage>();
    List<LegendRequest> layers = request.getLegends();
    boolean forceLabelsOn = false;
    boolean forceLabelsOff = false;
    if (request.getLegendOptions().get("forceLabels") instanceof String) {
        String forceLabelsOpt = (String) request.getLegendOptions().get("forceLabels");
        if (forceLabelsOpt.equalsIgnoreCase("on")) {
            forceLabelsOn = true;
        } else if (forceLabelsOpt.equalsIgnoreCase("off")) {
            forceLabelsOff = true;
        }
    }
    boolean forceTitlesOff = false;
    if (request.getLegendOptions().get("forceTitles") instanceof String) {
        String forceTitlesOpt = (String) request.getLegendOptions().get("forceTitles");
        if (forceTitlesOpt.equalsIgnoreCase("off")) {
            forceTitlesOff = true;
        }
    }
    double imageSizeFactor = 1.0;
    if (request.getLegendOptions().get("imageSizeFactor") instanceof String) {
        String imageSizeFactorOpt = (String) request.getLegendOptions().get("imageSizeFactor");
        imageSizeFactor = Double.valueOf(imageSizeFactorOpt);
    }
    FeatureCountProcessor countProcessor = null;
    if (Boolean.TRUE.equals(request.getLegendOption(GetLegendGraphicRequest.COUNT_MATCHED_KEY, Boolean.class))) {
        countProcessor = new FeatureCountProcessor(request);
    }
    for (LegendRequest legend : layers) {
        FeatureType layer = legend.getFeatureType();
        // style and rule to use for the current layer
        Style gt2Style = legend.getStyle();
        if (gt2Style == null) {
            throw new NullPointerException("request.getStyle()");
        }
        // get rule corresponding to the layer index
        // normalize to null for NO RULE
        // was null
        String ruleName = legend.getRule();
        // width and height, we might have to rescale those in case of DPI usage
        int w = request.getWidth();
        int h = request.getHeight();
        // apply dpi rescale
        double dpi = RendererUtilities.getDpi(request.getLegendOptions());
        double standardDpi = RendererUtilities.getDpi(Collections.emptyMap());
        if (dpi != standardDpi) {
            double scaleFactor = dpi / standardDpi;
            w = (int) Math.round(w * scaleFactor);
            h = (int) Math.round(h * scaleFactor);
            DpiRescaleStyleVisitor dpiVisitor = new DpiRescaleStyleVisitor(scaleFactor);
            dpiVisitor.visit(gt2Style);
            gt2Style = (Style) dpiVisitor.getCopy();
        }
        // apply UOM rescaling if we have a scale
        if (request.getScale() > 0) {
            double pixelsPerMeters = RendererUtilities.calculatePixelsPerMeterRatio(request.getScale(), request.getLegendOptions());
            UomRescaleStyleVisitor rescaleVisitor = new UomRescaleStyleVisitor(pixelsPerMeters);
            rescaleVisitor.visit(gt2Style);
            gt2Style = (Style) rescaleVisitor.getCopy();
        }
        boolean strict = request.isStrict();
        final boolean transparent = request.isTransparent();
        RenderedImage titleImage = null;
        // if we have more than one layer, we put a title on top of each layer legend
        if (layers.size() > 1 && !forceTitlesOff) {
            titleImage = getLayerTitle(legend, w, h, transparent, request);
        }
        // Check for rendering transformation
        boolean hasVectorTransformation = false;
        boolean hasRasterTransformation = false;
        List<FeatureTypeStyle> ftsList = gt2Style.featureTypeStyles();
        for (int i = 0; i < ftsList.size(); i++) {
            FeatureTypeStyle fts = ftsList.get(i);
            Expression exp = fts.getTransformation();
            if (exp != null) {
                ProcessFunction processFunction = (ProcessFunction) exp;
                Name processName = processFunction.getProcessName();
                Map<String, Parameter<?>> outputs = Processors.getResultInfo(processName, null);
                if (outputs.isEmpty()) {
                    continue;
                }
                // we assume there is
                Parameter<?> output = outputs.values().iterator().next();
                // only one output
                if (SimpleFeatureCollection.class.isAssignableFrom(output.getType())) {
                    hasVectorTransformation = true;
                    break;
                } else if (GridCoverage2D.class.isAssignableFrom(output.getType())) {
                    hasRasterTransformation = true;
                    break;
                }
            }
        }
        final boolean buildRasterLegend = (!strict && layer == null && LegendUtils.checkRasterSymbolizer(gt2Style)) || (LegendUtils.checkGridLayer(layer) && !hasVectorTransformation) || hasRasterTransformation;
        // Just checks LegendInfo currently, should check gtStyle
        final boolean useProvidedLegend = layer != null && legend.getLayerInfo() != null;
        RenderedImage legendImage = null;
        if (useProvidedLegend) {
            legendImage = getLayerLegend(legend, w, h, transparent, request);
        }
        if (buildRasterLegend) {
            final RasterLayerLegendHelper rasterLegendHelper = new RasterLayerLegendHelper(request, gt2Style, ruleName);
            final BufferedImage image = rasterLegendHelper.getLegend();
            if (image != null) {
                if (titleImage != null) {
                    layersImages.add(titleImage);
                }
                layersImages.add(image);
            }
        } else if (useProvidedLegend && legendImage != null) {
            if (titleImage != null) {
                layersImages.add(titleImage);
            }
            layersImages.add(legendImage);
        } else {
            final Feature sampleFeature;
            if (layer == null || hasVectorTransformation) {
                sampleFeature = createSampleFeature();
            } else {
                sampleFeature = createSampleFeature(layer);
            }
            final FeatureTypeStyle[] ftStyles = gt2Style.featureTypeStyles().toArray(new FeatureTypeStyle[0]);
            final double scaleDenominator = request.getScale();
            Rule[] applicableRules;
            if (ruleName != null) {
                Rule rule = LegendUtils.getRule(ftStyles, ruleName);
                if (rule == null) {
                    throw new ServiceException("Specified style does not contains a rule named " + ruleName);
                }
                applicableRules = new Rule[] { rule };
            } else {
                applicableRules = LegendUtils.getApplicableRules(ftStyles, scaleDenominator);
            }
            // do we have to alter the style to do context sensitive feature counts?
            if (countProcessor != null && !forceLabelsOff) {
                applicableRules = updateRuleTitles(countProcessor, legend, applicableRules);
            }
            final NumberRange<Double> scaleRange = NumberRange.create(scaleDenominator, scaleDenominator);
            final int ruleCount = applicableRules.length;
            /**
             * A legend graphic is produced for each applicable rule. They're being held here
             * until the process is done and then painted on a "stack" like legend.
             */
            final List<RenderedImage> legendsStack = new ArrayList<RenderedImage>(ruleCount);
            final SLDStyleFactory styleFactory = new SLDStyleFactory();
            double minimumSymbolSize = MINIMUM_SYMBOL_SIZE;
            // get minSymbolSize from LEGEND_OPTIONS, if defined
            if (request.getLegendOptions().get("minSymbolSize") instanceof String) {
                String minSymbolSizeOpt = (String) request.getLegendOptions().get("minSymbolSize");
                try {
                    minimumSymbolSize = Double.parseDouble(minSymbolSizeOpt);
                } catch (NumberFormatException e) {
                    throw new IllegalArgumentException("Invalid minSymbolSize value: should be a number");
                }
            }
            // calculate the symbols rescaling factor necessary for them to be
            // drawn inside the icon box
            double symbolScale = calcSymbolScale(w, h, layer, sampleFeature, applicableRules, minimumSymbolSize);
            for (int i = 0; i < ruleCount; i++) {
                final RenderedImage image = ImageUtils.createImage(w, h, (IndexColorModel) null, transparent);
                final Map<RenderingHints.Key, Object> hintsMap = new HashMap<RenderingHints.Key, Object>();
                final Graphics2D graphics = ImageUtils.prepareTransparency(transparent, LegendUtils.getBackgroundColor(request), image, hintsMap);
                graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
                Feature sample = getSampleFeatureForRule(layer, sampleFeature, applicableRules[i]);
                FilterFactory ff = CommonFactoryFinder.getFilterFactory();
                final Symbolizer[] symbolizers = applicableRules[i].getSymbolizers();
                final GraphicLegend graphic = applicableRules[i].getLegend();
                // If this rule has a legend graphic defined in the SLD, use it
                if (graphic != null) {
                    if (this.samplePoint == null) {
                        Coordinate coord = new Coordinate(w / 2, h / 2);
                        try {
                            this.samplePoint = new LiteShape2(geomFac.createPoint(coord), null, null, false);
                        } catch (Exception e) {
                            this.samplePoint = null;
                        }
                    }
                    shapePainter.paint(graphics, this.samplePoint, graphic, scaleDenominator, false);
                } else {
                    for (int sIdx = 0; sIdx < symbolizers.length; sIdx++) {
                        Symbolizer symbolizer = symbolizers[sIdx];
                        if (symbolizer instanceof RasterSymbolizer) {
                        // skip it
                        } else {
                            // rescale symbols if needed
                            if (symbolScale > 1.0 && symbolizer instanceof PointSymbolizer) {
                                PointSymbolizer pointSymbolizer = (PointSymbolizer) cloneSymbolizer(symbolizer);
                                if (pointSymbolizer.getGraphic() != null) {
                                    double size = getGraphicSize(sample, pointSymbolizer.getGraphic(), Math.min(w, h) - 4);
                                    pointSymbolizer.getGraphic().setSize(ff.literal(size / symbolScale + minimumSymbolSize));
                                    symbolizer = pointSymbolizer;
                                }
                            }
                            if (!(Math.abs(imageSizeFactor - 1.0) < 0.0001)) {
                                if (symbolizer instanceof PointSymbolizer) {
                                    PointSymbolizer pointSymbolizer2 = (PointSymbolizer) cloneSymbolizer(symbolizer);
                                    if (pointSymbolizer2.getGraphic() != null) {
                                        double size = getGraphicSize(sample, pointSymbolizer2.getGraphic(), Math.min(w, h) - 4);
                                        pointSymbolizer2.getGraphic().setSize(ff.literal(size * imageSizeFactor + minimumSymbolSize));
                                        symbolizer = pointSymbolizer2;
                                    }
                                } else if (symbolizer instanceof PolygonSymbolizer) {
                                    PolygonSymbolizer polygonSymbolizer2 = (PolygonSymbolizer) cloneSymbolizer(symbolizer);
                                    if (polygonSymbolizer2.getFill() != null) {
                                        // Fill
                                        double size = 0.0;
                                        if (polygonSymbolizer2.getFill().getGraphicFill() != null) {
                                            size = getGraphicSize(sample, polygonSymbolizer2.getFill().getGraphicFill(), Math.min(w, h) - 4);
                                            polygonSymbolizer2.getFill().getGraphicFill().setSize(ff.literal(size * imageSizeFactor + minimumSymbolSize));
                                        }
                                    }
                                    if (polygonSymbolizer2.getStroke() != null) {
                                        // Stroke
                                        double size = getGraphicSize(sample, polygonSymbolizer2.getStroke().getGraphicFill(), Math.min(w, h) - 4);
                                        polygonSymbolizer2.getStroke().getGraphicFill().setSize(ff.literal(size * imageSizeFactor + minimumSymbolSize));
                                        if (polygonSymbolizer2.getStroke().getGraphicStroke() != null) {
                                            size = getGraphicSize(sample, polygonSymbolizer2.getStroke().getGraphicStroke(), Math.min(w, h) - 4);
                                            polygonSymbolizer2.getStroke().getGraphicStroke().setSize(ff.literal(size * imageSizeFactor + minimumSymbolSize));
                                        }
                                    }
                                    symbolizer = polygonSymbolizer2;
                                } else if (symbolizer instanceof LineSymbolizer) {
                                    LineSymbolizer lineSymbolizer2 = (LineSymbolizer) cloneSymbolizer(symbolizer);
                                    if (lineSymbolizer2.getStroke() != null) {
                                        // Stroke
                                        double size = 0.0;
                                        if (lineSymbolizer2.getStroke().getGraphicFill() != null) {
                                            size = getGraphicSize(sample, lineSymbolizer2.getStroke().getGraphicFill(), Math.min(w, h) - 4);
                                            lineSymbolizer2.getStroke().getGraphicFill().setSize(ff.literal(size * imageSizeFactor + minimumSymbolSize));
                                        }
                                        if (lineSymbolizer2.getStroke().getGraphicStroke() != null) {
                                            size = getGraphicSize(sample, lineSymbolizer2.getStroke().getGraphicStroke(), Math.min(w, h) - 4);
                                            lineSymbolizer2.getStroke().getGraphicStroke().setSize(ff.literal(size * imageSizeFactor + minimumSymbolSize));
                                        }
                                        if (lineSymbolizer2.getStroke().getWidth() != null) {
                                            size = getWidthSize(sample, lineSymbolizer2.getStroke().getWidth(), 1);
                                            lineSymbolizer2.getStroke().setWidth(ff.literal(size * imageSizeFactor));
                                        }
                                    }
                                    symbolizer = lineSymbolizer2;
                                }
                            }
                        }
                        Style2D style2d = styleFactory.createStyle(sample, symbolizer, scaleRange);
                        LiteShape2 shape = getSampleShape(symbolizer, w, h);
                        if (style2d != null) {
                            shapePainter.paint(graphics, shape, style2d, scaleDenominator);
                        }
                    }
                }
                if (image != null && titleImage != null) {
                    layersImages.add(titleImage);
                    titleImage = null;
                }
                legendsStack.add(image);
                graphics.dispose();
            }
            int labelMargin = 3;
            if (!StringUtils.isEmpty(request.getLegendOptions().get("labelMargin"))) {
                labelMargin = Integer.parseInt(request.getLegendOptions().get("labelMargin").toString());
            }
            LegendMerger.MergeOptions options = LegendMerger.MergeOptions.createFromRequest(legendsStack, 0, 0, 0, labelMargin, request, forceLabelsOn, forceLabelsOff, forceTitlesOff);
            if (ruleCount > 0) {
                BufferedImage image = LegendMerger.mergeLegends(applicableRules, request, options);
                if (image != null) {
                    layersImages.add(image);
                }
            }
        }
    }
    // all legend graphics are merged if we have a layer group
    BufferedImage finalLegend = mergeGroups(layersImages, null, request, forceLabelsOn, forceLabelsOff, forceTitlesOff);
    if (finalLegend == null) {
        throw new IllegalArgumentException("no legend passed");
    }
    return finalLegend;
}
Also used : PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) ArrayList(java.util.ArrayList) LineString(com.vividsolutions.jts.geom.LineString) SimpleFeature(org.opengis.feature.simple.SimpleFeature) Feature(org.opengis.feature.Feature) FilterFactory(org.opengis.filter.FilterFactory) Name(org.opengis.feature.type.Name) List(java.util.List) ArrayList(java.util.ArrayList) GraphicLegend(org.opengis.style.GraphicLegend) UomRescaleStyleVisitor(org.geotools.styling.visitor.UomRescaleStyleVisitor) ProcessFunction(org.geotools.process.function.ProcessFunction) RasterSymbolizer(org.geotools.styling.RasterSymbolizer) ServiceException(org.geoserver.platform.ServiceException) Coordinate(com.vividsolutions.jts.geom.Coordinate) LineSymbolizer(org.geotools.styling.LineSymbolizer) Rule(org.geotools.styling.Rule) Map(java.util.Map) HashMap(java.util.HashMap) SimpleFeatureType(org.opengis.feature.simple.SimpleFeatureType) FeatureType(org.opengis.feature.type.FeatureType) BufferedImage(java.awt.image.BufferedImage) RenderingHints(java.awt.RenderingHints) Style2D(org.geotools.renderer.style.Style2D) DpiRescaleStyleVisitor(org.geotools.styling.visitor.DpiRescaleStyleVisitor) SLDStyleFactory(org.geotools.renderer.style.SLDStyleFactory) Style(org.geotools.styling.Style) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) LiteShape2(org.geotools.geometry.jts.LiteShape2) IndexColorModel(java.awt.image.IndexColorModel) PointSymbolizer(org.geotools.styling.PointSymbolizer) GridCoverage2D(org.geotools.coverage.grid.GridCoverage2D) Point(com.vividsolutions.jts.geom.Point) ServiceException(org.geoserver.platform.ServiceException) SchemaException(org.geotools.feature.SchemaException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) IllegalAttributeException(org.opengis.feature.IllegalAttributeException) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) Symbolizer(org.geotools.styling.Symbolizer) TextSymbolizer(org.geotools.styling.TextSymbolizer) LineSymbolizer(org.geotools.styling.LineSymbolizer) PointSymbolizer(org.geotools.styling.PointSymbolizer) RasterSymbolizer(org.geotools.styling.RasterSymbolizer) Graphics2D(java.awt.Graphics2D) NumberRange(org.geotools.util.NumberRange) Expression(org.opengis.filter.expression.Expression) Parameter(org.geotools.data.Parameter) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) RenderedImage(java.awt.image.RenderedImage) LegendRequest(org.geoserver.wms.GetLegendGraphicRequest.LegendRequest)

Example 59 with FilterFactory

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

the class ColourRampTest method testColourRamp.

/**
 * Test method for {@link com.sldeditor.colourramp.ColourRamp#ColourRamp()}.
 */
@Test
public void testColourRamp() {
    ColourRamp ramp = new ColourRamp();
    assertEquals(Color.BLACK, ramp.getStartColour());
    assertEquals(Color.WHITE, ramp.getEndColour());
    Color expectedStart = Color.red;
    Color expectedEnd = Color.pink;
    ramp.setColourRamp(expectedStart, expectedEnd);
    assertEquals(expectedStart, ramp.getStartColour());
    assertEquals(expectedEnd, ramp.getEndColour());
    Color expectedEnd2 = Color.cyan;
    ramp.addColour(expectedEnd2);
    assertEquals(expectedStart, ramp.getStartColour());
    assertEquals(expectedEnd2, ramp.getEndColour());
    assertEquals(3, ramp.getColourList().size());
    ImageIcon icon1 = ramp.getImageIcon(false);
    assertNotNull(icon1);
    ImageIcon icon2 = ramp.getImageIcon(true);
    assertNotNull(icon2);
    FilterFactory ff = CommonFactoryFinder.getFilterFactory(null);
    ColourRampData data = new ColourRampData();
    Expression expectedMinValue = ff.literal(1);
    Expression expectedMaxValue = ff.literal(10);
    data.setColourRamp(ramp);
    data.setMinValue(1);
    data.setMaxValue(10);
    Expression actualStart = ramp.getColour(data, expectedMinValue, false);
    @SuppressWarnings("unused") Expression actualEnd = ramp.getColour(data, expectedMaxValue, false);
    assertEquals(ColourUtils.toColour(actualStart.toString()), expectedStart);
    // Can't test end value
    // assertEquals(ColourUtils.toColour(actualEnd.toString()), expectedEnd2);
    // Reverse colours
    actualStart = ramp.getColour(data, expectedMinValue, true);
    actualEnd = ramp.getColour(data, expectedMaxValue, true);
    assertEquals(ColourUtils.toColour(actualStart.toString()), expectedEnd2);
// Can't test end value
// assertEquals(ColourUtils.toColour(actualEnd.toString()), expectedStart);
}
Also used : ColourRampData(com.sldeditor.colourramp.ramp.ColourRampData) ImageIcon(javax.swing.ImageIcon) ColourRamp(com.sldeditor.colourramp.ColourRamp) Expression(org.opengis.filter.expression.Expression) Color(java.awt.Color) FilterFactory(org.opengis.filter.FilterFactory) Test(org.junit.Test)

Example 60 with FilterFactory

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

the class FieldConfigGeometryFieldTest method testGenerateExpression.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigGeometryField#generateExpression()}. Test
 * method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigGeometryField#populateExpression(java.lang.Object)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigGeometryField#populateField(java.lang.String)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigGeometryField#setTestValue(com.sldeditor.ui.detail.config.FieldId, java.lang.String)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigGeometryField#getStringValue()}.
 */
@Test
public void testGenerateExpression() {
    class TestFieldConfigGeometryField extends FieldConfigGeometryField {

        public TestFieldConfigGeometryField(FieldConfigCommonData commonData) {
            super(commonData);
        }

        public Expression callGenerateExpression() {
            return generateExpression();
        }
    }
    TestFieldConfigGeometryField field = new TestFieldConfigGeometryField(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", false));
    Expression actualExpression = field.callGenerateExpression();
    assertNull(actualExpression);
    field.createUI();
    TestDataSource testDataSource = new TestDataSource();
    @SuppressWarnings("unused") DataSourceInterface dataSource = DataSourceFactory.createDataSource(testDataSource);
    field.dataSourceLoaded(GeometryTypeEnum.POLYGON, false);
    String expectedValue = "";
    field.setTestValue(FieldIdEnum.UNKNOWN, expectedValue);
    actualExpression = field.callGenerateExpression();
    assertTrue(expectedValue.compareTo(actualExpression.toString()) == 0);
    // Attribute expression
    FilterFactory ff = CommonFactoryFinder.getFilterFactory();
    Expression expectedExpression = ff.property(testDataSource.getDefaultGeometryField());
    field.populateExpression(expectedExpression);
    actualExpression = field.callGenerateExpression();
    assertTrue(expectedExpression.toString().compareTo(actualExpression.toString()) == 0);
    // Literal expression
    expectedExpression = ff.literal(testDataSource.getDefaultGeometryField());
    field.populateExpression(expectedExpression);
    actualExpression = field.callGenerateExpression();
    assertTrue(expectedExpression.toString().compareTo(actualExpression.toString()) == 0);
    field.populateField((String) null);
    String stringValue = field.getStringValue();
    assertNull(stringValue);
}
Also used : DataSourceInterface(com.sldeditor.datasource.DataSourceInterface) CreateDataSourceInterface(com.sldeditor.datasource.impl.CreateDataSourceInterface) Expression(org.opengis.filter.expression.Expression) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldConfigGeometryField(com.sldeditor.ui.detail.config.FieldConfigGeometryField) 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