org.geotools.filter.FilterFactoryImpl Java Examples

The following examples show how to use org.geotools.filter.FilterFactoryImpl. 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: GeoWaveFeatureReaderTest.java    From geowave with Apache License 2.0 6 votes vote down vote up
@Test
public void testSmallBBOX() throws IllegalArgumentException, NoSuchElementException, IOException {
  final FilterFactoryImpl factory = new FilterFactoryImpl();
  final Query query =
      new Query(
          "GeoWaveFeatureReaderTest",
          factory.bbox("geometry", 28, 41, 28.5, 41.5, "EPSG:4326"),
          new String[] {"geometry", "pid"});

  final FeatureReader<SimpleFeatureType, SimpleFeature> reader =
      dataStore.getFeatureReader(query, Transaction.AUTO_COMMIT);
  int count = 0;
  while (reader.hasNext()) {
    final SimpleFeature feature = reader.next();
    assertTrue(fids.contains(feature.getID()));
    count++;
  }
  assertEquals(1, count);
}
 
Example #2
Source File: GeoWaveFeatureReaderTest.java    From geowave with Apache License 2.0 6 votes vote down vote up
@Test
public void testBBOX() throws IllegalArgumentException, NoSuchElementException, IOException {
  final FilterFactoryImpl factory = new FilterFactoryImpl();
  final Query query =
      new Query(
          "GeoWaveFeatureReaderTest",
          factory.bbox("geometry", -180, -90, 180, 90, "EPSG:4326"),
          new String[] {"geometry", "pid"});

  final FeatureReader<SimpleFeatureType, SimpleFeature> reader =
      dataStore.getFeatureReader(query, Transaction.AUTO_COMMIT);
  int count = 0;
  while (reader.hasNext()) {
    final SimpleFeature feature = reader.next();
    assertTrue(fids.contains(feature.getID()));
    count++;
  }
  assertTrue(count > 0);
}
 
Example #3
Source File: GeoWaveFeatureReaderTest.java    From rya with Apache License 2.0 5 votes vote down vote up
@Test
public void testBBOX() throws IllegalArgumentException, NoSuchElementException, IOException {
    final FilterFactoryImpl factory = new FilterFactoryImpl();
    final Query query = new Query(
            "GeoWaveFeatureReaderTest",
            factory.bbox(
                    "",
                    -180,
                    -90,
                    180,
                    90,
                    "EPSG:4326"),
            new String[] {
                "geometry",
                "pid"
            });

    final FeatureReader<SimpleFeatureType, SimpleFeature> reader =
        dataStore.getFeatureReader(query, Transaction.AUTO_COMMIT);
    int count = 0;
    while (reader.hasNext()) {
        final SimpleFeature feature = reader.next();
        assertTrue(fids.contains(feature.getID()));
        count++;
    }
    assertTrue(count > 0);
}
 
Example #4
Source File: CQLQueryFilterTest.java    From geowave with Apache License 2.0 5 votes vote down vote up
@Test
public void test() {
  final FilterFactoryImpl factory = new FilterFactoryImpl();
  final Expression exp1 = factory.property("pid");
  final Expression exp2 = factory.literal("a89dhd-123-abc");
  final Filter f = factory.equal(exp1, exp2, false);
  final Index spatialIndex =
      new SpatialDimensionalityTypeProvider().createIndex(new SpatialOptions());

  final FeatureDataAdapter adapter = new FeatureDataAdapter(type);
  adapter.init(spatialIndex);
  final ExplicitCQLQuery cqlQuery = new ExplicitCQLQuery(null, f, adapter);

  final List<QueryFilter> filters = cqlQuery.createFilters(spatialIndex);
  final List<QueryFilter> dFilters = new ArrayList<>();
  for (final QueryFilter filter : filters) {
    dFilters.add(filter);
  }

  final FilterList dFilterList = new FilterList(dFilters);

  assertTrue(
      dFilterList.accept(
          spatialIndex.getIndexModel(),
          getEncodings(
              spatialIndex,
              adapter.encode(createFeature(), spatialIndex.getIndexModel())).get(0)));
}
 
Example #5
Source File: FilterToCQLToolTest.java    From geowave with Apache License 2.0 5 votes vote down vote up
@Test
public void tesFid() {
  final FilterFactoryImpl factory = new FilterFactoryImpl();
  final Id f = factory.id(new FeatureIdImpl("123-abc"));
  final String ss = ECQL.toCQL(f);
  System.out.println(ss);
  assertTrue(ss.contains("'123-abc'"));
}
 
Example #6
Source File: FilterToCQLToolTest.java    From geowave with Apache License 2.0 5 votes vote down vote up
@Test
public void test() {
  final FilterFactoryImpl factory = new FilterFactoryImpl();
  final Expression exp1 = factory.property("pid");
  final Expression exp2 = factory.literal("a89dhd-123-abc");
  final Filter f = factory.equal(exp1, exp2, false);
  final String ss = ECQL.toCQL(f);
  assertTrue(ss.contains("'a89dhd-123-abc'"));
}