本文整理汇总了Java中org.geotools.data.FeatureReader.next方法的典型用法代码示例。如果您正苦于以下问题:Java FeatureReader.next方法的具体用法?Java FeatureReader.next怎么用?Java FeatureReader.next使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.geotools.data.FeatureReader
的用法示例。
在下文中一共展示了FeatureReader.next方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testFidFilterQuery
import org.geotools.data.FeatureReader; //导入方法依赖的package包/类
@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());
}
示例2: testPidFilterQuery
import org.geotools.data.FeatureReader; //导入方法依赖的package包/类
@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);
}
示例3: testLike
import org.geotools.data.FeatureReader; //导入方法依赖的package包/类
@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);
}
示例4: example3
import org.geotools.data.FeatureReader; //导入方法依赖的package包/类
private static void example3() throws IOException {
System.out.println("example3 start\n");
// example3 start
Map<String, Serializable> params = new HashMap<String, Serializable>();
params.put("directory", directory);
DataStore datastore = DataStoreFinder.getDataStore(params);
Query query = new Query("example");
FeatureReader<SimpleFeatureType, SimpleFeature> reader = datastore
.getFeatureReader(query, Transaction.AUTO_COMMIT);
try {
int count = 0;
while (reader.hasNext()) {
SimpleFeature feature = reader.next();
System.out.println("feature " + count + ": " + feature.getID());
count++;
}
System.out.println("read in " + count + " features");
} finally {
reader.close();
}
// example3 end
System.out.println("\nexample3 end\n");
}
示例5: getBoundsInternal
import org.geotools.data.FeatureReader; //导入方法依赖的package包/类
/**
* Implementation that generates the total bounds
* (many file formats record this information in the header)
*/
protected ReferencedEnvelope getBoundsInternal(Query query) throws IOException {
ReferencedEnvelope bounds = new ReferencedEnvelope( getSchema().getCoordinateReferenceSystem() );
FeatureReader<SimpleFeatureType, SimpleFeature> featureReader = getReaderInternal(query);
try {
while( featureReader.hasNext() ){
SimpleFeature feature = featureReader.next();
bounds.include( feature.getBounds() );
}
}
finally {
featureReader.close();
}
return bounds;
}
示例6: testFID
import org.geotools.data.FeatureReader; //导入方法依赖的package包/类
@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);
}
示例7: testRangeIndex
import org.geotools.data.FeatureReader; //导入方法依赖的package包/类
@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);
}
示例8: testAllAttributes
import org.geotools.data.FeatureReader; //导入方法依赖的package包/类
@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);
}
示例9: testSubsetAttributes
import org.geotools.data.FeatureReader; //导入方法依赖的package包/类
@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);
}
示例10: testAllShapesArePolygon
import org.geotools.data.FeatureReader; //导入方法依赖的package包/类
public void testAllShapesArePolygon() {
try {
File fin = new File(CommunityAreas.shapeFilePath);
ShapefileDataStore r = new ShapefileDataStore(fin.toURI().toURL());
SimpleFeatureType sft = r.getSchema();
assertEquals(sft.getTypes().size(), 10);
assertEquals(sft.getType(0).getName().getLocalPart(), "MultiPolygon");
assertEquals(sft.getType(5).getName().getLocalPart(), "AREA_NUMBE");
assertEquals(sft.getType(6).getName().getLocalPart(), "COMMUNITY");
FeatureReader<SimpleFeatureType, SimpleFeature> fr = r.getFeatureReader();
SimpleFeature shp;
int total = 0;
while (fr.hasNext()) {
total ++;
shp = fr.next();
MultiPolygon g = (MultiPolygon) shp.getDefaultGeometry();
}
fr.close();
r.dispose();
assertEquals(total, 77);
} catch (Exception e) {
e.printStackTrace();
}
}
示例11: withSubjects
import org.geotools.data.FeatureReader; //导入方法依赖的package包/类
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();
}
开发者ID:FutureCitiesCatapult,项目名称:TomboloDigitalConnector,代码行数:15,代码来源:AbstractGeotoolsDataStoreImporter.java
示例12: testFID
import org.geotools.data.FeatureReader; //导入方法依赖的package包/类
@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);
}
示例13: testBBOX
import org.geotools.data.FeatureReader; //导入方法依赖的package包/类
@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);
}
示例14: testRangeIndex
import org.geotools.data.FeatureReader; //导入方法依赖的package包/类
@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);
}
示例15: testRemoveFeature
import org.geotools.data.FeatureReader; //导入方法依赖的package包/类
@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);
}