当前位置: 首页>>代码示例>>Java>>正文


Java FeatureReader类代码示例

本文整理汇总了Java中org.geotools.data.FeatureReader的典型用法代码示例。如果您正苦于以下问题:Java FeatureReader类的具体用法?Java FeatureReader怎么用?Java FeatureReader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FeatureReader类属于org.geotools.data包,在下文中一共展示了FeatureReader类的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());
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:22,代码来源:GeoWaveFeatureReaderTest.java

示例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);
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:24,代码来源:GeoWaveFeatureReaderTest.java

示例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);
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:23,代码来源:GeoWaveFeatureReaderTest.java

示例4: reader

import org.geotools.data.FeatureReader; //导入依赖的package包/类
@Override
public FeatureReader reader() throws IOException {
	final FeatureIterator iterator = features();
	return new FeatureReader() {
		public FeatureType getFeatureType() {
			return getSchema();
		}

		public Feature next() throws IOException,
				IllegalAttributeException, NoSuchElementException {
			return iterator.next();
		}

		public boolean hasNext() throws IOException {
			return iterator.hasNext();
		}

		public void close() throws IOException {
			SOSFeatureCollection.this.close(iterator);
		}
	};
}
 
开发者ID:52North,项目名称:uDig-SOS-plugin,代码行数:23,代码来源:SOSFeatureCollection.java

示例5: getReaderInternal

import org.geotools.data.FeatureReader; //导入依赖的package包/类
@Override
protected FeatureReader<SimpleFeatureType, SimpleFeature> getReaderInternal(Query query) throws IOException {
    // build the actual SQL query for selecting features
    String sql = buildSqlQuery(query);
    
    System.out.println("QUERY: " + sql);
    
    // get connection
    Connection conn = getDataStore().getConnection();
    
    // create the reader
    FeatureReader<SimpleFeatureType, SimpleFeature> reader;
    try {
        reader = new SimpleMonetDBFeatureReader(sql, conn, this, getSchema(), query.getHints(), this.srid);
    } catch (Throwable e) {
         if (e instanceof Error) {
            throw (Error) e;
        } else {
            throw (IOException) new IOException().initCause(e);
        }
    }    
    
    return reader;        
}
 
开发者ID:DennisPallett,项目名称:gt-jdbc-monetdb-simple,代码行数:25,代码来源:SimpleMonetDBFeatureSource.java

示例6: 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");
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:25,代码来源:PropertyExamples.java

示例7: 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;
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:20,代码来源:CSVFeatureSource.java

示例8: 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);
}
 
开发者ID:locationtech,项目名称:geowave,代码行数:18,代码来源:GeoWaveFeatureReaderTest.java

示例9: 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);

}
 
开发者ID:locationtech,项目名称:geowave,代码行数:20,代码来源:GeoWaveFeatureReaderTest.java

示例10: testMax

import org.geotools.data.FeatureReader; //导入依赖的package包/类
@Test
public void testMax()
		throws IllegalArgumentException,
		NoSuchElementException,
		IOException {
	final FeatureReader<SimpleFeatureType, SimpleFeature> reader = dataStore.getFeatureReader(
			query,
			Transaction.AUTO_COMMIT);
	final MaxVisitor visitor = new MaxVisitor(
			"start",
			type);
	unwrapDelegatingFeatureReader(
			reader).getFeatureCollection().accepts(
			visitor,
			null);
	assertTrue(visitor.getMax().equals(
			etime));

}
 
开发者ID:locationtech,项目名称:geowave,代码行数:20,代码来源:GeoWaveFeatureReaderTest.java

示例11: testMin

import org.geotools.data.FeatureReader; //导入依赖的package包/类
@Test
public void testMin()
		throws IllegalArgumentException,
		NoSuchElementException,
		IOException {
	final FeatureReader<SimpleFeatureType, SimpleFeature> reader = dataStore.getFeatureReader(
			query,
			Transaction.AUTO_COMMIT);
	final MinVisitor visitor = new MinVisitor(
			"start",
			type);
	unwrapDelegatingFeatureReader(
			reader).getFeatureCollection().accepts(
			visitor,
			null);
	assertTrue(visitor.getMin().equals(
			stime));

}
 
开发者ID:locationtech,项目名称:geowave,代码行数:20,代码来源:GeoWaveFeatureReaderTest.java

示例12: 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);
}
 
开发者ID:locationtech,项目名称:geowave,代码行数:22,代码来源:GeoToolsAttributesSubsetTest.java

示例13: 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);
}
 
开发者ID:locationtech,项目名称:geowave,代码行数:25,代码来源:GeoToolsAttributesSubsetTest.java

示例14: setFeatures

import org.geotools.data.FeatureReader; //导入依赖的package包/类
/**
 * DOCUMENT ME!
 *
 * @param reader DOCUMENT ME!
 *
 * @throws IOException DOCUMENT ME!
 */
public void setFeatures(FeatureReader<SimpleFeatureType, SimpleFeature> reader) throws IOException {
    FeatureStore<SimpleFeatureType, SimpleFeature> store = store();

    //check if the feature reader needs to be retyped
    if (!store.getSchema().equals(reader.getFeatureType())) {
        reader = new RetypingFeatureCollection.RetypingFeatureReader(reader, store.getSchema());
    }

    store().setFeatures(reader);
}
 
开发者ID:STEMLab,项目名称:geoserver-3d-extension,代码行数:18,代码来源:GeoServerFeatureStore.java

示例15: 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();
    }
}
 
开发者ID:thekingofkings,项目名称:embedding,代码行数:31,代码来源:CommunityAreasTest.java


注:本文中的org.geotools.data.FeatureReader类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。