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


Java FeatureStore类代码示例

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


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

import org.geotools.data.FeatureStore; //导入依赖的package包/类
/**
 * Gets the feature store.
 *
 * @return the feature store
 */
public FeatureStore<SimpleFeatureType, SimpleFeature> getFeatureStore() {
    FeatureStore<SimpleFeatureType, SimpleFeature> featureStore = null;

    if(dataStore != null)
    {
        try
        {
            FeatureSource<SimpleFeatureType, SimpleFeature> featureSource = dataStore.getFeatureSource(typeName);

            featureStore = (FeatureStore<SimpleFeatureType, SimpleFeature>) featureSource;
        } catch (IOException e) {
            ConsoleManager.getInstance().exception(this, e);
        }
    }
    return featureStore;
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:22,代码来源:DataSourceInfo.java

示例3: getFeatureStore

import org.geotools.data.FeatureStore; //导入依赖的package包/类
/**
 * Gets the feature store.
 *
 * @return the feature store
 */
public FeatureStore<SimpleFeatureType, SimpleFeature> getFeatureStore() {
    FeatureStore<SimpleFeatureType, SimpleFeature> featureStore = null;

    if (dataStore != null) {
        try {
            FeatureSource<SimpleFeatureType, SimpleFeature> featureSource = dataStore
                    .getFeatureSource(typeName);

            featureStore = (FeatureStore<SimpleFeatureType, SimpleFeature>) featureSource;
        } catch (IOException e) {
            ConsoleManager.getInstance().exception(this, e);
        }
    }
    return featureStore;
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:21,代码来源:DataSourceInfo.java

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

示例5: initInternal

import org.geotools.data.FeatureStore; //导入依赖的package包/类
private void initInternal() throws IOException {
    validPredicates = ConfigUtils.getGeoPredicates(conf);

    final DataStore dataStore = createDataStore(conf);

    try {
        featureType = getStatementFeatureType(dataStore);
    } catch (final IOException | SchemaException e) {
        throw new IOException(e);
    }

    featureSource = dataStore.getFeatureSource(featureType.getName());
    if (!(featureSource instanceof FeatureStore)) {
        throw new IllegalStateException("Could not retrieve feature store");
    }
    featureStore = (FeatureStore<SimpleFeatureType, SimpleFeature>) featureSource;
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:18,代码来源:GeoMesaGeoIndexer.java

示例6: resolve

import org.geotools.data.FeatureStore; //导入依赖的package包/类
public <T> T resolve( Class<T> adaptee, IProgressMonitor monitor ) throws IOException {
        if(adaptee == null)
            return null;
//        if(adaptee.isAssignableFrom(IService.class))
//            return adaptee.cast( parent );        
        if(adaptee.isAssignableFrom(WPSDataStore.class))
            return parent.resolve( adaptee, monitor );
        if (adaptee.isAssignableFrom(IGeoResource.class))
            return adaptee.cast( this );
        if(adaptee.isAssignableFrom(IGeoResourceInfo.class))
            return adaptee.cast( getInfo(monitor));
        if(adaptee.isAssignableFrom(FeatureStore.class)){
        	FeatureSource fs = parent.getDS(monitor).getFeatureSource(typeName);
            if(fs instanceof FeatureStore)
                return adaptee.cast( fs);
        if(adaptee.isAssignableFrom(FeatureSource.class))
            return adaptee.cast( parent.getDS(monitor).getFeatureSource(typeName));
        }
        return super.resolve(adaptee, monitor);
    }
 
开发者ID:52North,项目名称:uDig-WPS-plugin,代码行数:21,代码来源:WPSGeoResourceImpl.java

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

示例8: getBounds

import org.geotools.data.FeatureStore; //导入依赖的package包/类
@Override
public Envelope getBounds(Filter filter) throws LayerException {
	FeatureSource<SimpleFeatureType, SimpleFeature> source = getFeatureSource();
	if (source instanceof FeatureStore<?, ?>) {
		SimpleFeatureStore store = (SimpleFeatureStore) source;
		transactionSynchronization.synchTransaction(store);
	}
	try {
		FeatureCollection<SimpleFeatureType, SimpleFeature> fc;
		if (null == filter) {
			fc = source.getFeatures();
		} else {
			fc = source.getFeatures(filter);
		}
		FeatureIterator<SimpleFeature> it = fc.features();
		transactionSynchronization.addIterator(it);
		return fc.getBounds();
	} catch (Throwable t) { // NOSONAR avoid errors (like NPE) as well
		throw new LayerException(t, ExceptionCode.UNEXPECTED_PROBLEM);
	}
}
 
开发者ID:geomajas,项目名称:geomajas-project-server,代码行数:22,代码来源:GeoToolsLayer.java

示例9: getElements

import org.geotools.data.FeatureStore; //导入依赖的package包/类
/**
 * {@inheritDoc}
 *
 */
@Transactional(readOnly = true)
public Iterator<?> getElements(Filter filter, int offset, int maxResultSize) throws LayerException {
	FeatureSource<SimpleFeatureType, SimpleFeature> source = getFeatureSource();
	try {
		if (source instanceof FeatureStore<?, ?>) {
			SimpleFeatureStore store = (SimpleFeatureStore) source;
			transactionSynchronization.synchTransaction(store);
		}
		Query query = new Query();
		query.setFilter(filter);
		query.setMaxFeatures(maxResultSize > 0 ? maxResultSize : Integer.MAX_VALUE);
		query.setStartIndex(offset);
		FeatureCollection<SimpleFeatureType, SimpleFeature> fc = source.getFeatures(query);
		FeatureIterator<SimpleFeature> it = fc.features();
		transactionSynchronization.addIterator(it);
		return new JavaIterator(it);
	} catch (Throwable t) { // NOSONAR avoid errors (like NPE) as well
		throw new LayerException(t, ExceptionCode.UNEXPECTED_PROBLEM);
	}
}
 
开发者ID:geomajas,项目名称:geomajas-project-server,代码行数:25,代码来源:GeoToolsLayer.java

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

示例11: addFeatures

import org.geotools.data.FeatureStore; //导入依赖的package包/类
/**
 * see interface for details.
 * @param fc
 *
 * @throws IOException
 */
public List<FeatureId> addFeatures(FeatureCollection<SimpleFeatureType, SimpleFeature> fc) throws IOException {
    FeatureStore<SimpleFeatureType, SimpleFeature> store = store();

    //check if the feature collection needs to be retyped
    if (!store.getSchema().equals(fc.getSchema())) {
        fc = new RetypingFeatureCollection(DataUtilities.simple(fc), store.getSchema());
    }

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

示例12: setFeatures

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

示例13: testGetFeatureStore

import org.geotools.data.FeatureStore; //导入依赖的package包/类
/**
 * Test method for {@link com.sldeditor.datasource.impl.DataSourceInfo#getFeatureStore()}. Test
 * method for
 * {@link com.sldeditor.datasource.impl.DataSourceInfo#setSchema(org.opengis.feature.type.FeatureType)}.
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void testGetFeatureStore() {
    URL url = SLDEditorFile.class.getClassLoader()
            .getResource("point/sld/shp/sld_cookbook_point.shp");

    Map map = new HashMap();
    map.put("url", url);
    DataStore dataStore;
    try {
        dataStore = DataStoreFinder.getDataStore(map);

        DataSourceInfo dsInfo = new DataSourceInfo();

        String typeName = dataStore.getTypeNames()[0];
        dsInfo.setTypeName(typeName);
        SimpleFeatureSource source = dataStore.getFeatureSource(typeName);
        SimpleFeatureType schema = source.getSchema();
        dsInfo.setSchema(schema);

        assertNull(dsInfo.getFeatureStore());
        dsInfo.setDataStore(dataStore);

        FeatureStore<SimpleFeatureType, SimpleFeature> featureStore = dsInfo.getFeatureStore();

        assertTrue(featureStore != null);
    } catch (IOException e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:37,代码来源:DataSourceInfoTest.java

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

示例15: executeQuery

import org.geotools.data.FeatureStore; //导入依赖的package包/类
/**
 * Executes a basic bounding box query
 *
 * @param simpleFeatureTypeName
 * @param dataStore
 *
 * @throws IOException
 * @throws CQLException
 */
static void executeQuery(String simpleFeatureTypeName, DataStore dataStore)
        throws IOException, CQLException {

    // start with our basic filter to narrow the results
    Filter cqlFilter = createBaseFilter();

    // use the 2-arg constructor for the query - this will not restrict the attributes returned
    Query query = new Query(simpleFeatureTypeName, cqlFilter);

    // get the feature store used to query the GeoMesa data
    FeatureStore featureStore = (FeatureStore) dataStore.getFeatureSource(simpleFeatureTypeName);

    // execute the query
    FeatureCollection results = featureStore.getFeatures(query);

    // loop through all results
    FeatureIterator iterator = results.features();
    try {
        printResults(iterator, Attributes.geom.getName());
    } finally {
        iterator.close();
    }
}
 
开发者ID:geomesa,项目名称:geomesa-tutorials,代码行数:33,代码来源:AuthorizationsTutorial.java


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