org.opengis.filter.PropertyIsEqualTo Java Examples
The following examples show how to use
org.opengis.filter.PropertyIsEqualTo.
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: ElasticViewParametersFilterIT.java From elasticgeo with GNU General Public License v3.0 | 6 votes |
@Test public void testNativeTermQuery() 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", 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(1, features.size()); SimpleFeatureIterator fsi = features.features(); assertTrue(fsi.hasNext()); assertEquals(fsi.next().getID(), "active.12"); }
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: ExtractTimeFilterVisitor.java From geowave with Apache License 2.0 | 6 votes |
@Override public Object visit(final PropertyIsEqualTo filter, final Object data) { final TemporalConstraints leftResult = (TemporalConstraints) filter.getExpression1().accept(this, data); final TemporalConstraints rightResult = (TemporalConstraints) filter.getExpression2().accept(this, data); if (leftResult.isEmpty() || rightResult.isEmpty()) { return new TemporalConstraints(); } if (leftResult instanceof ParameterTimeConstraint) { return new ParameterTimeConstraint( new TemporalRange( rightResult.getStartRange().getStartTime(), rightResult.getEndRange().getEndTime()), leftResult.getName()); } else { return new ParameterTimeConstraint( new TemporalRange( leftResult.getStartRange().getStartTime(), leftResult.getEndRange().getEndTime()), rightResult.getName()); } }
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: 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 #8
Source File: ElasticFilterTest.java From elasticgeo with GNU General Public License v3.0 | 5 votes |
@Test public void testPropertyIsEqualToBoolean() { PropertyIsEqualTo filter = ff.equals(ff.property("booleanAttr"), ff.literal("true")); Map<String,Object> expected = ImmutableMap.of("term", ImmutableMap.of("booleanAttr", true)); builder.visit(filter, null); assertTrue(builder.createCapabilities().fullySupports(filter)); assertEquals(expected, builder.getQueryBuilder()); }
Example #9
Source File: FilterServiceTest.java From geomajas-project-server with GNU Affero General Public License v3.0 | 5 votes |
@Test public void testParseFidFilter() throws GeomajasException { Filter f1 = filterService.parseFilter("IN( 1 )"); Filter f2 = filterService.parseFilter("a.@id = 1"); Assert.assertTrue(f1 instanceof Id); Assert.assertTrue(f2 instanceof PropertyIsEqualTo); PropertyIsEqualTo piet = (PropertyIsEqualTo)f2; Assert.assertTrue(piet.getExpression1() instanceof PropertyName); Assert.assertEquals("a/@id",((PropertyName)piet.getExpression1()).getPropertyName()); }
Example #10
Source File: CriteriaVisitor.java From geomajas-project-server with GNU Affero General Public License v3.0 | 5 votes |
/** {@inheritDoc} */ @Override public Object visit(PropertyIsEqualTo filter, Object userData) { String propertyName = getPropertyName(filter.getExpression1()); String finalName = parsePropertyName(propertyName, userData); Object value = castLiteral(getLiteralValue(filter.getExpression2()), propertyName); return Restrictions.eq(finalName, value); }
Example #11
Source File: PropertyIgnoringFilterVisitor.java From geowave with Apache License 2.0 | 5 votes |
@Override public Object visit(final PropertyIsEqualTo filter, final Object extraData) { if (!usesProperty(filter)) { return Filter.INCLUDE; } return super.visit(filter, extraData); }
Example #12
Source File: PropertyIgnoringFilterVisitor.java From geowave with Apache License 2.0 | 5 votes |
@Override public Object visit(final PropertyIsEqualTo filter, final Object extraData) { if (!usesProperty(filter)) { return Filter.INCLUDE; } return super.visit(filter, extraData); }
Example #13
Source File: ElasticFeatureFilterIT.java From elasticgeo with GNU General Public License v3.0 | 5 votes |
@Test public void testGetFeaturesWithNOTLogicFilter() throws Exception { init(); FilterFactory ff = dataStore.getFilterFactory(); PropertyIsEqualTo property1 = ff.equals(ff.property("vendor_s"), ff.literal("D-Link")); Not filter = ff.not(property1); SimpleFeatureCollection features = featureSource.getFeatures(filter); assertEquals(7, features.size()); SimpleFeatureIterator iterator = features.features(); while (iterator.hasNext()) { SimpleFeature f = iterator.next(); assertTrue(!f.getAttribute("vendor_s").equals("D-Link")); } }
Example #14
Source File: ElasticFeatureFilterIT.java From elasticgeo with GNU General Public License v3.0 | 5 votes |
@Test public void testGetFeaturesWithAndLogicFilter() throws Exception { init(); FilterFactory ff = dataStore.getFilterFactory(); PropertyIsEqualTo property = ff.equals(ff.property("standard_ss"), ff.literal("IEEE 802.11b")); BBOX bbox = ff.bbox("geo", -1, -1, 10, 10, "EPSG:" + SOURCE_SRID); And filter = ff.and(property, bbox); SimpleFeatureCollection features = featureSource.getFeatures(filter); assertEquals(3, features.size()); }
Example #15
Source File: ElasticFeatureFilterIT.java From elasticgeo with GNU General Public License v3.0 | 5 votes |
@Test public void testCountWithIsEqualFilter() throws Exception { init(); FilterFactory ff = dataStore.getFilterFactory(); PropertyIsEqualTo filter = ff.equals(ff.property("vendor_s"), ff.literal("D-Link")); Query query = new Query(); query.setFilter(filter); assertEquals(4, featureSource.getCount(query)); }
Example #16
Source File: ElasticFilterTest.java From elasticgeo with GNU General Public License v3.0 | 5 votes |
@Test public void testPropertyIsEqualToInteger() { PropertyIsEqualTo filter = ff.equals(ff.property("integerAttr"), ff.literal("4")); Map<String,Object> expected = ImmutableMap.of("term", ImmutableMap.of("integerAttr", 4)); builder.visit(filter, null); assertTrue(builder.createCapabilities().fullySupports(filter)); assertEquals(expected, builder.getQueryBuilder()); }
Example #17
Source File: ElasticFilterTest.java From elasticgeo with GNU General Public License v3.0 | 5 votes |
@Test public void testPropertyIsEqualToFloat() { PropertyIsEqualTo filter = ff.equals(ff.property("floatAttr"), ff.literal("4.5")); Map<String,Object> expected = ImmutableMap.of("term", ImmutableMap.of("floatAttr", 4.5f)); builder.visit(filter, null); assertTrue(builder.createCapabilities().fullySupports(filter)); assertEquals(expected, builder.getQueryBuilder()); }
Example #18
Source File: ElasticFilterTest.java From elasticgeo with GNU General Public License v3.0 | 5 votes |
@Test public void testDoubleIsEqualtoProperty() { PropertyIsEqualTo filter = ff.equals(ff.literal("4.5"), ff.property("doubleAttr")); Map<String,Object> expected = ImmutableMap.of("term", ImmutableMap.of("doubleAttr", 4.5)); builder.visit(filter, null); assertTrue(builder.createCapabilities().fullySupports(filter)); assertEquals(expected, builder.getQueryBuilder()); }
Example #19
Source File: ElasticFilterTest.java From elasticgeo with GNU General Public License v3.0 | 5 votes |
@Test public void testPropertyIsEqualToDouble() { PropertyIsEqualTo filter = ff.equals(ff.property("doubleAttr"), ff.literal("4.5")); Map<String,Object> expected = ImmutableMap.of("term", ImmutableMap.of("doubleAttr", 4.5)); builder.visit(filter, null); assertTrue(builder.createCapabilities().fullySupports(filter)); assertEquals(expected, builder.getQueryBuilder()); }
Example #20
Source File: ElasticFilterTest.java From elasticgeo with GNU General Public License v3.0 | 5 votes |
@Test public void testNestedStringIsEqualToProperty() { PropertyIsEqualTo filter = ff.equals(ff.literal("value"), ff.property("nested.hej")); Map<String,Object> expected = ImmutableMap.of("nested", ImmutableMap.of("path", "nested", "query", ImmutableMap.of("term", ImmutableMap.of("nested.hej", "value")))); builder.visit(filter, null); assertTrue(builder.createCapabilities().fullySupports(filter)); assertEquals(expected,builder.getQueryBuilder()); }
Example #21
Source File: ElasticFilterTest.java From elasticgeo with GNU General Public License v3.0 | 5 votes |
@Test public void testNestedPropertyIsEqualToString() { PropertyIsEqualTo filter = ff.equals(ff.property("nested.hej"), ff.literal("value")); Map<String,Object> expected = ImmutableMap.of("nested", ImmutableMap.of("path", "nested", "query", ImmutableMap.of("term", ImmutableMap.of("nested.hej", "value")))); builder.visit(filter, null); assertTrue(builder.createCapabilities().fullySupports(filter)); assertEquals(expected,builder.getQueryBuilder()); }
Example #22
Source File: ElasticFilterTest.java From elasticgeo with GNU General Public License v3.0 | 5 votes |
@Test public void testPropertyIsEqualToString() { PropertyIsEqualTo filter = ff.equals(ff.property("stringAttr"), ff.literal("value")); Map<String,Object> expected = ImmutableMap.of("term", ImmutableMap.of("stringAttr", "value")); builder.visit(filter, null); assertTrue(builder.createCapabilities().fullySupports(filter)); assertEquals(expected, builder.getQueryBuilder()); }
Example #23
Source File: ElasticGeometryFilterIT.java From elasticgeo with GNU General Public License v3.0 | 5 votes |
@Test public void testBBOXAndEqualsFilter() throws Exception { init(); FilterFactory ff = dataStore.getFilterFactory(); PropertyIsEqualTo property = ff.equals(ff.property("standard_ss"), ff.literal("IEEE 802.11b")); BBOX bbox = ff.bbox("geo", -180, -180, 180, 180, "EPSG:" + SOURCE_SRID); And filter = ff.and(property, bbox); SimpleFeatureCollection features = featureSource.getFeatures(filter); assertEquals(7, features.size()); }
Example #24
Source File: UniqueValueRenderer.java From sldeditor with GNU General Public License v3.0 | 4 votes |
/** * Creates the filter. * * @param rule the rule * @param fieldsElement the fields element * @param fieldDelimiterElement the field delimiter element * @param value the value */ private void createFilter(Rule rule, JsonElement fieldsElement, JsonElement fieldDelimiterElement, String value) { if(fieldsElement == null) return; if(value == null) { rule.setElseFilter(true); } else { List<String> fieldList = new ArrayList<String>(); JsonArray fieldArray = fieldsElement.getAsJsonArray(); for(int fieldIndex = 0; fieldIndex < fieldArray.size(); fieldIndex ++) { JsonElement jsonFieldElement = fieldArray.get(fieldIndex); if(jsonFieldElement != null) { JsonObject fieldObj = jsonFieldElement.getAsJsonObject(); fieldList.add(fieldObj.get("name").getAsString()); } } String[] values = null; if(fieldDelimiterElement != null) { values = value.split(fieldDelimiterElement.getAsString()); } else { values = new String[1]; values[0] = value; } List<Filter> filterList = new ArrayList<Filter>(); int index = 0; while(index < values.length) { Expression fieldExpression = filterFactory.property(fieldList.get(index)); Expression valueExpression = filterFactory.literal(values[index]); PropertyIsEqualTo filter = filterFactory.equals(fieldExpression, valueExpression); filterList.add(filter); index ++; } Filter completeFilter = null; if(filterList.size() > 1) { completeFilter = filterFactory.and(filterList); } else if(filterList.size() == 1) { completeFilter = filterList.get(0); } rule.setFilter(completeFilter); } }
Example #25
Source File: ExtractGeometryFilterVisitor.java From geowave with Apache License 2.0 | 4 votes |
@Override public Object visit(final PropertyIsEqualTo filter, final Object data) { return new ExtractGeometryFilterVisitorResult(infinity(), null); }
Example #26
Source File: FilterToElastic.java From elasticgeo with GNU General Public License v3.0 | 2 votes |
/** * Write the FilterBuilder for this kind of filter * * @param filter the filter to visit * @param extraData extra data (unused by this method) * */ public Object visit(PropertyIsEqualTo filter, Object extraData) { visitBinaryComparisonOperator(filter, "="); return extraData; }