Package org.geotools.data.memory

Examples of org.geotools.data.memory.MemoryFeatureCollection


    List<String> attrs = (List<String>) model.get(RestController.ATTRIBUTES);
    SimpleFeatureType sft = convertorService.toSimpleFeatureType(info, attrs);
    response.setContentType(getContentType());
    if (Collection.class.isAssignableFrom(ff.getClass())) {
      Collection<InternalFeature> features = (Collection<InternalFeature>) ff;
      FeatureCollection<SimpleFeatureType, SimpleFeature> coll = new MemoryFeatureCollection(sft);
      for (InternalFeature feature : features) {
        coll.add(convertorService.toSimpleFeature(feature, sft));
      }
      parser.write(coll, response.getOutputStream());
    } else {
      InternalFeature feature = (InternalFeature) ff;
      parser.write(convertorService.toSimpleFeature(feature, sft), response.getOutputStream());
View Full Code Here


            errorMessage = new HashMap<String, String>();
            Geometry geometry = extractGeometriesFrom(
                    schemaDir, metadata, _parser, errorMessage);

            if (geometry != null && !geometry.getEnvelopeInternal().isNull()) {
                MemoryFeatureCollection features = new MemoryFeatureCollection(_featureStore.getSchema());
                SimpleFeatureType schema = _featureStore.getSchema();
               
                SimpleFeature template = SimpleFeatureBuilder.template(schema,
                        SimpleFeatureBuilder.createDefaultFeatureId());
                template.setAttribute(schema.getGeometryDescriptor().getName(), geometry);
                template.setAttribute(_idColumn == null? _IDS_ATTRIBUTE_NAME : _idColumn.toString(), id);
                features.add(template);

                _featureStore.addFeatures(features);

                _writes++;
View Full Code Here

            }
           
            //get the data from the source
            try{
                //cache these features in a local feature collection while we deal with them
                SimpleFeatureCollection localSource = new MemoryFeatureCollection(getSchema());
                fromSource = this.fs.getFeatures(filter);
                localSource.addAll(fromSource);
                fromSource = localSource;
            }catch (Exception ex){
                //something happened getting data from source
                //return what we have from the cache
                logger.log(Level.INFO, "Error getting data for cache from source feature store.", ex);
View Full Code Here

    ftb.add(LABEL_COLUMN, String.class);
    ftb.setName(MY_FEATURE);
        final SimpleFeatureType schema = ftb.buildFeatureType();

        // create a feature collection ----------------------------------------
        final MemoryFeatureCollection fc = new MemoryFeatureCollection(schema);

        // populate the collection --------------------------------------------
        final PrecisionModel pm = new PrecisionModel(PrecisionModel.FLOATING);
        final GeometryFactory jtsFactory = new GeometryFactory(pm, SRID);

        // create 1st point
        final Point g1 = jtsFactory.createPoint(new Coordinate(X_1, Y_1));
        fc.add(SimpleFeatureBuilder.build(schema, new Object[] { new Integer(1), g1, LABEL_1 }, ID_1));

        // create 2nd point
        final Point g2 = jtsFactory.createPoint(new Coordinate(X_2, Y_2));
        fc.add(SimpleFeatureBuilder.build(schema, new Object[] { new Integer(2), g2, LABEL_2 }, ID_2));

        final DataStore ds = new MemoryDataStore(fc);

        // create and populate the layer --------------------------------------
        final StyleFactory sf = CommonFactoryFinder.getStyleFactory(GeoTools.getDefaultHints());
View Full Code Here

        assertNotNull(source);
        assertTrue(source instanceof WFSFeatureStore);

        WFSFeatureStore store = (WFSFeatureStore) source;
                
        MemoryFeatureCollection collection = new MemoryFeatureCollection(featureType1);
       
        Coordinate insideCoord = new Coordinate(5.2, 7.5);
        Point myPoint = geomfac.createPoint(insideCoord);
       
        SimpleFeature feat = new SimpleFeatureImpl(Arrays.asList(new Object[]{myPoint, "mypoint""pics/x.jpg", "pics/y.jpg"}), featureType1, new FeatureIdImpl("myid") );
       
        collection.add(feat);
       
        List<FeatureId> fids = store.addFeatures((SimpleFeatureCollection) collection);
       
        assertEquals(1, fids.size());
       
View Full Code Here

        assertNotNull(source);
        assertTrue(source instanceof WFSFeatureStore);

        WFSFeatureStore store = (WFSFeatureStore) source;
                
        MemoryFeatureCollection collection = new MemoryFeatureCollection(featureType1);
       
        Coordinate insideCoord = new Coordinate(5.2, 7.5);
        Point myPoint = geomfac.createPoint(insideCoord);
       
        SimpleFeature feat = new SimpleFeatureImpl(Arrays.asList(new Object[]{myPoint, "mypoint""pics/x.jpg", "pics/y.jpg"}), featureType1, new FeatureIdImpl("myid") );
       
        collection.add(feat);
       
        Transaction transaction = new DefaultTransaction();
        store.setTransaction(transaction);
       
        List<FeatureId> fids = store.addFeatures((SimpleFeatureCollection) collection);       
View Full Code Here

        }
        geoms[i] = gf.createLineString(c);
      }
     
      SimpleFeature features[] = new SimpleFeature[geoms.length];
      MemoryFeatureCollection mm = new MemoryFeatureCollection(featureType);
      for (int i = 0; i < geoms.length; i ++){
        features[i] = fb.buildFeature(i +"", new Object[]{new Integer(i), geoms[i]});
        mm.add(features[i]);
      }
     
      DataStore ds = new MemoryDataStore(mm);
      FeatureCache cache = new GridFeatureCache(ds.getFeatureSource(featureType.getTypeName()), 4, 4, MemoryStorage.createInstance());
     
View Full Code Here

      geoms[i] = gf.createLineString(c);
    }

    SimpleFeature features[] = new SimpleFeature[geoms.length];

    MemoryFeatureCollection mm = new MemoryFeatureCollection(featureType);
    for (int i = 0; i < geoms.length; i++) {
      features[i] = fb.buildFeature(i + "", new Object[] {
          new Integer(i), geoms[i] });
      mm.add(features[i]);
    }

    //
    // ---- CACHING FEATURE COLLECTION -----
    //
View Full Code Here

        }
        geoms[i] = gf.createLineString(c);
      }
     
      SimpleFeature features[] = new SimpleFeature[geoms.length];
      MemoryFeatureCollection mm = new MemoryFeatureCollection(featureType);
      for (int i = 0; i < geoms.length; i ++){
        features[i] = fb.buildFeature(i +"", new Object[]{new Integer(i), geoms[i]});
        mm.add(features[i]);
      }
     
      DataStore ds = new MemoryDataStore(mm);
      FeatureCache cache = new StreamingGridFeatureCache(ds.getFeatureSource(featureType.getTypeName()), 4, 4, MemoryStorage.createInstance());
     
View Full Code Here

                assertEquals(type1.getDescriptor(i).getName(), type2.getDescriptor(i).getName());
                assertEquals(type1.getDescriptor(i).getType(), type2.getDescriptor(i).getType());
            }
           
            //compare data
            MemoryFeatureCollection memCollection = new MemoryFeatureCollection(type2);
            while (reader.hasNext()) {
                memCollection.add(reader.next());
            }
           
            assertEquals(sCollection.size(), memCollection.size());
           
            SimpleFeatureIterator it = sCollection.features();
            while (it.hasNext()) {
                SimpleFeature sf = it.next();
                for (int i = 0; i < type1.getDescriptors().size(); i++) {
View Full Code Here

TOP

Related Classes of org.geotools.data.memory.MemoryFeatureCollection

Copyright © 2018 www.massapicom. 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.