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


Java FeatureReader.close方法代码示例

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


在下文中一共展示了FeatureReader.close方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: 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

示例3: 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

示例4: importDatasource

import org.geotools.data.FeatureReader; //导入方法依赖的package包/类
@Override
final public void importDatasource(Datasource datasource, List<String> geographyScope, List<String> temporalScope, List<String> datasourceLocation) throws Exception {
    DataStore dataStore = getDataStoreForDatasource(datasource);
    FeatureReader<SimpleFeatureType, SimpleFeature> featureReader = GeotoolsDataStoreUtils.getFeatureReader(dataStore, getTypeNameForDatasource(datasource));

    // Load attribute values
    withSubjects(featureReader, dataStore, (feature, subject) -> {
        timedValueBuffer.addAll(buildTimedValuesFromFeature(datasource, feature, subject));
        fixedValueBuffer.addAll(buildFixedValuesFromFeature(datasource, feature, subject));
    });

    featureReader.close();
    dataStore.dispose();
}
 
开发者ID:FutureCitiesCatapult,项目名称:TomboloDigitalConnector,代码行数:15,代码来源:AbstractGeotoolsDataStoreImporter.java

示例5: SoilSealingAdministrativeUnit

import org.geotools.data.FeatureReader; //导入方法依赖的package包/类
/**
 * Default constructor
 * 
 * @param au
 * @param geoCodingReference
 * @param populationReference
 * @throws IOException
 */
public SoilSealingAdministrativeUnit(String au, FeatureTypeInfo geoCodingReference,
        FeatureTypeInfo populationReference) throws IOException {
    if (!au.contains("_")) {
        throw new IOException("Invalid Administrative Unit name");
    }
    this.geoCodingReference = geoCodingReference;
    this.populationReference = populationReference;
    this.name = au.split("_")[0];
    this.parent = au.split("_")[1];

    FeatureReader<SimpleFeatureType, SimpleFeature> ftReader = null;
    Transaction transaction = new DefaultTransaction();
    try {
        final JDBCDataStore ds = (JDBCDataStore) geoCodingReference.getStore().getDataStore(null);
        Filter nameFilter = ff.equals(ff.property("name"), ff.literal(this.name));
        Filter parentFilter = ff.equals(ff.property("parent"), ff.literal(this.parent));
        Filter queryFilter = ff.and(Arrays.asList(nameFilter, parentFilter));
        Query query = new Query(geoCodingReference.getFeatureType().getName().getLocalPart(), queryFilter);
        
        ftReader = ds.getFeatureReader(query, transaction);

        while (ftReader.hasNext()) {
            Feature feature = ftReader.next();
            this.type = AuType.getType((Integer) feature.getProperty("type").getValue());
            this.the_geom = (Geometry) feature.getDefaultGeometryProperty().getValue();
            break;
        }
    } finally {
        if (ftReader != null) {
            ftReader.close();
        }

        transaction.commit();
        transaction.close();
    }

    if (this.type == null || this.the_geom == null) {
        throw new IOException("Invalid Administrative Unit name: no record found!");
    }

    switch (this.type) {
    case MUNICIPALITY:
        loadPopulationStatistics(this);
        break;
    case DISTRICT:
    case REGION:
        loadSubs(this);
        break;
    default:
        break;
    }
}
 
开发者ID:geosolutions-it,项目名称:soil_sealing,代码行数:61,代码来源:SoilSealingAdministrativeUnit.java

示例6: loadPopulationStatistics

import org.geotools.data.FeatureReader; //导入方法依赖的package包/类
/**
 * 
 * @param soilSealingAdministrativeUnit
 * @throws IOException
 */
private void loadPopulationStatistics(SoilSealingAdministrativeUnit soilSealingAdministrativeUnit) throws IOException {
    FeatureReader<SimpleFeatureType, SimpleFeature> ftReader = null;
    Transaction transaction = new DefaultTransaction();
    try {
        final JDBCDataStore ds = (JDBCDataStore) populationReference.getStore().getDataStore(null);
        Filter auNameFilter = ff.equals(ff.property("au_name"), ff.literal(this.name));
        Filter queryFilter = ff.and(Arrays.asList(auNameFilter));
        Query query = new Query(populationReference.getFeatureType().getName().getLocalPart(), queryFilter);

        ftReader = ds.getFeatureReader(query, transaction);
        
        while (ftReader.hasNext()) {
            Feature feature = ftReader.next();
            Collection<Property> properties = feature.getProperties();
            for (Property prop : properties) {
                if (prop.getName().getLocalPart().startsWith("a_")) {
                    Object yearPopulationValue = prop.getValue();
                    if (yearPopulationValue != null) {
                        population.put(prop.getName().getLocalPart().split("a_")[1], ((BigDecimal) yearPopulationValue).intValue());
                    }
                }
            }
        }
    } finally {
        if (ftReader != null) {
            ftReader.close();
        }

        transaction.commit();
        transaction.close();
    }
}
 
开发者ID:geosolutions-it,项目名称:soil_sealing,代码行数:38,代码来源:SoilSealingAdministrativeUnit.java

示例7: example4

import org.geotools.data.FeatureReader; //导入方法依赖的package包/类
private static void example4() throws IOException {
    System.out.println("example4 start\n");
    // example4 start
    Map<String, Serializable> params = new HashMap<String, Serializable>();
    params.put("directory", directory);
    DataStore store = DataStoreFinder.getDataStore(params);

    FilterFactory ff = CommonFactoryFinder.getFilterFactory();

    Set<FeatureId> selection = new HashSet<FeatureId>();
    selection.add(ff.featureId("fid1"));

    Filter filter = ff.id(selection);
    Query query = new Query("example", filter);

    FeatureReader<SimpleFeatureType, SimpleFeature> reader = store
            .getFeatureReader(query, Transaction.AUTO_COMMIT);

    try {
        while (reader.hasNext()) {
            SimpleFeature feature = reader.next();
            System.out.println("feature " + feature.getID());

            for (Property property : feature.getProperties()) {
                System.out.print("\t");
                System.out.print(property.getName());
                System.out.print(" = ");
                System.out.println(property.getValue());
            }
        }
    } finally {
        reader.close();
    }
    // example4 end
    System.out.println("\nexample4 end\n");
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:37,代码来源:PropertyExamples.java

示例8: getBoundsInternal

import org.geotools.data.FeatureReader; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
@Override
protected ReferencedEnvelope getBoundsInternal(
		final Query query )
		throws IOException {
	double minx = -90.0, maxx = 90.0, miny = -180.0, maxy = 180.0;

	DataStatistics<SimpleFeature> bboxStats = null;
	if (query.getFilter().equals(
			Filter.INCLUDE)) {
		final Map<ByteArrayId, DataStatistics<SimpleFeature>> stats = new GeoWaveEmptyTransaction(
				components).getDataStatistics();
		bboxStats = stats.get(FeatureBoundingBoxStatistics.composeId(getFeatureType()
				.getGeometryDescriptor()
				.getLocalName()));
	}
	if (bboxStats != null) {
		minx = ((BoundingBoxDataStatistics) bboxStats).getMinX();
		maxx = ((BoundingBoxDataStatistics) bboxStats).getMaxX();
		miny = ((BoundingBoxDataStatistics) bboxStats).getMinY();
		maxy = ((BoundingBoxDataStatistics) bboxStats).getMaxY();
	}
	else {

		final FeatureReader<SimpleFeatureType, SimpleFeature> reader = new GeoWaveFeatureReader(
				query,
				new GeoWaveEmptyTransaction(
						components),
				components);
		if (reader.hasNext()) {
			minx = 90.0;
			maxx = -90.0;
			miny = 180.0;
			maxy = -180.0;
			while (reader.hasNext()) {
				final BoundingBox bbox = reader.next().getBounds();
				minx = Math.min(
						bbox.getMinX(),
						minx);
				maxx = Math.max(
						bbox.getMaxX(),
						maxx);
				miny = Math.min(
						bbox.getMinY(),
						miny);
				maxy = Math.max(
						bbox.getMaxY(),
						maxy);

			}
		}
		reader.close();
	}
	return new ReferencedEnvelope(
			minx,
			maxx,
			miny,
			maxy,
			GeometryUtils.DEFAULT_CRS);
}
 
开发者ID:locationtech,项目名称:geowave,代码行数:61,代码来源:GeoWaveFeatureSource.java

示例9: testTemporal

import org.geotools.data.FeatureReader; //导入方法依赖的package包/类
@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",
				"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);

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

示例10: test

import org.geotools.data.FeatureReader; //导入方法依赖的package包/类
@Test
public void test()
		throws IOException,
		CQLException,
		ParseException {
	final Transaction transaction1 = new DefaultTransaction();

	final FeatureWriter<SimpleFeatureType, SimpleFeature> writer = dataStore.getFeatureWriter(
			type.getTypeName(),
			transaction1);
	assertFalse(writer.hasNext());
	SimpleFeature newFeature = writer.next();
	newFeature.setAttribute(
			"pop",
			Long.valueOf(100));
	newFeature.setAttribute(
			"pid",
			UUID.randomUUID().toString());
	newFeature.setAttribute(
			"when",
			DateUtilities.parseISO("2005-05-19T18:33:55Z"));
	newFeature.setAttribute(
			"geometry",
			factory.createPoint(new Coordinate(
					27.25,
					41.25)));

	newFeature = writer.next();
	newFeature.setAttribute(
			"pop",
			Long.valueOf(100));
	newFeature.setAttribute(
			"pid",
			UUID.randomUUID().toString());
	newFeature.setAttribute(
			"when",
			DateUtilities.parseISO("2005-05-19T20:33:55Z"));
	newFeature.setAttribute(
			"geometry",
			factory.createPoint(new Coordinate(
					27.25,
					41.25)));
	writer.write();
	writer.close();

	final FeatureReader<SimpleFeatureType, SimpleFeature> reader = dataStore.getFeatureReader(
			query,
			transaction1);
	assertTrue(reader.hasNext());
	final SimpleFeature priorFeature = reader.next();
	assertEquals(
			newFeature.getAttribute("pid"),
			priorFeature.getAttribute("pid"));
	assertFalse(reader.hasNext());
	reader.close();

	transaction1.commit();
	transaction1.close();

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

示例11: testInsertIsolation

import org.geotools.data.FeatureReader; //导入方法依赖的package包/类
@Test
public void testInsertIsolation()
		throws IOException,
		CQLException {
	final Transaction transaction1 = new DefaultTransaction();

	final FeatureWriter<SimpleFeatureType, SimpleFeature> writer = dataStore.getFeatureWriter(
			type.getTypeName(),
			transaction1);
	assertFalse(writer.hasNext());
	final SimpleFeature newFeature = writer.next();
	newFeature.setAttribute(
			"pop",
			Long.valueOf(100));
	newFeature.setAttribute(
			"pid",
			UUID.randomUUID().toString());
	newFeature.setAttribute(
			"geometry",
			factory.createPoint(new Coordinate(
					27.25,
					41.25)));
	writer.write();
	writer.close();

	FeatureReader<SimpleFeatureType, SimpleFeature> reader = dataStore.getFeatureReader(
			query,
			transaction1);
	assertTrue(reader.hasNext());
	final SimpleFeature priorFeature = reader.next();
	assertEquals(
			newFeature.getAttribute("pid"),
			priorFeature.getAttribute("pid"));
	reader.close();

	// uncommitted at this point, so this next transaction should not see
	// it.

	final Transaction transaction2 = new DefaultTransaction();
	reader = dataStore.getFeatureReader(
			query,
			transaction2);
	assertFalse(reader.hasNext());
	reader.close();

	transaction1.commit();
	reader = dataStore.getFeatureReader(
			query,
			transaction1);
	assertTrue(reader.hasNext());
	reader.next();
	assertFalse(reader.hasNext());
	reader.close();

	transaction1.close();

	// since this implementation does not support serializable, transaction2
	// can see the changes even though
	// it started after transaction1 and before the commit.
	reader = dataStore.getFeatureReader(
			query,
			transaction2);
	assertTrue(reader.hasNext());
	reader.next();
	assertFalse(reader.hasNext());
	reader.close();
	transaction2.commit();
	transaction2.close();

	// stats check
	final Transaction transaction3 = new DefaultTransaction();
	reader = ((GeoWaveFeatureSource) ((GeoWaveGTDataStore) dataStore).getFeatureSource(
			"geostuff",
			transaction3)).getReaderInternal(query);
	Map<ByteArrayId, DataStatistics<SimpleFeature>> transStats = ((GeoWaveFeatureReader) reader)
			.getTransaction()
			.getDataStatistics();
	assertNotNull(transStats.get(FeatureNumericRangeStatistics.composeId("pop")));
	transaction3.close();

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


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