org.opengis.filter.FilterFactory Java Examples
The following examples show how to use
org.opengis.filter.FilterFactory.
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: ElasticFeatureFilterIT.java From elasticgeo with GNU General Public License v3.0 | 6 votes |
@Test public void testGetFeaturesWithORLogicFilter() throws Exception { init(); FilterFactory ff = dataStore.getFilterFactory(); PropertyIsEqualTo property1 = ff.equals(ff.property("vendor_s"), ff.literal("D-Link")); PropertyIsEqualTo property2 = ff.equals(ff.property("vendor_s"), ff.literal("Linksys")); Or filter = ff.or(property1, property2); SimpleFeatureCollection features = featureSource.getFeatures(filter); assertEquals(6, features.size()); SimpleFeatureIterator iterator = features.features(); while (iterator.hasNext()) { SimpleFeature f = iterator.next(); assertTrue(f.getAttribute("vendor_s").equals("D-Link") || f.getAttribute("vendor_s").equals("Linksys")); } }
Example #2
Source File: ElasticViewParametersFilterIT.java From elasticgeo with GNU General Public License v3.0 | 6 votes |
@Test public void testEncodedNativeTermQuery() throws Exception { init("not-active"); Map<String, String> vparams = new HashMap<>(); Map<String,Object> query = ImmutableMap.of("term", ImmutableMap.of("security_ss", "WPA")); vparams.put("q", URLEncoder.encode(mapper.writeValueAsString(query), "UTF-8")); Hints hints = new Hints(Hints.VIRTUAL_TABLE_PARAMETERS, vparams); Query q = new Query(featureSource.getSchema().getTypeName()); q.setHints(hints); FilterFactory ff = dataStore.getFilterFactory(); PropertyIsEqualTo filter = ff.equals(ff.property("speed_is"), ff.literal("300")); q.setFilter(filter); ContentFeatureCollection features = featureSource.getFeatures(q); assertEquals(1, features.size()); SimpleFeatureIterator fsi = features.features(); assertTrue(fsi.hasNext()); assertEquals(fsi.next().getID(), "active.12"); }
Example #3
Source File: ElasticViewParametersFilterIT.java From elasticgeo with GNU General Public License v3.0 | 6 votes |
@Test public void testNativeBooleanQuery() throws Exception { init(); Map<String, String> vparams = new HashMap<>(); Map<String,Object> query = ImmutableMap.of("bool", ImmutableMap.of("must", ImmutableMap.of("term", ImmutableMap.of("security_ss", "WPA")), "must_not", ImmutableMap.of("term", ImmutableMap.of("modem_b", true)))); vparams.put("q", mapper.writeValueAsString(query)); Hints hints = new Hints(Hints.VIRTUAL_TABLE_PARAMETERS, vparams); Query q = new Query(featureSource.getSchema().getTypeName()); q.setHints(hints); FilterFactory ff = dataStore.getFilterFactory(); PropertyIsEqualTo filter = ff.equals(ff.property("speed_is"), ff.literal("300")); q.setFilter(filter); ContentFeatureCollection features = featureSource.getFeatures(q); assertEquals(2, features.size()); SimpleFeatureIterator fsi = features.features(); assertTrue(fsi.hasNext()); assertEquals(fsi.next().getAttribute("modem_b"), false); assertTrue(fsi.hasNext()); assertEquals(fsi.next().getAttribute("modem_b"), false); }
Example #4
Source File: ExpressionPanelv2Test.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** * Test method for {@link * com.sldeditor.filter.v2.expression.ExpressionPanelv2#ExpressionPanelv2(java.util.List)}. */ @Test public void testExpressionPanelv2Property() { TestExpressionPanelv2 testObj = new TestExpressionPanelv2(null); assertNull(testObj.getVendorOptionList()); testObj.dataSourceAboutToUnloaded(null); testObj.populate((String) null); testObj.configure("title", String.class, false); testObj.testShowExpressionDialog(null, null); FilterFactory ff = CommonFactoryFinder.getFilterFactory(); Expression expectedExpression = ff.add(ff.property("field"), ff.literal(42)); testObj.populate(expectedExpression); testObj.testShowExpressionDialog(Integer.class, expectedExpression); assertEquals(testObj.getExpression().toString(), testObj.getExpressionString()); testObj.dataSourceLoaded(GeometryTypeEnum.POLYGON, true); testObj.dataApplied(); testObj.testSelection(); }
Example #5
Source File: ElasticFeatureFilterIT.java From elasticgeo with GNU General Public License v3.0 | 6 votes |
@Test public void testReadStringArrayWithCsvStrategy() throws Exception { init(); dataStore.setArrayEncoding(ArrayEncoding.CSV); FilterFactory ff = dataStore.getFilterFactory(); PropertyIsEqualTo filter = ff.equals(ff.property("modem_b"), ff.literal(true)); SimpleFeatureCollection features = featureSource.getFeatures(filter); assertEquals(8, features.size()); try (SimpleFeatureIterator iterator = features.features()) { assertTrue(iterator.hasNext()); SimpleFeature feature = iterator.next(); String st = (String) feature.getAttribute("standard_ss"); // changed from "IEEE 802.11b" in SolrFeatureSourceTest assertTrue(URLDecoder.decode(st, StandardCharsets.UTF_8.toString()).startsWith("IEEE 802.11")); } }
Example #6
Source File: ElasticFeatureFilterIT.java From elasticgeo with GNU General Public License v3.0 | 6 votes |
@Test public void testGetFeaturesWithQuery() throws Exception { init(); FilterFactory ff = dataStore.getFilterFactory(); PropertyIsEqualTo filter = ff.equals(ff.property("modem_b"), ff.literal(true)); Query query = new Query(); query.setPropertyNames(new String[] { "standard_ss", "security_ss" }); query.setFilter(filter); SimpleFeatureCollection features = featureSource.getFeatures(query); assertEquals(8, features.size()); try (SimpleFeatureIterator iterator = features.features()) { assertTrue(iterator.hasNext()); SimpleFeature feature = iterator.next(); assertEquals(2, feature.getAttributeCount()); String st = (String) feature.getAttribute("standard_ss"); // changed from "IEEE 802.11b" in SolrFeatureSourceTest assertTrue(st.contains("IEEE 802.11b")); } }
Example #7
Source File: FieldConfigBaseTest.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** * 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, 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); }
Example #8
Source File: ElasticTemporalFilterIT.java From elasticgeo with GNU General Public License v3.0 | 6 votes |
@Test public void testGreaterDateFilterLong() throws Exception { init(); Date testDate = new Date(1005912798000L); FilterFactory ff = dataStore.getFilterFactory(); Filter f = ff.greaterOrEqual(ff.property("installed_td"), ff.literal(testDate.getTime())); SimpleFeatureCollection features = featureSource.getFeatures(f); assertEquals(7, features.size()); SimpleFeatureIterator it = features.features(); while (it.hasNext()) { SimpleFeature next = it.next(); Date date = (Date) next.getAttribute("installed_td"); assertTrue(date.after(testDate) || date.equals(testDate)); } it.close(); }
Example #9
Source File: DetailsUtilitiesTest.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** * 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)); }
Example #10
Source File: ArrowUtilsTest.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** * 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)); }
Example #11
Source File: SelectedSymbolTest.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** * 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)); }
Example #12
Source File: VOGeoServerContrastEnhancementNormalizeGreyTest.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: VOGeoServerContrastEnhancementNormalizeGreyTest.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** * 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; }
Example #14
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 #15
Source File: VOGeoServerContrastEnhancementNormalizeOverallTest.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** * 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; }
Example #16
Source File: VOGeoServerContrastEnhancementNormalizeBlueTest.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 #17
Source File: StyleGenerator.java From constellation with Apache License 2.0 | 6 votes |
private static Rule makeFillRule() { final FilterFactory filterFactory = CommonFactoryFinder.getFilterFactory(); final StyleFactory styleFactory = CommonFactoryFinder.getStyleFactory(); // create a partially opaque outline stroke final Stroke stroke = styleFactory.createStroke( filterFactory.literal(Color.BLACK), filterFactory.literal(1), filterFactory.literal(.5) ); // create a partially opaque fill Fill fill = styleFactory.createFill( filterFactory.literal(COLORS.next()), filterFactory.literal(.5) ); // setting the geometryPropertyName arg to null signals that we want to draw the default geometry of features final PolygonSymbolizer sym = styleFactory.createPolygonSymbolizer(stroke, fill, null); final Rule rule = styleFactory.createRule(); rule.symbolizers().add(sym); return rule; }
Example #18
Source File: VOGeoServerContrastEnhancementNormalizeGreenTest.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** * 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; }
Example #19
Source File: ElasticTemporalFilterIT.java From elasticgeo with GNU General Public License v3.0 | 5 votes |
@Test public void testBegunBy() throws Exception { init(); Period period = period("2004-20-06 03:44:56", "2014-22-06 03:44:56"); FilterFactory ff = dataStore.getFilterFactory(); Filter f = ff.begunBy(ff.literal(period), ff.property("installed_tdt")); SimpleFeatureCollection features = featureSource.getFeatures(f); assertEquals(1, features.size()); }
Example #20
Source File: ElasticTemporalFilterIT.java From elasticgeo with GNU General Public License v3.0 | 5 votes |
@Test public void testTContains() throws Exception { init(); Period period = period("2004-19-06 03:44:56", "2004-20-06 03:44:58"); FilterFactory ff = dataStore.getFilterFactory(); Filter f = ff.tcontains(ff.literal(period), ff.property("installed_tdt")); SimpleFeatureCollection features = featureSource.getFeatures(f); assertEquals(1, features.size()); }
Example #21
Source File: ElasticTemporalFilterIT.java From elasticgeo with GNU General Public License v3.0 | 5 votes |
@Test public void testDuring() throws Exception { init(); Period period = period("2004-19-06 03:44:56", "2004-20-06 03:44:58"); FilterFactory ff = dataStore.getFilterFactory(); Filter f = ff.during(ff.property("installed_tdt"), ff.literal(period)); SimpleFeatureCollection features = featureSource.getFeatures(f); assertEquals(1, features.size()); }
Example #22
Source File: ElasticTemporalFilterIT.java From elasticgeo with GNU General Public License v3.0 | 5 votes |
@Test public void testEnds() throws Exception { init(); Period period = period("2002-20-06 03:44:56", "2004-20-06 03:44:56"); FilterFactory ff = dataStore.getFilterFactory(); Filter f = ff.ends(ff.property("installed_tdt"), ff.literal(period)); SimpleFeatureCollection features = featureSource.getFeatures(f); assertEquals(1, features.size()); }
Example #23
Source File: ExpressionPanelv2Test.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** * Test method for {@link * com.sldeditor.filter.v2.expression.ExpressionPanelv2#ExpressionPanelv2(java.util.List)}. */ @Test public void testExpressionPanelv2Concatenate() { TestExpressionPanelv2 testObj = new TestExpressionPanelv2(null); assertNull(testObj.getVendorOptionList()); testObj.dataSourceAboutToUnloaded(null); testObj.populate((String) null); testObj.configure("title", String.class, false); testObj.testShowExpressionDialog(null, null); FilterFactory ff = CommonFactoryFinder.getFilterFactory(); FunctionImpl expectedExpression = new ConcatenateFunction(); List<Expression> params = new ArrayList<Expression>(); params.add(ff.literal("world")); params.add(ff.literal("dog")); expectedExpression.setParameters(params); testObj.populate(expectedExpression); testObj.testShowExpressionDialog(String.class, expectedExpression); assertEquals(testObj.getExpression().toString(), testObj.getExpressionString()); testObj.dataApplied(); testObj.testSelection(); }
Example #24
Source File: ElasticGeometryFilterIT.java From elasticgeo with GNU General Public License v3.0 | 5 votes |
@Test public void testBBOXFilter() throws Exception { init(); FilterFactory ff = dataStore.getFilterFactory(); BBOX bbox = ff.bbox("geo", -180, -98, 180, 98, "EPSG:" + SOURCE_SRID); SimpleFeatureCollection features = featureSource.getFeatures(bbox); assertEquals(11, features.size()); }
Example #25
Source File: MathsExpressionPanelTest.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** * Test method for {@link * com.sldeditor.filter.v2.expression.MathsExpressionPanel#MathsExpressionPanel(com.sldeditor.ui.attribute.SubPanelUpdatedInterface)}. */ @Test void testMathsExpressionPanel() { FilterFactory ff = CommonFactoryFinder.getFilterFactory(); MathsExpressionPanel testObj = new MathsExpressionPanel( new SubPanelUpdatedInterface() { @Override public void updateSymbol() {} @Override public void parameterAdded() {} }); // Invalid testObj.setExpression(null); assertEquals(null, testObj.getExpression()); // Add testObj.setExpression(ff.add(null, null)); assertEquals(AddImpl.class, testObj.getExpression().getClass()); assertEquals("Add", testObj.getSelectedItem()); // Subtract testObj.setExpression(ff.subtract(null, null)); assertEquals(SubtractImpl.class, testObj.getExpression().getClass()); // Multiply testObj.setExpression(ff.multiply(null, null)); assertEquals(MultiplyImpl.class, testObj.getExpression().getClass()); // Divide testObj.setExpression(ff.divide(null, null)); assertEquals(DivideImpl.class, testObj.getExpression().getClass()); testObj.setPanelEnabled(true); }
Example #26
Source File: ElasticFeatureFilterIT.java From elasticgeo with GNU General Public License v3.0 | 5 votes |
@Test public void testGetFeaturesWithIsBetweenFilterOnNestedType() throws Exception { init(); FilterFactory ff = dataStore.getFilterFactory(); PropertyIsBetween f = ff.between(ff.property("nested.hej"), ff.literal(5), ff.literal(15)); SimpleFeatureCollection features = featureSource.getFeatures(f); assertEquals(10, features.size()); }
Example #27
Source File: EnvironmentVariablePanelTest.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** * Test method for {@link * com.sldeditor.filter.v2.envvar.EnvironmentVariablePanel#EnvironmentVariablePanel(com.sldeditor.filter.v2.expression.ExpressionFilterInterface)}. */ @Test void testEnvironmentVariablePanel() { TestEnvironmentVariablePanel testObj = new TestEnvironmentVariablePanel(null); // Nothing selected testObj.revertButton(); testObj.applyButton(); testObj.dataSourceLoaded(null); TestExpressionFilterInterface receiver = new TestExpressionFilterInterface(); testObj = new TestEnvironmentVariablePanel(receiver); TestDataSourceInterface dataSource = new TestDataSourceInterface(); testObj.dataSourceLoaded(dataSource); assertFalse(receiver.dataAppliedFlag); FilterFactory ff = CommonFactoryFinder.getFilterFactory(); ExpressionNode node = new ExpressionNode(); Expression property = ff.property("Field2"); node.setExpression(property); testObj.setAttribute(property); testObj.applyButton(); assertTrue(receiver.dataAppliedFlag); receiver.dataAppliedFlag = false; testObj.setSelectedNode(node); testObj.applyButton(); assertTrue(receiver.dataAppliedFlag); }
Example #28
Source File: ColourUtilsTest.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** * 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); }
Example #29
Source File: IFeatureShape.java From hortonmachine with GNU General Public License v3.0 | 5 votes |
/** * Modify the attributes of this feature. * * @param names the names of the attributes to modify. * @param values the values to set. * @return the new feature if the editing has been successful. */ default public SimpleFeature modifyFeatureAttribute( String[] names, Object[] values ) { FeatureStoreInfo featureStoreInfo = getFeatureStoreInfo(); SimpleFeatureStore featureStore = featureStoreInfo.getFeatureStore(); if (featureStore != null) { Transaction transaction = new DefaultTransaction("modify"); featureStore.setTransaction(transaction); FilterFactory ff = CommonFactoryFinder.getFilterFactory(GeoTools.getDefaultHints()); Filter filter = ff.id(Collections.singleton(ff.featureId(getFeature().getID()))); try { featureStore.modifyFeatures(names, values, filter); transaction.commit(); SimpleFeature modifiedFeature = featureStore.getFeatures(filter).features().next(); return modifiedFeature; } catch (Exception eek) { try { transaction.rollback(); } catch (IOException e) { e.printStackTrace(); } } } return null; }
Example #30
Source File: ElasticFeatureFilterIT.java From elasticgeo with GNU General Public License v3.0 | 5 votes |
@Test public void testGetFeaturesWithIsGreaterThanOrEqualToFilter() throws Exception { init(); FilterFactory ff = dataStore.getFilterFactory(); PropertyIsGreaterThanOrEqualTo f = ff.greaterOrEqual(ff.property("speed_is"), ff.literal(300)); SimpleFeatureCollection features = featureSource.getFeatures(f); assertEquals(5, features.size()); }