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


Java FeatureStore.addFeatures方法代码示例

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


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

示例1: saveAll

import org.geotools.data.FeatureStore; //导入方法依赖的package包/类
/**
 * Method to store analysed image params in a table on the DDBB for posterior data mining
 *
 * @param layer
 * @param projection
 * @param imageCis
 */
public void saveAll(GeometryImage layer, String projection, Object[] imageCis,GeoImageReader gir) {
    try {
    	//Data store to get access to ddbb
        DataStore datastore = (DataStore) DataStoreFinder.getDataStore(config);
        //Access to the corresponding Imagery table on ddbb
        FeatureStore featurestore = (FeatureStore) datastore.getFeatureSource(imageCis[0].toString());
        SimpleFeatureType featuretype = (SimpleFeatureType) featurestore.getSchema();
        FeatureCollection features = createTabFeatures(featuretype,imageCis);
        featurestore.addFeatures(features);
        writeToDB(datastore, features);
        datastore.dispose();
        // store extracted VDS points
        save(null,projection,((SarImageReader)gir).getGeoTransform());
    } catch (Exception ex) {
    	logger.error(ex.getMessage(),ex);
    }
}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:25,代码来源:PostgisIO.java

示例2: addDeleteNewFeature

import org.geotools.data.FeatureStore; //导入方法依赖的package包/类
public static void addDeleteNewFeature(SimpleFeatureType sft, FeatureStore producerFS)
        throws InterruptedException, IOException {
    SimpleFeatureBuilder builder = new SimpleFeatureBuilder(sft);
    DefaultFeatureCollection featureCollection = new DefaultFeatureCollection();
    final Random random = new Random();

    String id = "1000";

    builder.add("Antoninus"); // name
    builder.add((int) Math.round(random.nextDouble()*110)); // age
    builder.add(new Date()); // dtg
    builder.add(WKTUtils$.MODULE$.read("POINT(-1 -1)")); // geom
    SimpleFeature feature = builder.buildFeature(id);

    featureCollection.add(feature);
    producerFS.addFeatures(featureCollection);

    FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2();
    Filter idFilter = ff.id(ff.featureId(id));
    producerFS.removeFeatures(idFilter);
}
 
开发者ID:geomesa,项目名称:geomesa-tutorials,代码行数:22,代码来源:KafkaQuickStart.java

示例3: main

import org.geotools.data.FeatureStore; //导入方法依赖的package包/类
public static void main(String[] args) throws MalformedURLException,
		IOException, NoSuchAuthorityCodeException, FactoryException {
	if (args.length < 3) {
		System.err.println("Usage: ReprojectShapeFile in.shp out.shp epsg:code");
		System.exit(3);
	}
	File in = new File(args[0]);
	File out = new File(args[1]);
	CoordinateReferenceSystem crs = CRS.decode(args[2]);

	ShapefileDataStoreFactory fac = new ShapefileDataStoreFactory();
	FileDataStore inStore = fac.createDataStore(in.toURI().toURL());
	FileDataStore outStore = fac.createDataStore(out.toURI().toURL());

	SimpleFeatureCollection inFeatures = inStore.getFeatureSource()
			.getFeatures();

	ReprojectShapeFile reprojector = new ReprojectShapeFile();

	SimpleFeatureCollection outFeatures = reprojector
			.reproject(inFeatures, crs);
	outStore.createSchema(outFeatures.getSchema());
	Transaction transaction = new DefaultTransaction("create");
	String outName = outStore.getNames().get(0).getLocalPart();
	SimpleFeatureSource featureSource = outStore.getFeatureSource(outName);
	FeatureStore featureStore = (FeatureStore) featureSource;
	featureStore.setTransaction(transaction);
	featureStore.addFeatures(outFeatures);
	transaction.commit();
	outStore.dispose();
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:32,代码来源:ReprojectShapeFile.java

示例4: save

import org.geotools.data.FeatureStore; //导入方法依赖的package包/类
/**
* Save the corresponding VDS into corresponding format [kmz,xml,ddbb]
* @param layer
* @param projection
*/
  @Override
  public void save(File output, String projection,GeoTransform transform) {
      try {
      	//Data store to get access to ddbb
          DataStore datastore = (DataStore) DataStoreFinder.getDataStore(config);
          //Access to the corresponding VDS layer on ddbb f.i: 'VESSELS'
          FeatureStore featurestore = (FeatureStore) datastore.getFeatureSource(layername);
          SimpleFeatureType featuretype = (SimpleFeatureType) featurestore.getSchema();
          /* @FIX I need explanation
           impleFeatureTypeBuilder builder =  new SimpleFeatureTypeBuilder();
          builder.setName(featuretype.getName());

          builder.setCRS(featuretype.getCoordinateReferenceSystem());
          System.out.println(featuretype.getDescriptors().size());
          //build the type
          //SimpleFeatureType type = builder.buildFeatureType();
          // System.out.println(type.getDescriptors().size());
          //*/
          FeatureCollection features = createFeatures(featuretype, glayer, projection, gir.getGeoTransform());
          featurestore.addFeatures(features);
          writeToDB(datastore, features);
          datastore.dispose();


      } catch (Exception ex) {
      	logger.error(ex.getMessage(),ex);
      }
  }
 
开发者ID:ec-europa,项目名称:sumo,代码行数:34,代码来源:PostgisIO.java

示例5: insertFeatures

import org.geotools.data.FeatureStore; //导入方法依赖的package包/类
static void insertFeatures(String simpleFeatureTypeName,
                           DataStore dataStore,
                           FeatureCollection featureCollection)
        throws IOException {

    FeatureStore featureStore = (SimpleFeatureStore) dataStore.getFeatureSource(simpleFeatureTypeName);
    featureStore.addFeatures(featureCollection);
}
 
开发者ID:geomesa,项目名称:geomesa-tutorials,代码行数:9,代码来源:FeatureLevelVisibility.java

示例6: writeShapefile

import org.geotools.data.FeatureStore; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public static void writeShapefile(EnsembleDeLiens liens, String file) throws SchemaException, IOException {
  ShapefileDataStore store = new ShapefileDataStore(new File(file).toURI().toURL());
  String specs = "the_geom:LineString,linkId:Integer,edgeId:Integer,refId:Integer,compId:Integer,evalLink:Double,surfDist:Double,exact:Double,compl:Double"; //$NON-NLS-1$
  SimpleFeatureType type = DataUtilities.createType("Link", specs);
  store.createSchema(type);
  FeatureStore<SimpleFeatureType, SimpleFeature> featureStore = (FeatureStore<SimpleFeatureType, SimpleFeature>) store.getFeatureSource("Link");
  Transaction t = new DefaultTransaction();
  DefaultFeatureCollection collection = new DefaultFeatureCollection("coll",type);
  
  int linkId = 1;
  int edgeId = 1;
  GeometryFactory factory = new GeometryFactory();
  for (Lien feature : liens) {
    for (Arc edge : feature.getArcs()) {
      Lien l = (Lien) edge.getCorrespondant(0);
      List<Object> liste = new ArrayList<Object>(5);
      IFeature source = l.getObjetsRef().get(0);
      IFeature target = l.getObjetsComp().get(0);
      IDirectPosition sourcePosition = source.getGeom().centroid();
      IDirectPosition targetPosition = target.getGeom().centroid();
      liste.add(factory.createLineString(new Coordinate[]{new Coordinate(sourcePosition.getX(), sourcePosition.getY()), new Coordinate(targetPosition.getX(), targetPosition.getY())}));
      liste.add(new Integer(linkId));
      liste.add(new Integer(edgeId));
      liste.add(source.getAttribute("buildingId"));
      liste.add(target.getAttribute("buildingId"));
      liste.add(feature.getEvaluation());
      liste.add(feature.getDistanceSurfacique());
      liste.add(feature.getExactitude());
      liste.add(feature.getCompletude());
      SimpleFeature simpleFeature = SimpleFeatureBuilder.build(type, liste.toArray(), String
          .valueOf(edgeId++));
      collection.add(simpleFeature);
    }
    linkId++;
  }
  featureStore.addFeatures(collection);
  t.commit();
  t.close();
  store.dispose();
}
 
开发者ID:IGNF,项目名称:geoxygene,代码行数:42,代码来源:AppariementSurfaces.java

示例7: addSimpleFeatures

import org.geotools.data.FeatureStore; //导入方法依赖的package包/类
public static void addSimpleFeatures(SimpleFeatureType sft, FeatureStore producerFS, String visibility)
        throws InterruptedException, IOException {
    final int MIN_X = -180;
    final int MAX_X = 180;
    final int MIN_Y = -90;
    final int MAX_Y = 90;
    final int DX = 2;
    final int DY = 1;
    final String[] PEOPLE_NAMES = {"James", "John", "Peter", "Hannah", "Claire", "Gabriel"};
    final long SECONDS_PER_YEAR = 365L * 24L * 60L * 60L;
    final Random random = new Random();
    final DateTime MIN_DATE = new DateTime(2015, 1, 1, 0, 0, 0, DateTimeZone.forID("UTC"));

    SimpleFeatureBuilder builder = new SimpleFeatureBuilder(sft);
    DefaultFeatureCollection featureCollection = new DefaultFeatureCollection();

    // creates and updates two SimpleFeatures.
    // the first time this for loop runs the two SimpleFeatures are created.
    // in the subsequent iterations of the for loop, the two SimpleFeatures are updated.
    int numFeatures = (MAX_X - MIN_X) / DX;
    for (int i = 1; i <= numFeatures; i++) {
        builder.add(PEOPLE_NAMES[i % PEOPLE_NAMES.length]); // name
        builder.add((int) Math.round(random.nextDouble()*110)); // age
        builder.add(MIN_DATE.plusSeconds((int) Math.round(random.nextDouble() * SECONDS_PER_YEAR)).toDate()); // dtg
        builder.add(WKTUtils$.MODULE$.read("POINT(" + (MIN_X + DX * i) + " " + (MIN_Y + DY * i) + ")")); // geom
        SimpleFeature feature1 = builder.buildFeature("1");
        feature1.getUserData().put(Hints.USE_PROVIDED_FID, Boolean.TRUE);

        builder.add(PEOPLE_NAMES[(i+1) % PEOPLE_NAMES.length]); // name
        builder.add((int) Math.round(random.nextDouble()*110)); // age
        builder.add(MIN_DATE.plusSeconds((int) Math.round(random.nextDouble() * SECONDS_PER_YEAR)).toDate()); // dtg
        builder.add(WKTUtils$.MODULE$.read("POINT(" + (MIN_X + DX * i) + " " + (MAX_Y - DY * i) + ")")); // geom
        SimpleFeature feature2 = builder.buildFeature("2");
        feature2.getUserData().put(Hints.USE_PROVIDED_FID, Boolean.TRUE);

        if (visibility != null) {
            feature1.getUserData().put("geomesa.feature.visibility", visibility);
            feature2.getUserData().put("geomesa.feature.visibility", visibility);
        }

        // write the SimpleFeatures to Kafka
        featureCollection.add(feature1);
        featureCollection.add(feature2);
        producerFS.addFeatures(featureCollection);
        featureCollection.clear();

        // wait 100 ms in between updating SimpleFeatures to simulate a stream of data
        Thread.sleep(100);
    }
}
 
开发者ID:geomesa,项目名称:geomesa-tutorials,代码行数:51,代码来源:KafkaQuickStart.java

示例8: createShapeFile

import org.geotools.data.FeatureStore; //导入方法依赖的package包/类
private File createShapeFile(FeatureCollection<SimpleFeatureType, SimpleFeature> collection) throws IOException {

		String shapeFileSuffix = ".shp";

		File tempBaseFile = File.createTempFile("resolveDir", ".tmp");
		tempBaseFile.deleteOnExit();
		File parent = tempBaseFile.getParentFile();

		File shpBaseDirectory = new File(parent, UUID.randomUUID().toString());

		if (!shpBaseDirectory.mkdir()) {
			throw new IllegalStateException("Could not create temporary shp directory.");
		}

		File tempSHPfile = File.createTempFile("shp", shapeFileSuffix, shpBaseDirectory);
		tempSHPfile.deleteOnExit();
		DataStoreFactorySpi dataStoreFactory = new ShapefileDataStoreFactory();
		Map<String, Serializable> params = new HashMap<String, Serializable>();
		params.put("url", tempSHPfile.toURI().toURL());
		params.put("create spatial index", Boolean.TRUE);

		ShapefileDataStore newDataStore = (ShapefileDataStore) dataStoreFactory
				.createNewDataStore(params);

		newDataStore.createSchema(collection.getSchema());
		if(collection.getSchema().getCoordinateReferenceSystem()==null){
			newDataStore.forceSchemaCRS(getCRS_WGS84());
		}else{
			newDataStore.forceSchemaCRS(collection.getSchema()
				.getCoordinateReferenceSystem());
		}

		Transaction transaction = new DefaultTransaction("create");

		String typeName = newDataStore.getTypeNames()[0];
		@SuppressWarnings("unchecked")
		FeatureStore<SimpleFeatureType, SimpleFeature> featureStore = (FeatureStore<SimpleFeatureType, SimpleFeature>) newDataStore
				.getFeatureSource(typeName);
		featureStore.setTransaction(transaction);
		try {
			featureStore.addFeatures(collection);
			transaction.commit();
		} catch (Exception problem) {
			transaction.rollback();
		} finally {
			transaction.close();
		}

		// Get names of additional files
		String path = tempSHPfile.getAbsolutePath();
		String baseName = path.substring(0, path.length() - shapeFileSuffix.length());
		File shx = new File(baseName + ".shx");
		File dbf = new File(baseName + ".dbf");
		File prj = new File(baseName + ".prj");

		// mark created files for delete
		tempSHPfile.deleteOnExit();
		shx.deleteOnExit();
		dbf.deleteOnExit();
		prj.deleteOnExit();
		shpBaseDirectory.deleteOnExit();

		return shpBaseDirectory;
	}
 
开发者ID:enviroCar,项目名称:enviroCar-server,代码行数:65,代码来源:TrackShapefileEncoder.java


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