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


Java FeatureWriter类代码示例

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


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

示例1: testRemoveFeature

import org.geotools.data.FeatureWriter; //导入依赖的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);
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:45,代码来源:GeoWaveFeatureReaderTest.java

示例2: exportToShapefile

import org.geotools.data.FeatureWriter; //导入依赖的package包/类
/**
 * Export features to a new shapefile using the map projection in which
 * they are currently displayed
 */
 public static void exportToShapefile(DataStore newDataStore, FeatureCollection<SimpleFeatureType,SimpleFeature> featureCollection)/*,SimpleFeatureType ftype)*/ throws Exception {
 // carefully open an iterator and writer to process the results
    Transaction transaction = new DefaultTransaction();
    FeatureWriter<SimpleFeatureType, SimpleFeature> writer = newDataStore.getFeatureWriter(newDataStore.getTypeNames()[0],  transaction);

    FeatureIterator<SimpleFeature> iterator = featureCollection.features();
    try {

        while( iterator.hasNext() ){
            SimpleFeature feature = iterator.next();
            SimpleFeature copy = writer.next();


            //copy.setAttributes( feature.getAttributes() );
            Geometry geometry = (Geometry) feature.getDefaultGeometry();
            if(geometry!=null){
            	copy.setDefaultGeometry( geometry.buffer(0));
            	writer.write();
            }else{
            	logger.warn("Warning:geometry null");
            }
        }
        transaction.commit();
        logger.info("Export to shapefile complete" );
    } catch (Exception problem) {
        problem.printStackTrace();
        transaction.rollback();
        logger.error("Export to shapefile failed",problem );
    } finally {
        writer.close();
        iterator.close();
        transaction.close();
    }
}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:39,代码来源:SimpleShapefile.java

示例3: getWriterInternal

import org.geotools.data.FeatureWriter; //导入依赖的package包/类
@Override
protected FeatureWriter<SimpleFeatureType, SimpleFeature> getWriterInternal(
		final Query query,
		final int flags )
		throws IOException {
	final GeoWaveTransactionState state = getDataStore().getMyTransactionState(
			transaction,
			this);
	return new GeoWaveFeatureWriter(
			components,
			state.getGeoWaveTransaction(query.getTypeName()),
			(GeoWaveFeatureReader) getReaderInternal(query));
}
 
开发者ID:locationtech,项目名称:geowave,代码行数:14,代码来源:GeoWaveFeatureSource.java

示例4: build

import org.geotools.data.FeatureWriter; //导入依赖的package包/类
public void build() throws IOException, ParseException
{
  // Build the test shapefile
  SimpleFeatureTypeBuilder schemaBuilder = new SimpleFeatureTypeBuilder();
  schemaBuilder.setName("Flag");
  schemaBuilder.setNamespaceURI("http://localhost/");
  schemaBuilder.setCRS(DefaultGeographicCRS.WGS84);

  // add attributes in order
  this.addSchemaAttributes(schemaBuilder);

  SimpleFeatureType schema = schemaBuilder.buildFeatureType();

  ShapefileDataStoreFactory dataStoreFactory = new ShapefileDataStoreFactory();

  Map<String, Serializable> params = new HashMap<String, Serializable>();
  params.put("url", url);
  params.put("create spatial index", Boolean.TRUE);

  ShapefileDataStore store = (ShapefileDataStore) dataStoreFactory.createNewDataStore(params);
  store.createSchema(schema);

  FeatureWriter<SimpleFeatureType, SimpleFeature> writer = store.getFeatureWriter(Transaction.AUTO_COMMIT);

  try
  {
    for (int i = 0; i < 100; i++)
    {
      SimpleFeature feature = writer.next();

      populateFeature(feature, i);

      writer.write();
    }
  }
  finally
  {
    writer.close();
  }
}
 
开发者ID:terraframe,项目名称:geoprism,代码行数:41,代码来源:ShapeFileBuilder.java

示例5: exportGeometriesToShapeFile

import org.geotools.data.FeatureWriter; //导入依赖的package包/类
/**
 *
 * @param geoms
 * @param fileOutput
 * @param geomType
 * @param transform
 * @throws IOException
 * @throws SchemaException
 */
public static void exportGeometriesToShapeFile(final List<Geometry> geoms,
	 File fileOutput,String geomType,GeoTransform transform,
	 SimpleFeatureType featureType) throws IOException, SchemaException{

 FileDataStoreFactorySpi factory = new ShapefileDataStoreFactory();
 //Map map = Collections.singletonMap( "url", fileOutput.toURI().toURL() );
 DataStore data = factory.createDataStore( fileOutput.toURI().toURL() );
 boolean addAttr=true;
 if(featureType==null){
	 featureType=DataUtilities.createType( "the_geom", "geom:"+geomType+",name:String,age:Integer,description:String" );
	 addAttr=false;
 }
 data.createSchema( featureType );

 Transaction transaction = new DefaultTransaction();
    FeatureWriter<SimpleFeatureType, SimpleFeature> writer = data.getFeatureWriterAppend(data.getTypeNames()[0], transaction);

    SimpleFeatureBuilder featureBuilder=new SimpleFeatureBuilder(featureType);
    GeometryFactory gb=new GeometryFactory();
    try {
     int fid=0;
     for(final Geometry g:geoms){
    	 Geometry clone=gb.createGeometry(g);
    	 if(transform!=null)
    		 clone=transform.transformGeometryGeoFromPixel(clone);

    	 featureBuilder.add("the_geom");
    	 featureBuilder.add(clone);
    	 SimpleFeature sf=featureBuilder.buildFeature(""+fid++);
    	 SimpleFeature sfout=writer.next();
    	 sfout.setAttributes( sf.getAttributes() );
         //setting attributes geometry
       	 AttributesGeometry att=(AttributesGeometry) g.getUserData();
       	 try{
        	 if(att!=null&&addAttr){
         	 String sch[]=att.getSchema();
         	 for(int i=0;i<sch.length;i++){
         		 Object val=att.get(sch[i]);
         		 if(val.getClass().isArray()){
         			 Object o=ArrayUtils.toString(val);
         			 sfout.setAttribute(sch[i], o);
         		 }else{
         			 sfout.setAttribute(sch[i], val);
         		 }
         	 }
        	 }
       	 }catch(Exception e ){
       		 logger.warn("Error adding attributes to geometry:"+e.getMessage());
       	 }

         sfout.setDefaultGeometry( clone);
    	 writer.write();
	 }
     transaction.commit();
     logger.info("Export to shapefile complete:"+ fileOutput.getAbsolutePath());
    } catch (Exception problem) {
        problem.printStackTrace();
        transaction.rollback();
        logger.error("Export to shapefile failed",problem );
    } finally {
        writer.close();
        transaction.close();
        data.dispose();
    }

}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:76,代码来源:SimpleShapefile.java

示例6: exportToShapefileForceWGS84

import org.geotools.data.FeatureWriter; //导入依赖的package包/类
public static void exportToShapefileForceWGS84(DataStore newDataStore, FeatureCollection<SimpleFeatureType,SimpleFeature> featureCollection)/*,SimpleFeatureType ftype)*/ throws Exception {
 // carefully open an iterator and writer to process the results
    Transaction transaction = new DefaultTransaction();

    //CoordinateReferenceSystem crsOrig=featureCollection.getSchema().getCoordinateReferenceSystem();

    //set wgs84 coordinates ref sys
    SimpleFeatureType featureType = SimpleFeatureTypeBuilder.retype(featureCollection.getSchema(), DefaultGeographicCRS.WGS84);
    newDataStore.createSchema(featureType);

    FeatureWriter<SimpleFeatureType, SimpleFeature> writer = newDataStore.getFeatureWriter(newDataStore.getTypeNames()[0],  transaction);
    //create the transformation
    MathTransform trans=CRS.findMathTransform(CRS.parseWKT(WKTString.WKT3995_ESRI),DefaultGeographicCRS.WGS84);


    FeatureIterator<SimpleFeature> iterator = featureCollection.features();
    try {

        while( iterator.hasNext() ){
            SimpleFeature feature = iterator.next();
            SimpleFeature copy = writer.next();


            Geometry geometry = (Geometry) feature.getDefaultGeometry();
            geometry=JTS.transform(geometry,trans);


            if(geometry!=null){
            	copy.setDefaultGeometry( geometry.buffer(0));
            	writer.write();
            }else{
            	logger.warn("Warning:geometry null");
            }
        }
        transaction.commit();
        logger.info("Export to shapefile complete" );
    } catch (Exception problem) {
        problem.printStackTrace();
        transaction.rollback();
        logger.error("Export to shapefile failed",problem );
    } finally {
        writer.close();
        iterator.close();
        transaction.close();
    }
}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:47,代码来源:SimpleShapefile.java

示例7: getFeatureWriter

import org.geotools.data.FeatureWriter; //导入依赖的package包/类
@Override
public FeatureWriter<SimpleFeatureType, SimpleFeature> getFeatureWriter(Filter filter,
        Transaction transaction) throws IOException {
    return getFeatureWriter(getTypeName().getLocalPart(), filter, transaction);
}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:6,代码来源:ShapefileDataStore.java

示例8: getFeatureWriterAppend

import org.geotools.data.FeatureWriter; //导入依赖的package包/类
@Override
public FeatureWriter<SimpleFeatureType, SimpleFeature> getFeatureWriterAppend(
        Transaction transaction) throws IOException {
    return getFeatureWriterAppend(getTypeName().getLocalPart(), transaction);
}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:6,代码来源:ShapefileDataStore.java

示例9: setup

import org.geotools.data.FeatureWriter; //导入依赖的package包/类
@Before
public void setup() throws SchemaException, CQLException, Exception {
    setupConf();
    try (final GeoWaveGeoIndexer indexer = new GeoWaveGeoIndexer()) {
        indexer.setConf(conf);
        dataStore = indexer.getGeoToolsDataStore();
        // Clear old data
        indexer.purge(conf);

        type = DataUtilities.createType(
                "GeoWaveFeatureReaderTest",
                "geometry:Geometry:srid=4326,start:Date,end:Date,pop:java.lang.Long,pid:String");

        dataStore.createSchema(type);

        stime = DateUtilities.parseISO("2005-05-15T20:32:56Z");
        etime = DateUtilities.parseISO("2005-05-20T20:32:56Z");

        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",
                "a" + UUID.randomUUID().toString());
        newFeature.setAttribute(
                "start",
                stime);
        newFeature.setAttribute(
                "end",
                etime);
        newFeature.setAttribute(
                "geometry",
                factory.createPoint(new Coordinate(27.25, 41.25)));
        fids.add(newFeature.getID());
        pids.add(newFeature.getAttribute("pid").toString());
        writer.write();
        newFeature = writer.next();
        newFeature.setAttribute(
                "pop",
                Long.valueOf(101));
        newFeature.setAttribute(
                "pid",
                "b" + UUID.randomUUID().toString());
        newFeature.setAttribute(
                "start",
                etime);
        newFeature.setAttribute(
                "geometry",
                factory.createPoint(new Coordinate(28.25, 41.25)));
        fids.add(newFeature.getID());
        pids.add(newFeature.getAttribute("pid").toString());
        writer.write();
        writer.close();
        transaction1.commit();
        transaction1.close();

        query = new Query(
                "GeoWaveFeatureReaderTest",
                ECQL.toFilter("IN ('" + fids.get(0) + "')"),
                new String[] {
                    "geometry",
                    "pid"
                });
    }
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:72,代码来源:GeoWaveFeatureReaderTest.java

示例10: exportToShapefile

import org.geotools.data.FeatureWriter; //导入依赖的package包/类
/**
 * Export features to a new shapefile using the map projection in which they are currently
 * displayed
 */
// docs start export
private void exportToShapefile() throws Exception {
    SimpleFeatureType schema = featureSource.getSchema();
    JFileDataStoreChooser chooser = new JFileDataStoreChooser("shp");
    chooser.setDialogTitle("Save reprojected shapefile");
    chooser.setSaveFile(sourceFile);
    int returnVal = chooser.showSaveDialog(null);
    if (returnVal != JFileDataStoreChooser.APPROVE_OPTION) {
        return;
    }
    File file = chooser.getSelectedFile();
    if (file.equals(sourceFile)) {
        JOptionPane.showMessageDialog(null, "Cannot replace " + file);
        return;
    }

    // set up the math transform used to process the data
    CoordinateReferenceSystem dataCRS = schema.getCoordinateReferenceSystem();
    CoordinateReferenceSystem worldCRS = map.getCoordinateReferenceSystem();
    boolean lenient = true; // allow for some error due to different datums
    MathTransform transform = CRS.findMathTransform(dataCRS, worldCRS, lenient);

    // grab all features
    SimpleFeatureCollection featureCollection = featureSource.getFeatures();

    // And create a new Shapefile with a slight modified schema
    DataStoreFactorySpi factory = new ShapefileDataStoreFactory();
    Map<String, Serializable> create = new HashMap<String, Serializable>();
    create.put("url", file.toURI().toURL());
    create.put("create spatial index", Boolean.TRUE);
    DataStore dataStore = factory.createNewDataStore(create);
    SimpleFeatureType featureType = SimpleFeatureTypeBuilder.retype(schema, worldCRS);
    dataStore.createSchema(featureType);

    // carefully open an iterator and writer to process the results
    Transaction transaction = new DefaultTransaction("Reproject");
    FeatureWriter<SimpleFeatureType, SimpleFeature> writer =
                    dataStore.getFeatureWriterAppend(featureType.getTypeName(), transaction);
    SimpleFeatureIterator iterator = featureCollection.features();
    try {
        while (iterator.hasNext()) {
            // copy the contents of each feature and transform the geometry
            SimpleFeature feature = iterator.next();
            SimpleFeature copy = writer.next();
            copy.setAttributes(feature.getAttributes());

            Geometry geometry = (Geometry) feature.getDefaultGeometry();
            Geometry geometry2 = JTS.transform(geometry, transform);

            copy.setDefaultGeometry(geometry2);
            writer.write();
        }
        transaction.commit();
        JOptionPane.showMessageDialog(null, "Export to shapefile complete");
    } catch (Exception problem) {
        problem.printStackTrace();
        transaction.rollback();
        JOptionPane.showMessageDialog(null, "Export to shapefile failed");
    } finally {
        writer.close();
        iterator.close();
        transaction.close();
    }
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:69,代码来源:CRSLab.java

示例11: populate

import org.geotools.data.FeatureWriter; //导入依赖的package包/类
public void populate()
		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-19T20:32:56Z"));
	newFeature.setAttribute(
			"geometry",
			factory.createPoint(new Coordinate(
					43.454,
					28.232)));
	writer.write();

	newFeature = writer.next();
	newFeature.setAttribute(
			"pop",
			Long.valueOf(100));
	newFeature.setAttribute(
			"pid",
			UUID.randomUUID().toString());
	newFeature.setAttribute(
			"when",
			DateUtilities.parseISO("2005-05-18T20:32:56Z"));
	newFeature.setAttribute(
			"geometry",
			factory.createPoint(new Coordinate(
					43.454,
					27.232)));
	writer.write();

	newFeature = writer.next();
	newFeature.setAttribute(
			"pop",
			Long.valueOf(100));
	newFeature.setAttribute(
			"pid",
			UUID.randomUUID().toString());
	newFeature.setAttribute(
			"when",
			DateUtilities.parseISO("2005-05-17T20:32:56Z"));
	newFeature.setAttribute(
			"geometry",
			factory.createPoint(new Coordinate(
					43.454,
					28.232)));
	writer.write();
	writer.close();
	transaction1.commit();
	transaction1.close();
}
 
开发者ID:locationtech,项目名称:geowave,代码行数:65,代码来源:WFSBoundedSpatialQueryTest.java

示例12: setup

import org.geotools.data.FeatureWriter; //导入依赖的package包/类
@Before
public void setup()
		throws SchemaException,
		CQLException,
		Exception {
	dataStore = createDataStore();
	type = DataUtilities.createType(
			"GeoWaveFeatureReaderTest",
			"geometry:Geometry:srid=4326,start:Date,end:Date,pop:java.lang.Long,pid:String");

	dataStore.createSchema(type);

	stime = DateUtilities.parseISO("2005-05-15T20:32:56Z");
	etime = DateUtilities.parseISO("2005-05-20T20:32:56Z");

	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",
			"a" + UUID.randomUUID().toString());
	newFeature.setAttribute(
			"start",
			stime);
	newFeature.setAttribute(
			"end",
			etime);
	newFeature.setAttribute(
			"geometry",
			factory.createPoint(new Coordinate(
					27.25,
					41.25)));
	fids.add(newFeature.getID());
	pids.add(newFeature.getAttribute(
			"pid").toString());
	writer.write();
	newFeature = writer.next();
	newFeature.setAttribute(
			"pop",
			Long.valueOf(101));
	newFeature.setAttribute(
			"pid",
			"b" + UUID.randomUUID().toString());
	newFeature.setAttribute(
			"start",
			etime);
	newFeature.setAttribute(
			"geometry",
			factory.createPoint(new Coordinate(
					28.25,
					41.25)));
	fids.add(newFeature.getID());
	pids.add(newFeature.getAttribute(
			"pid").toString());
	writer.write();
	writer.close();
	transaction1.commit();
	transaction1.close();

	// System.out.println(fids);
	query = new Query(
			"GeoWaveFeatureReaderTest",
			ECQL.toFilter("IN ('" + fids.get(0) + "')"),
			new String[] {
				"geometry",
				"pid"
			});

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

示例13: test

import org.geotools.data.FeatureWriter; //导入依赖的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

示例14: populate

import org.geotools.data.FeatureWriter; //导入依赖的package包/类
public void populate(
		final SimpleFeatureType type,
		final DataStore dataStore )
		throws IOException,
		CQLException,
		ParseException {

	dataStore.createSchema(type);

	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(77));
	newFeature.setAttribute(
			"pid",
			UUID.randomUUID().toString());
	newFeature.setAttribute(
			"when",
			DateUtilities.parseISO("2005-05-19T20:32:56Z"));
	newFeature.setAttribute(
			"geometry",
			factory.createPoint(new Coordinate(
					43.454,
					28.232)));
	writer.write();

	newFeature = writer.next();
	newFeature.setAttribute(
			"pop",
			Long.valueOf(66));
	newFeature.setAttribute(
			"pid",
			UUID.randomUUID().toString());
	newFeature.setAttribute(
			"when",
			DateUtilities.parseISO("2005-05-18T20:32:56Z"));
	newFeature.setAttribute(
			"geometry",
			factory.createPoint(new Coordinate(
					43.454,
					27.232)));
	writer.write();

	newFeature = writer.next();
	newFeature.setAttribute(
			"pop",
			Long.valueOf(100));
	newFeature.setAttribute(
			"pid",
			UUID.randomUUID().toString());
	newFeature.setAttribute(
			"when",
			DateUtilities.parseISO("2005-05-17T20:32:56Z"));
	newFeature.setAttribute(
			"geometry",
			factory.createPoint(new Coordinate(
					43.454,
					28.242)));
	writer.write();
	writer.close();
	transaction1.commit();
	transaction1.close();
}
 
开发者ID:locationtech,项目名称:geowave,代码行数:70,代码来源:GeoWaveFeatureSourceTest.java

示例15: setup

import org.geotools.data.FeatureWriter; //导入依赖的package包/类
@Before
public void setup()
		throws IOException,
		GeoWavePluginException,
		SchemaException {
	geotoolsDataStore = createDataStore();
	type = DataUtilities.createType(
			typeName,
			typeSpec);

	geotoolsDataStore.createSchema(type);
	final Transaction transaction = new DefaultTransaction();
	final FeatureWriter<SimpleFeatureType, SimpleFeature> writer = geotoolsDataStore.getFeatureWriter(
			type.getTypeName(),
			transaction);
	assertFalse(writer.hasNext());
	SimpleFeature newFeature = writer.next();
	newFeature.setAttribute(
			geometry_attribute,
			GeometryUtils.GEOMETRY_FACTORY.createPoint(new Coordinate(
					41.25,
					41.25)));
	newFeature.setAttribute(
			long_attribute,
			1l);
	newFeature.setAttribute(
			string_attribute,
			"string1");
	writer.write();
	newFeature = writer.next();
	newFeature.setAttribute(
			geometry_attribute,
			GeometryUtils.GEOMETRY_FACTORY.createPoint(new Coordinate(
					41.5,
					41.5)));
	newFeature.setAttribute(
			long_attribute,
			2l);
	newFeature.setAttribute(
			string_attribute,
			"string2");
	writer.write();
	newFeature = writer.next();
	newFeature.setAttribute(
			geometry_attribute,
			GeometryUtils.GEOMETRY_FACTORY.createPoint(new Coordinate(
					41.75,
					41.75)));
	newFeature.setAttribute(
			long_attribute,
			3l);
	newFeature.setAttribute(
			string_attribute,
			"string3");
	writer.write();
	writer.close();
	transaction.commit();
	transaction.close();
}
 
开发者ID:locationtech,项目名称:geowave,代码行数:60,代码来源:GeoToolsAttributesSubsetTest.java


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