org.opengis.filter.expression.Expression Java Examples
The following examples show how to use
org.opengis.filter.expression.Expression.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SLDEditorBufferedImageLegendGraphicBuilder.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** * Gets a numeric value for the given graphic * * @param feature sample to be used for evals * @param pointSymbolizer symbolizer * @param defaultSize size to use is none can be taken from the graphic */ private double getWidthSize(Feature feature, Expression widthExp, int defaultSize) { if (widthExp != null) { if (widthExp instanceof Literal) { Object size = widthExp.evaluate(feature); if (size != null) { if (size instanceof Double) { return (Double) size; } try { return Double.parseDouble(size.toString()); } catch (NumberFormatException e) { return defaultSize; } } } } return defaultSize; }
Example #2
Source File: IsLessThan.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** * Creates the filter. * * @param parameterList the parameter list * @return the filter */ @Override public Filter createFilter(List<Expression> parameterList) { IsLessThenImpl filter = null; if ((parameterList == null) || (parameterList.size() < 2) || (parameterList.size() > 3)) { filter = new IsLessThanExtended(); } else { LiteralExpressionImpl matchCase = (LiteralExpressionImpl) parameterList.get(2); filter = new IsLessThanExtended( parameterList.get(0), parameterList.get(1), (Boolean) matchCase.getValue()); } return filter; }
Example #3
Source File: OmsVectorReshaper.java From hortonmachine with GNU General Public License v3.0 | 6 votes |
private List<Expression> createExpressionList( String expressionString ) { List<Expression> list = new ArrayList<Expression>(); String definition = expressionString.replaceAll("\r", "\n").replaceAll("[\n\r][\n\r]", "\n"); for( String line : definition.split("\n") ) { int mark = line.indexOf("="); if (mark != -1) { String expressionDefinition = line.substring(mark + 1).trim(); Expression expression; try { expression = CQL.toExpression(expressionDefinition); } catch (CQLException e) { throw new ModelsRuntimeException(e.toString(), this); } list.add(expression); } } return list; }
Example #4
Source File: TextSymbolizerDetails.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** * Extract font. * * @return the font */ private Font extractFont() { Font font = null; Expression fontFamily = fieldConfigVisitor.getExpression(FieldIdEnum.FONT_FAMILY); Expression fontSize = fieldConfigVisitor.getExpression(FieldIdEnum.FONT_SIZE); Expression fontStyle = fieldConfigVisitor.getExpression(FieldIdEnum.FONT_STYLE); Expression fontWeight = fieldConfigVisitor.getExpression(FieldIdEnum.FONT_WEIGHT); List<Expression> fontFamilyList = new ArrayList<>(); fontFamilyList.add(fontFamily); if ((fontStyle == null) || (fontWeight == null) || (fontSize == null)) { font = getStyleFactory().getDefaultFont(); } else { font = getStyleFactory().font(fontFamilyList, fontStyle, fontWeight, fontSize); } return font; }
Example #5
Source File: FilterServiceImpl.java From geomajas-project-server with GNU Affero General Public License v3.0 | 6 votes |
@Override public Filter createCompareFilter(String name, String comparator, Date value) { PropertyName attribute = FF.property(name); Expression val = FF.literal(value); if ("<".equals(comparator)) { return FF.less(attribute, val); } else if (">".equals(comparator)) { return FF.greater(attribute, val); } else if (">=".equals(comparator)) { return FF.greaterOrEqual(attribute, val); } else if ("<=".equals(comparator)) { return FF.lessOrEqual(attribute, val); } else if ("=".equals(comparator)) { return FF.equals(attribute, val); } else if ("==".equals(comparator)) { return FF.equals(attribute, val); } else if ("<>".equals(comparator)) { return FF.notEqual(attribute, val, false); } else { throw new IllegalArgumentException("Could not interpret compare filter. Argument (" + value + ") not known."); } }
Example #6
Source File: ParameterFunctionUtils.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** * Gets the expression list. @TODO This gets round the issue where the * org.geotools.process.function.ParameterFunction does not have a public accessor. Using * reflection and changing the accessibility flag we can read the process function data. * * @param parameter the parameter * @return the expression list */ @SuppressWarnings("unchecked") public static List<Expression> getExpressionList(Expression parameter) { List<Expression> parameterList = null; if (parameter != null) { for (Method method : parameter.getClass().getMethods()) { if (method.getName().compareTo(GET_PARAMETERS) == 0) { try { method.setAccessible(true); Object[] args = null; parameterList = (List<Expression>) method.invoke(parameter, args); return parameterList; } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { ConsoleManager.getInstance().exception(ParameterFunctionUtils.class, e); } } } } return parameterList; }
Example #7
Source File: ExpressionPanelv2.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** * Show expression dialog. * * @param type the type * @param expression the expression */ protected void showExpressionDialog(Class<?> type, Expression expression) { rootNode = createExpressionNode(); if (model != null) { model.setRoot(rootNode); ExpressionNode expressionNode = (ExpressionNode) rootNode; expressionNode.setType(type); if (expression != null) { populateExpression(expressionNode, expression); } // Auto select the first item if (tree.getRowCount() > 0) { tree.setSelectionRow(0); } } }
Example #8
Source File: FilterToElasticHelper.java From elasticgeo with GNU General Public License v3.0 | 6 votes |
private void visitComparisonSpatialOperator(BinarySpatialOperator filter, PropertyName property, Literal geometry, boolean swapped, Object extraData) { // if geography case, sanitize geometry first Literal geometry1 = clipToWorld(geometry); //noinspection RedundantCast visitBinarySpatialOperator(filter, (Expression)property, (Expression) geometry1, swapped, extraData); // if geography case, sanitize geometry first if(isWorld(geometry1)) { // nothing to filter in this case delegate.queryBuilder = MATCH_ALL; return; } else if(isEmpty(geometry1)) { if(!(filter instanceof Disjoint)) { delegate.queryBuilder = ImmutableMap.of("bool", ImmutableMap.of("must_not", MATCH_ALL)); } else { delegate.queryBuilder = MATCH_ALL; } return; } //noinspection RedundantCast visitBinarySpatialOperator(filter, (Expression)property, (Expression) geometry1, swapped, extraData); }
Example #9
Source File: FieldConfigBase.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** * Populate literal expression. * * @param expression the expression */ private void populateLiteralExpression(Expression expression) { LiteralExpressionImpl lExpression = (LiteralExpressionImpl) expression; Object objValue = lExpression.getValue(); if (objValue instanceof AttributeExpressionImpl) { expressionType = ExpressionTypeEnum.E_ATTRIBUTE; if (attributeSelectionPanel != null) { attributeSelectionPanel.setAttribute((AttributeExpressionImpl) objValue); } setCachedExpression((AttributeExpressionImpl) objValue); } else { expressionType = ExpressionTypeEnum.E_VALUE; populateExpression(objValue); valueUpdated(); } }
Example #10
Source File: NumberValues.java From sldeditor with GNU General Public License v3.0 | 6 votes |
@Override public void setValue(Object aValue) { this.value = null; this.expression = null; if (aValue instanceof Number) { this.value = (Number) aValue; } else if (aValue instanceof LiteralExpressionImpl) { LiteralExpressionImpl literal = (LiteralExpressionImpl) aValue; value = literal.evaluate(value, Number.class); } else if ((aValue instanceof AttributeExpressionImpl) || (aValue instanceof FunctionExpressionImpl) || (aValue instanceof MathExpressionImpl)) { this.expression = (Expression) aValue; } }
Example #11
Source File: VOGeoServerContrastEnhancementNormalizeRedTest.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** * 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; }
Example #12
Source File: VOGeoServerContrastEnhancementNormalizeOverallTest.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** * 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; }
Example #13
Source File: EnumValues.java From sldeditor with GNU General Public License v3.0 | 6 votes |
@Override public void setValue(Object aValue) { this.value = null; this.expression = null; if (aValue != null) { if (aValue instanceof LiteralExpressionImpl) { value = ((Expression) aValue).toString(); } else if ((aValue instanceof AttributeExpressionImpl) || (aValue instanceof FunctionExpressionImpl) || (aValue instanceof MathExpressionImpl)) { this.expression = (Expression) aValue; } else { if (aValue instanceof String) { value = ((String) aValue); } } } }
Example #14
Source File: FieldConfigInlineFeature.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** * Generate expression. * * @return the expression */ /* * (non-Javadoc) * * @see com.sldeditor.ui.detail.config.FieldConfigBase#generateExpression() */ @Override protected Expression generateExpression() { Expression expression = null; if (inlineGML != null) { String text = inlineGML.getInlineFeatures(); if ((text != null) && !text.isEmpty()) { expression = getFilterFactory().literal(text); } } return expression; }
Example #15
Source File: BooleanValues.java From sldeditor with GNU General Public License v3.0 | 6 votes |
@Override public void setValue(Object aValue) { this.value = null; this.expression = null; if (aValue instanceof Boolean) { this.value = (Boolean) aValue; } else if (aValue instanceof LiteralExpressionImpl) { LiteralExpressionImpl literal = (LiteralExpressionImpl) aValue; value = literal.evaluate(value, Boolean.class); } else if ((aValue instanceof AttributeExpressionImpl) || (aValue instanceof FunctionExpressionImpl) || (aValue instanceof MathExpressionImpl)) { this.expression = (Expression) aValue; } }
Example #16
Source File: StyleUtilities.java From hortonmachine with GNU General Public License v3.0 | 6 votes |
/** * Get the offset from a {@link Symbolizer}. * * @param symbolizer the symbolizer. * @return the offset. */ @SuppressWarnings("rawtypes") public static Point2D getOffset( Symbolizer symbolizer ) { Expression geometry = symbolizer.getGeometry(); if (geometry != null) { if (geometry instanceof FilterFunction_offset) { FilterFunction_offset offsetFunction = (FilterFunction_offset) geometry; List parameters = offsetFunction.getParameters(); Expression xOffsetExpr = (Expression) parameters.get(1); Expression yOffsetExpr = (Expression) parameters.get(2); Double xOffsetDouble = xOffsetExpr.evaluate(null, Double.class); Double yOffsetDouble = yOffsetExpr.evaluate(null, Double.class); if (xOffsetDouble != null && yOffsetDouble != null) { Point2D.Double point = new Point2D.Double(xOffsetDouble, yOffsetDouble); return point; } } } return null; }
Example #17
Source File: SimpleFillSymbol.java From sldeditor with GNU General Public License v3.0 | 6 votes |
@Override public List<Symbolizer> convertToFill(String layerName, JsonElement element, int transparency) { if(element == null) return null; JsonObject obj = element.getAsJsonObject(); List<Symbolizer> symbolizerList = new ArrayList<Symbolizer>(); Expression fillColour = getColour(obj.get(SimpleFillSymbolKeys.FILL_COLOUR)); Expression transparencyExpression = getTransparency(transparency); Fill fill = null; if(fillColour != null) { fill = styleFactory.createFill(fillColour, transparencyExpression); } PolygonSymbolizer polygon = styleFactory.createPolygonSymbolizer(); polygon.setStroke(null); polygon.setFill(fill); symbolizerList.add(polygon); return symbolizerList; }
Example #18
Source File: DWithin.java From sldeditor with GNU General Public License v3.0 | 6 votes |
@Override public String toString() { String operator = " dwithin "; String distStr = ", distance: " + getDistance(); org.opengis.filter.expression.Expression leftGeometry = getExpression1(); org.opengis.filter.expression.Expression rightGeometry = getExpression2(); if ((leftGeometry == null) && (rightGeometry == null)) { return "[ " + "null" + operator + "null" + distStr + " ]"; } else if (leftGeometry == null) { return "[ " + "null" + operator + rightGeometry.toString() + distStr + " ]"; } else if (rightGeometry == null) { return "[ " + leftGeometry.toString() + operator + "null" + distStr + " ]"; } return "[ " + leftGeometry.toString() + operator + rightGeometry.toString() + distStr + " ]"; }
Example #19
Source File: FieldConfigBase.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** * Populate. * * @param expression the expression */ public void populate(Expression expression) { if (attributeSelectionPanel != null) { attributeSelectionPanel.populateAttributeComboxBox(expression); } if (expression == null) { expressionType = ExpressionTypeEnum.E_VALUE; revertToDefaultValue(); valueUpdated(); } else { if (expression instanceof LiteralExpressionImpl) { populateLiteralExpression(expression); } else if (expression instanceof ConstantExpression) { populateConstantExpression(expression); } else if (expression instanceof NilExpression) { populateNilExpression(); } else if (expression instanceof ProcessFunction) { populateProcessFunction(expression); } else if (expression instanceof AttributeExpressionImpl) { populateAttributeExpression(expression); } else if ((expression instanceof FunctionExpressionImpl) || (expression instanceof BinaryExpression)) { expressionType = ExpressionTypeEnum.E_EXPRESSION; if (attributeSelectionPanel != null) { attributeSelectionPanel.populate(expression); } setCachedExpression(expression); } else { expressionType = ExpressionTypeEnum.E_EXPRESSION; } } setValueFieldState(); }
Example #20
Source File: FunctionField.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** * Gets the concatenate. * * @param newExpression the new expression * @param argCount the arg count * @return the concatenate */ private void getConcatenate(Expression newExpression, int argCount) { ConcatenateFunction expression = (ConcatenateFunction) newExpression; List<Expression> params = new ArrayList<>(); for (int i = 0; i < argCount; i++) { params.add(null); } boolean validSymbolFlag = (params.size() == argCount); if (validSymbolFlag) { expression.setParameters(params); } }
Example #21
Source File: StyleValues.java From sldeditor with GNU General Public License v3.0 | 5 votes |
@Override public void setValue(Object aValue) { this.value = null; this.expression = null; if (aValue instanceof Style) { this.value = (Style) aValue; } else if ((aValue instanceof AttributeExpressionImpl) || (aValue instanceof LiteralExpressionImpl) || (aValue instanceof FunctionExpressionImpl) || (aValue instanceof MathExpressionImpl)) { this.expression = (Expression) aValue; } }
Example #22
Source File: FeatureLayer.java From snap-desktop with GNU General Public License v3.0 | 5 votes |
@Override public void visit(TextSymbolizer text) { super.visit(text); TextSymbolizer textCopy = (TextSymbolizer) pages.peek(); Fill textFill = textCopy.getFill(); if (textFill != null) { Expression opacityExpression = textFill.getOpacity(); if (opacityExpression != null) { textOpacity = opacityExpression.evaluate(opacityExpression, Double.class); } } }
Example #23
Source File: FieldConfigPopulationTest.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** * Test method for {@link * com.sldeditor.ui.detail.config.FieldConfigPopulation#FieldConfigPopulation(com.sldeditor.ui.detail.GraphicPanelFieldManager)}. */ @Test public void testFieldConfigPopulation() { FieldIdEnum fieldId = FieldIdEnum.UNKNOWN; FieldConfigPopulation obj = new FieldConfigPopulation(null); obj.populateBooleanField(fieldId, Boolean.TRUE); obj.populateComboBoxField(fieldId, ""); obj.populateColourField(fieldId, null); obj.populateColourMapField(FieldIdEnum.ANCHOR_POINT_V, (ColorMap) null); obj.populateFontField(FieldIdEnum.ANCHOR_POINT_V, (Font) null); obj.populateTextField(fieldId, (String) null); obj.populateDoubleField(fieldId, (Double) null); obj.populateIntegerField(fieldId, (Integer) null); obj.populateField(fieldId, (Expression) null); obj.populateUserLayer(fieldId, (UserLayer) null); obj.populateFieldTypeConstraint(fieldId, (List<FeatureTypeConstraint>) null); assertNull(obj.getExpression(fieldId)); assertFalse(obj.getBoolean(fieldId)); assertEquals(0, obj.getInteger(fieldId)); assertTrue(Math.abs(obj.getDouble(fieldId) - 0.0) < 0.001); assertTrue(obj.getText(fieldId).compareTo("") == 0); assertNull(obj.getComboBox(fieldId)); assertNull(obj.getColourMap(fieldId)); assertNull(obj.getFieldConfig(fieldId)); assertNull(obj.getFeatureTypeConstraint(fieldId)); }
Example #24
Source File: TEquals.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** * Creates the filter. * * @param parameterList the parameter list * @return the filter */ @Override public Filter createFilter(List<Expression> parameterList) { TEqualsImpl filter = null; if ((parameterList == null) || (parameterList.size() != 2)) { filter = new TEqualsExtended(); } else { filter = new TEqualsExtended(parameterList.get(0), parameterList.get(1)); } return filter; }
Example #25
Source File: RasterSymbolizerDetails.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** * Populate contrast enhancement. * * @param rasterSymbolizer the raster symbolizer */ private void populateContrastEnhancement(RasterSymbolizer rasterSymbolizer) { ContrastEnhancement contrast = rasterSymbolizer.getContrastEnhancement(); GroupConfigInterface group = getGroup(GroupIdEnum.RASTER_CONTRAST); if (group != null) { group.enable(contrast != null); } if (contrast != null) { Expression gammaValue = contrast.getGammaValue(); fieldConfigVisitor.populateField(FieldIdEnum.RASTER_CONTRAST_GAMMAVALUE, gammaValue); populateContrastMethod(contrast, GroupIdEnum.RASTER_OVERALL_CONTRAST_METHOD); } }
Example #26
Source File: PolygonSymbolizerDetails.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** Update symbol. */ private void updateSymbol() { if (!Controller.getInstance().isPopulating()) { Expression geometryField = ExtractGeometryField.getGeometryField(fieldConfigVisitor); Expression perpendicularOffset = fieldConfigVisitor.getExpression(FieldIdEnum.PERPENDICULAR_OFFSET); // // Displacement // Displacement displacement = null; StandardData standardData = getStandardData(); PolygonSymbolizer polygonSymbolizer = (PolygonSymbolizer) SelectedSymbol.getInstance().getSymbolizer(); if (polygonSymbolizer != null) { polygonSymbolizer.setName(standardData.getName()); polygonSymbolizer.setDescription(standardData.getDescription()); polygonSymbolizer.setUnitOfMeasure( (standardData.getUnit() != null) ? standardData.getUnit().getUnit() : null); polygonSymbolizer.setDisplacement(displacement); polygonSymbolizer.setGeometry(geometryField); polygonSymbolizer.setPerpendicularOffset(perpendicularOffset); this.fireUpdateSymbol(); } } }
Example #27
Source File: EnumValues.java From sldeditor with GNU General Public License v3.0 | 5 votes |
@Override public Expression getExpression() { if (expression != null) { return expression; } if (value != null) { return filterFactory.literal(value); } return null; }
Example #28
Source File: DistributedRenderProcessUtils.java From geowave with Apache License 2.0 | 5 votes |
public static Expression getRenderingProcess() { if (SINGLETON_RENDER_PROCESS == null) { final ProcessFactory processFactory = new AnnotatedBeanProcessFactory( Text.text("Internal GeoWave Process Factory"), "internal", InternalDistributedRenderProcess.class); final Name processName = new NameImpl("internal", "InternalDistributedRender"); final RenderingProcess process = (RenderingProcess) processFactory.create(processName); final Map<String, Parameter<?>> parameters = processFactory.getParameterInfo(processName); final InternalProcessFactory factory = new InternalProcessFactory(); // this is kinda a hack, but the only way to instantiate a process // is // for it to have a registered process factory, so temporarily // register // the process factory Processors.addProcessFactory(factory); SINGLETON_RENDER_PROCESS = new RenderingProcessFunction( processName, Collections.singletonList( new ParameterFunction( null, Collections.singletonList(new LiteralExpressionImpl("data")))), parameters, process, null); Processors.removeProcessFactory(factory); } return SINGLETON_RENDER_PROCESS; }
Example #29
Source File: FunctionExpressionInterface.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** * Creates the Categorize function. * * @param functionName the function name * @param parameters the parameters */ private static void createCategorizeFunction( FunctionName functionName, List<Expression> parameters) { // CategorizeFunction needs all the fields populated for (int index = 0; index < functionName.getArguments().size() - 1; index++) { parameters.add(index, ff.literal("")); } parameters.remove(parameters.size() - 1); parameters.add(ff.literal(CategorizeFunction.PRECEDING)); }
Example #30
Source File: XMLSetFieldExpressionEx.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** * Method to part of the visitor pattern. * * @param visitor the visitor * @param fieldId the field id */ @Override public void accept(TestValueVisitor visitor, FieldIdEnum fieldId) { Expression expression = ff.property(this.expression); visitor.setTestValue(fieldId, expression); }