Examples of SimpleFeatureStore


Examples of org.geotools.data.simple.SimpleFeatureStore

  }

  public Object create(Object feature) throws LayerException {
    FeatureSource<SimpleFeatureType, SimpleFeature> source = getFeatureSource();
    if (source instanceof FeatureStore<?, ?>) {
      SimpleFeatureStore store = (SimpleFeatureStore) source;
      FeatureCollection<SimpleFeatureType, SimpleFeature> col = DataUtilities
          .collection(new SimpleFeature[] { (SimpleFeature) feature });
      if (transactionManager != null) {
        store.setTransaction(transactionManager.getTransaction());
      }
      try {
        store.addFeatures(col);
      } catch (IOException ioe) {
        featureModelUsable = false;
        throw new LayerException(ioe, ExceptionCode.LAYER_MODEL_IO_EXCEPTION);
      }
      return feature;
View Full Code Here

Examples of org.geotools.data.simple.SimpleFeatureStore

  }

  public void update(Object feature) throws LayerException {
    FeatureSource<SimpleFeatureType, SimpleFeature> source = getFeatureSource();
    if (source instanceof FeatureStore<?, ?>) {
      SimpleFeatureStore store = (SimpleFeatureStore) source;
      String featureId = getFeatureModel().getId(feature);
      Filter filter = filterService.createFidFilter(new String[] {featureId});
      if (transactionManager != null) {
        store.setTransaction(transactionManager.getTransaction());
      }
      List<Name> names = new ArrayList<Name>();
      Map<String, Attribute> attrMap = getFeatureModel().getAttributes(feature);
      List<Object> values = new ArrayList<Object>();
      for (String name : attrMap.keySet()) {
        names.add(store.getSchema().getDescriptor(name).getName());
        values.add(attrMap.get(name).getValue());
      }

      try {
        store.modifyFeatures(names.toArray(new Name[names.size()]), values.toArray(), filter);
        store.modifyFeatures(store.getSchema().getGeometryDescriptor().getName(), getFeatureModel()
            .getGeometry(feature), filter);
        log.debug("Updated feature {} in {}", featureId, getFeatureSourceName());
      } catch (IOException ioe) {
        featureModelUsable = false;
        throw new LayerException(ioe, ExceptionCode.LAYER_MODEL_IO_EXCEPTION);
View Full Code Here

Examples of org.geotools.data.simple.SimpleFeatureStore

  }

  public void delete(String featureId) throws LayerException {
    FeatureSource<SimpleFeatureType, SimpleFeature> source = getFeatureSource();
    if (source instanceof FeatureStore<?, ?>) {
      SimpleFeatureStore store = (SimpleFeatureStore) source;
      Filter filter = filterService.createFidFilter(new String[] {featureId});
      if (transactionManager != null) {
        store.setTransaction(transactionManager.getTransaction());
      }
      try {
        store.removeFeatures(filter);
        if (log.isDebugEnabled()) {
          log.debug("Deleted feature {} in {}", featureId, getFeatureSourceName());
        }
      } catch (IOException ioe) {
        featureModelUsable = false;
View Full Code Here

Examples of org.geotools.data.simple.SimpleFeatureStore

  }

  public Envelope getBounds() throws LayerException {
    FeatureSource<SimpleFeatureType, SimpleFeature> source = getFeatureSource();
    if (source instanceof FeatureStore<?, ?>) {
      SimpleFeatureStore store = (SimpleFeatureStore) source;
      if (transactionManager != null) {
        store.setTransaction(transactionManager.getTransaction());
      }
    }
    try {
      FeatureCollection<SimpleFeatureType, SimpleFeature> fc = source.getFeatures();
      FeatureIterator<SimpleFeature> it = fc.features();
View Full Code Here

Examples of org.geotools.data.simple.SimpleFeatureStore

   * @return the bounds of the specified features
   */
  public Envelope getBounds(Filter filter) throws LayerException {
    FeatureSource<SimpleFeatureType, SimpleFeature> source = getFeatureSource();
    if (source instanceof FeatureStore<?, ?>) {
      SimpleFeatureStore store = (SimpleFeatureStore) source;
      if (transactionManager != null) {
        store.setTransaction(transactionManager.getTransaction());
      }
    }
    try {
      FeatureCollection<SimpleFeatureType, SimpleFeature> fc = source.getFeatures(filter);
      FeatureIterator<SimpleFeature> it = fc.features();
View Full Code Here

Examples of org.geotools.data.simple.SimpleFeatureStore

   * This implementation does not support the 'offset' and 'maxResultSize' parameters.
   */
  public Iterator<?> getElements(Filter filter, int offset, int maxResultSize) throws LayerException {
    FeatureSource<SimpleFeatureType, SimpleFeature> source = getFeatureSource();
    if (source instanceof FeatureStore<?, ?>) {
      SimpleFeatureStore store = (SimpleFeatureStore) source;
      if (transactionManager != null) {
        store.setTransaction(transactionManager.getTransaction());
      }
    }
    try {
      FeatureCollection<SimpleFeatureType, SimpleFeature> fc = source.getFeatures(filter);
      FeatureIterator<SimpleFeature> it = fc.features();
View Full Code Here

Examples of org.geotools.data.simple.SimpleFeatureStore

            String typeName = dataStore.getTypeNames()[0];
            SimpleFeatureSource featureSource = dataStore.getFeatureSource(typeName);

            if (featureSource instanceof SimpleFeatureStore)
            {
                SimpleFeatureStore featureStore = (SimpleFeatureStore) featureSource;

                featureStore.setTransaction(transaction);
              
                featureStore.addFeatures(collection);
                transaction.commit();

                transaction.close();
            }
            else
View Full Code Here

Examples of org.geotools.data.simple.SimpleFeatureStore

     */
    private SimpleFeature getFeature(IGeoResource geoResource, FidFilterImpl filter) {
        if (filter != null) {
            try {
                if (geoResource.canResolve(SimpleFeatureStore.class)) {
                    final SimpleFeatureStore featureSource = geoResource.resolve(SimpleFeatureStore.class,
                            new NullProgressMonitor());
                    final SimpleFeatureCollection featureCollection = featureSource.getFeatures(filter);
                    final SimpleFeatureIterator featureIterator = featureCollection.features();
                    try {
                         if (featureIterator.hasNext()) {
                             return featureIterator.next();
                         }
View Full Code Here

Examples of org.geotools.data.simple.SimpleFeatureStore

            final Object obj, IProgressMonitor monitor) {

        try {
            if (geoResource.canResolve(SimpleFeatureStore.class)) {
                final Filter filter = CommonFactoryFinder.getFilterFactory2().id(fid);
                final SimpleFeatureStore featureStore = geoResource.resolve(
                        SimpleFeatureStore.class, monitor);
                featureStore.modifyFeatures(attributeName, obj, filter);
                return true;
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
View Full Code Here

Examples of org.geotools.data.simple.SimpleFeatureStore

                    SimpleFeatureType featureType = csvFileFeatureCollection.getSchema();
                    JGrassCatalogUtilities.removeMemoryServiceByTypeName(featureType.getTypeName());
                    IGeoResource resource = CatalogPlugin.getDefault().getLocalCatalog().createTemporaryResource(featureType);

                    SimpleFeatureStore resolve = (SimpleFeatureStore) resource.resolve(FeatureStore.class, pm);
                    resolve.addFeatures(csvFileFeatureCollection);
                    ApplicationGIS.addLayersToMap(ApplicationGIS.getActiveMap(), Collections.singletonList(resource), -1);

                } catch (Exception e) {
                    e.printStackTrace();
                    String message = Messages.getString("CsvImportWizard.error"); //$NON-NLS-1$
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.