Examples of FeatureWriter


Examples of org.geotools.data.FeatureWriter

            t[i] = new Thread(new Runnable() {
                @Override
                public void run() {
                    for (int j = 0; j < 50; j++) {
                        try {
                            FeatureWriter w = dataStore.getFeatureWriter(tname("ft2"), Transaction.AUTO_COMMIT);
                            while (w.hasNext()) {
                                w.next();
                            }
                            SimpleFeature f = (SimpleFeature) w.next();
                            f.setAttribute(1, new Integer( (id * 100) + j));
                            f.setAttribute(2, "one");
                            w.write();
                            w.close();
                        } catch (Exception ex) {
                            ex.printStackTrace();
                            errors[0] = true;
                        }
                    }
View Full Code Here

Examples of org.geotools.data.FeatureWriter

        SimpleFeatureType featureType = builder.buildFeatureType();
        dataStore.createSchema(featureType);


        FeatureWriter w = dataStore.getFeatureWriter(tname("ft2"), Transaction.AUTO_COMMIT);
        w.hasNext();

        SimpleFeature f = (SimpleFeature) w.next();
        f.setAttribute(1, new Integer(0));
        f.setAttribute(2, "one");
        w.write();
        w.close();

        FilterFactory ff = dataStore.getFilterFactory();
        PropertyIsEqualTo correct = ff.equal(ff.property(aname("stringProperty")), ff.literal("one"), true);
        PropertyIsEqualTo incorrect = ff.equal(ff.property(aname("stringProperty")), ff.literal("OnE"), true);
View Full Code Here

Examples of org.geotools.data.FeatureWriter

    }
   
    static void loadData(MemoryDataStore mem, String name) throws Exception {
        WKTReader wkt = new WKTReader();

        FeatureWriter w = mem.getFeatureWriter(name, Transaction.AUTO_COMMIT);
        BufferedReader r = new BufferedReader(
                new InputStreamReader(
                        LabelObstacleTest.class.getResourceAsStream("test-data/obstacles/" + name
                                + ".txt")));
        String line = null;
        while ((line = r.readLine()) != null) {
            String[] values = line.split(";");
            SimpleFeature f = (SimpleFeature) w.next();
            for (int i = 0; i < f.getAttributeCount(); i++) {
                AttributeDescriptor ad = f.getType().getDescriptor(i);
                if (ad instanceof GeometryDescriptor) {
                    f.setAttribute(i, wkt.read(values[i]));
                } else {
                    f.setAttribute(i, values[i]);
                }
            }

            w.write();
        }

        r.close();
    }
View Full Code Here

Examples of org.geotools.data.FeatureWriter

     */
    public SimpleFeatureWriter writer(FeatureEntry entry, boolean append, Filter filter,
        Transaction tx) throws IOException {

        DataStore dataStore = dataStore();
        FeatureWriter w = append ?  dataStore.getFeatureWriterAppend(entry.getTableName(), tx)
            : dataStore.getFeatureWriter(entry.getTableName(), filter, tx);

        return Features.simple(w);
    }
View Full Code Here

Examples of org.geotools.data.FeatureWriter

        String typeName = sds.getTypeNames()[0];
        int idx = loadFeatures(sds, typeName).size();

        while (idx > 0) {
            FeatureWriter writer = null;

            try {
                writer = sds.getFeatureWriter(typeName, Filter.INCLUDE, Transaction.AUTO_COMMIT);
                writer.next();
                writer.remove();
            } finally {
                if (writer != null) {
                    writer.close();
                    writer = null;
                }
            }
            idx--;
            assertEquals(idx, countFeatures(loadFeatures(sds, typeName)));
View Full Code Here

Examples of org.geotools.data.FeatureWriter

        int idx = loadFeatures(sds, typeName).size();
        assertEquals(idx, countFeatures(loadFeatures(sds, typeName)));

        while (idx > 0) {
            FeatureWriter writer = null;
            try {
                writer = sds.getFeatureWriter(sds.getTypeNames()[0], Filter.INCLUDE,
                        Transaction.AUTO_COMMIT);
                while (writer.hasNext()) {
                    writer.next();
                }
                writer.remove();
            } finally {
                if (writer != null) {
                    writer.close();
                    writer = null;
                }
            }
            assertEquals(--idx, countFeatures(loadFeatures(sds, typeName)));
        }
View Full Code Here

Examples of org.geotools.data.FeatureWriter

            features[i] = SimpleFeatureBuilder.build(schema,
                    new Object[] { gf.createPoint(new Coordinate(i, i)), new Integer(i), "" + i },
                    null);
        }

        FeatureWriter writer = ds.getFeatureWriterAppend("testw", Transaction.AUTO_COMMIT);
        for (int i = 0; i < features.length; i++) {
            assertFalse(writer.hasNext());
            SimpleFeature f = (SimpleFeature) writer.next();
            f.setAttributes(features[i].getAttributes());
            writer.write();
        }
        writer.close();

        FeatureReader reader = ds.getFeatureReader(new Query("testw"), null);
        for (int i = 0; i < features.length; i++) {
            assertTrue(reader.hasNext());
            SimpleFeature f = (SimpleFeature) reader.next();
View Full Code Here

Examples of org.geotools.data.FeatureWriter

       
      // creates the feature writer using the schema of source feature collection.
      SimpleFeatureType schema = fc.getSchema();

        s.createSchema(schema);
        FeatureWriter fw = s.getFeatureWriter(s.getTypeNames()[0], Transaction.AUTO_COMMIT);

        FeatureIterator it = fc.features();
        while (it.hasNext()) {
            SimpleFeature sf = (SimpleFeature) it.next();
            ((SimpleFeature) fw.next()).setAttributes(sf.getAttributes());
            fw.write();
        }
        it.close();
        fw.close();
    }
View Full Code Here

Examples of org.geotools.data.FeatureWriter

       
      // creates the feature writer using the schema of source feature collection.
      SimpleFeatureType schema = buildFeatureTypeForMapInfo();
     
        s.createSchema(schema);
        FeatureWriter fw = s.getFeatureWriter(s.getTypeNames()[0], Transaction.AUTO_COMMIT);
        //FeatureWriter fw = s.getFeatureWriterAppend(s.getTypeNames()[0], Transaction.AUTO_COMMIT);
       
        FeatureIterator it = fc.features();
        while (it.hasNext()) {
            SimpleFeature sf = (SimpleFeature) it.next();
            ((SimpleFeature) fw.next()).setAttributes(sf.getAttributes());
            fw.write();
        }
        it.close();
        fw.close();
    }
View Full Code Here

Examples of org.geotools.data.FeatureWriter

      // creates the feature writer using the schema of source feature collection.
      SimpleFeatureType schema = fc.getSchema();

        dataStore.createSchema(schema);
        String typeName = dataStore.getTypeNames()[0];
    FeatureWriter fw = dataStore.getFeatureWriter(typeName, Transaction.AUTO_COMMIT);

        System.out.println("adding features ....");
        FeatureIterator it = fc.features();
        while (it.hasNext()) {
            SimpleFeature sf = (SimpleFeature) it.next();
            ((SimpleFeature) fw.next()).setAttributes(sf.getAttributes());
            fw.write();
        }
        it.close();
        fw.close();
        System.out.println("the end!!!");

    }
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.