• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java FeatureStore类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: addFeatureToStore

import org.geotools.data.FeatureStore; //导入依赖的package包/类
/**
 * 
 * @param store
 * @param typeName
 * @param feature
 * @throws IOException
 */
public static void addFeatureToStore(DataStore store,
		String typeName, SimpleFeature feature) throws IOException {
	
	((FeatureStore)store.getFeatureSource(typeName)).addFeatures(
			DataUtilities.collection(GeoCollectUtils.cloneFeature(store, typeName, feature, new HashMap<String, String>())));
	
}
 
开发者ID:geosolutions-it,项目名称:OpenSDI-Manager2,代码行数:15,代码来源:TestUtils.java


示例17: canResolve

import org.geotools.data.FeatureStore; //导入依赖的package包/类
@Override
public <T> boolean canResolve(final Class<T> adaptee) {
	if (adaptee == null) {
		return false;
	}
	return (adaptee.isAssignableFrom(IGeoResourceInfo.class)
			|| adaptee.isAssignableFrom(FeatureStore.class)
			|| adaptee.isAssignableFrom(FeatureSource.class)
			|| adaptee.isAssignableFrom(SOSDataStore.class)
			|| adaptee.isAssignableFrom(UDIGSOSDataStore.class) || adaptee
			.isAssignableFrom(IService.class))
			|| super.canResolve(adaptee);
}
 
开发者ID:52North,项目名称:uDig-SOS-plugin,代码行数:14,代码来源:SOSGeoResourceImpl.java


示例18: resolve

import org.geotools.data.FeatureStore; //导入依赖的package包/类
@Override
public <T> T resolve(final Class<T> adaptee, final IProgressMonitor monitor)
		throws IOException {
	if (adaptee == null) {
		return null;
	}
	// if(adaptee.isAssignableFrom(IService.class))
	// return adaptee.cast( parent );
	if (adaptee.isAssignableFrom(SOSDataStore.class)) {
		return parent.resolve(adaptee, monitor);
	}
	if (adaptee.isAssignableFrom(UDIGSOSDataStore.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)) {
		final 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-SOS-plugin,代码行数:34,代码来源:SOSGeoResourceImpl.java


示例19: canResolve

import org.geotools.data.FeatureStore; //导入依赖的package包/类
public <T> boolean canResolve( Class<T> adaptee ) {
    if(adaptee == null)
        return false;
    return (adaptee.isAssignableFrom(IGeoResourceInfo.class) || 
            adaptee.isAssignableFrom(FeatureStore.class) || 
            adaptee.isAssignableFrom(FeatureSource.class) || 
            adaptee.isAssignableFrom(WPSDataStore.class) ||
            adaptee.isAssignableFrom(IService.class))||
            super.canResolve(adaptee);
}
 
开发者ID:52North,项目名称:uDig-WPS-plugin,代码行数:11,代码来源:WPSGeoResourceImpl.java


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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java BlockSnapshot类代码示例发布时间:2022-05-21
下一篇:
Java DefaultGlobalScopeProvider类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap