Java Code Examples for org.geotools.data.FeatureReader#hasNext()
The following examples show how to use
org.geotools.data.FeatureReader#hasNext() .
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 rya with Apache License 2.0 | 6 votes |
@Test public void testFidFilterQuery() throws IllegalArgumentException, NoSuchElementException, IOException, CQLException { final String fidsString = fids.stream().collect(Collectors.joining("','", "'", "'")); final Filter filter = ECQL.toFilter("IN (" + fidsString + ")"); final Query query = new Query( "GeoWaveFeatureReaderTest", filter, 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 == fids.size()); }
Example 2
Source File: GeoWaveFeatureReaderTest.java From rya with Apache License 2.0 | 6 votes |
@Test public void testPidFilterQuery() throws IllegalArgumentException, NoSuchElementException, IOException, CQLException { // Filter it so that it only queries for everything but the first pid. // There's only 2 pids total so it should just return the second one. final String pidsString = pids.subList(1, pids.size()).stream().collect(Collectors.joining("','", "'", "'")); final Filter filter = ECQL.toFilter("pid IN (" + pidsString + ")"); final Query query = new Query( "GeoWaveFeatureReaderTest", filter, 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 == pids.size() - 1); }
Example 3
Source File: GeoWaveFeatureReaderTest.java From rya with Apache License 2.0 | 6 votes |
@Test public void testLike() throws IllegalArgumentException, NoSuchElementException, IOException, CQLException { final Query query = new Query( "GeoWaveFeatureReaderTest", ECQL.toFilter("pid like '" + pids.get( 0).substring( 0, 1) + "%'"), 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 4
Source File: GeoWaveFeatureReaderTest.java From geowave with Apache License 2.0 | 6 votes |
@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 5
Source File: GeoWaveFeatureReaderTest.java From geowave with Apache License 2.0 | 6 votes |
@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 6
Source File: GeoWaveFeatureReaderTest.java From geowave with Apache License 2.0 | 6 votes |
@Test public void testLike() throws IllegalArgumentException, NoSuchElementException, IOException, CQLException { System.out.println(pids); final Query query = new Query( "GeoWaveFeatureReaderTest", ECQL.toFilter("pid like '" + pids.get(0).substring(0, 1) + "%'"), 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 7
Source File: GeoToolsAttributesSubsetTest.java From geowave with Apache License 2.0 | 6 votes |
@Test public void testSubsetAttributes() throws CQLException, IOException { final Query query = new Query( typeName, CQL.toFilter(cqlPredicate), new String[] {geometry_attribute, string_attribute}); final FeatureReader<SimpleFeatureType, SimpleFeature> reader = geotoolsDataStore.getFeatureReader(query, Transaction.AUTO_COMMIT); int count = 0; while (reader.hasNext()) { final SimpleFeature feature = reader.next(); count++; Assert.assertTrue(feature.getAttribute(geometry_attribute) != null); Assert.assertTrue(feature.getAttribute(long_attribute) == null); Assert.assertTrue(feature.getAttribute(string_attribute) != null); } Assert.assertTrue(count == 3); }
Example 8
Source File: WFSTemporalQueryTest.java From geowave with Apache License 2.0 | 6 votes |
@Test public void testTemporal() throws CQLException, IOException, ParseException { populate(); final Transaction transaction2 = new DefaultTransaction(); final Query query = new Query( "geostuff", CQL.toFilter( "BBOX(geometry,44,27,42,30) and start during 2005-05-16T20:32:56Z/2005-05-20T21:32:56Z and end during 2005-05-18T20:32:56Z/2005-05-22T21:32:56Z"), new String[] {"geometry", "start", "end", "pid"}); final FeatureReader<SimpleFeatureType, SimpleFeature> reader = dataStore.getFeatureReader(query, transaction2); int c = 0; while (reader.hasNext()) { reader.next(); c++; } reader.close(); transaction2.commit(); transaction2.close(); assertEquals(2, c); }
Example 9
Source File: AbstractGeotoolsDataStoreImporter.java From TomboloDigitalConnector with MIT License | 5 votes |
private void withSubjects(FeatureReader<SimpleFeatureType, SimpleFeature> featureReader, DataStore dataStore, BiConsumer<SimpleFeature, Subject> fn) throws IOException, FactoryException, TransformException { MathTransform crsTransform = GeotoolsDataStoreUtils.makeCrsTransform(getSourceEncoding()); while(featureReader.hasNext()) { SimpleFeature feature = featureReader.next(); buildSubjectFromFeature(feature, crsTransform).ifPresent(subject -> { fn.accept(feature, subject); subjectBuffer.add(subject); }); flushBufferIfRequired(); } flushBuffer(); }
Example 10
Source File: GeoWaveFeatureReaderTest.java From rya with Apache License 2.0 | 5 votes |
@Test public void testFID() throws IllegalArgumentException, NoSuchElementException, IOException, CQLException { 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 11
Source File: GeoWaveFeatureReaderTest.java From rya with Apache License 2.0 | 5 votes |
@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 12
Source File: GeoWaveFeatureReaderTest.java From rya with Apache License 2.0 | 5 votes |
@Test public void testRangeIndex() throws IllegalArgumentException, NoSuchElementException, IOException { 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 13
Source File: GeoWaveFeatureReaderTest.java From rya with Apache License 2.0 | 5 votes |
@Test public void testRemoveFeature() throws IllegalArgumentException, NoSuchElementException, IOException, CQLException { final Query query = new Query( "GeoWaveFeatureReaderTest", ECQL.toFilter("pid like '" + pids.get( 0).substring( 0, 1) + "%'"), 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); // Remove final FeatureWriter<SimpleFeatureType, SimpleFeature> writer = dataStore.getFeatureWriter(type.getTypeName(), Transaction.AUTO_COMMIT); try { while (writer.hasNext()) { writer.next(); writer.remove(); } } finally { writer.close(); } // Re-query final FeatureReader<SimpleFeatureType, SimpleFeature> reader2 = dataStore.getFeatureReader(query, Transaction.AUTO_COMMIT); int recount = 0; while (reader2.hasNext()) { reader2.next(); recount++; } assertEquals(0, recount); }
Example 14
Source File: GeoWaveFeatureReaderTest.java From geowave with Apache License 2.0 | 5 votes |
@Test public void testFID() throws IllegalArgumentException, NoSuchElementException, IOException, CQLException { 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 15
Source File: GeoWaveFeatureReaderTest.java From geowave with Apache License 2.0 | 5 votes |
@Test public void testRangeIndex() throws IllegalArgumentException, NoSuchElementException, IOException { 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 16
Source File: GeoToolsAttributesSubsetTest.java From geowave with Apache License 2.0 | 5 votes |
@Test public void testAllAttributes() throws CQLException, IOException { final Query query = new Query(typeName, CQL.toFilter(cqlPredicate), Query.ALL_PROPERTIES); final FeatureReader<SimpleFeatureType, SimpleFeature> reader = geotoolsDataStore.getFeatureReader(query, Transaction.AUTO_COMMIT); int count = 0; while (reader.hasNext()) { final SimpleFeature feature = reader.next(); count++; Assert.assertTrue(feature.getAttribute(geometry_attribute) != null); Assert.assertTrue(feature.getAttribute(long_attribute) != null); Assert.assertTrue(feature.getAttribute(string_attribute) != null); } Assert.assertTrue(count == 3); }