Package org.geotools.data.shapefile

Examples of org.geotools.data.shapefile.ShapefileDataStore.createSchema()


                System.out.println("Creating shapefile " + file.getAbsolutePath());
               
                ShapefileDataStore ds = new ShapefileDataStore(file.toURL());
                tb.init(proto);
                tb.setName(name);
                ds.createSchema(tb.buildFeatureType());
               
                FeatureWriter fw = ds.getFeatureWriterAppend(name, Transaction.AUTO_COMMIT);
                for (int j = 0; j < m; j++) {
                    fw.hasNext();
                    SimpleFeature f = (SimpleFeature)fw.next();
View Full Code Here


        }
        builder.setName(outputFeatureType.getName());
        builder.setCRS(outputFeatureType.getCoordinateReferenceSystem());
        outputFeatureType = builder.buildFeatureType();

        dataStore.createSchema(outputFeatureType);

        final String typeName = dataStore.getTypeNames()[0];
        final SimpleFeatureSource featureSource = dataStore.getFeatureSource(typeName);
        if (!(featureSource instanceof SimpleFeatureStore)) {
            throw new CommandFailedException("Could not create feature store.");
View Full Code Here

            } catch (GeoToolsOpException e) {
                cli.getConsole().println("No features to export.");
                return;
            }
        }
        dataStore.createSchema(outputFeatureType);

        final String typeName = dataStore.getTypeNames()[0];
        final SimpleFeatureSource featureSource = dataStore.getFeatureSource(typeName);
        if (!(featureSource instanceof SimpleFeatureStore)) {
            throw new CommandFailedException("Could not create feature store.");
View Full Code Here

        /* Output the staged features to Shapefile */
        final File shapeDir = Files.createTempDir();
        File shapeFile = new File(shapeDir, shpName + ".shp");
        LOG.debug("writing out shapefile {}", shapeFile);
        ShapefileDataStore outStore = new ShapefileDataStore(shapeFile.toURI().toURL());
        outStore.createSchema(contourSchema);
        SimpleFeatureStore featureStore = (SimpleFeatureStore) outStore.getFeatureSource();
        featureStore.addFeatures(contourFeatures);
        shapeDir.deleteOnExit(); // Note: the order is important
        for (File f : shapeDir.listFiles())
            f.deleteOnExit();
View Full Code Here

        /* Output the staged features to Shapefile */
        final File shapeDir = Files.createTempDir();
        File shapeFile = new File(shapeDir, shpName + ".shp");
        LOG.debug("writing out shapefile {}", shapeFile);
        ShapefileDataStore outStore = new ShapefileDataStore(shapeFile.toURI().toURL());
        outStore.createSchema(contourSchema);
        /* "FeatureSource is used to read features, the subclass FeatureStore is used for
         * read/write access. The way to tell if a File can be written to in GeoTools is to use an
         * instanceof check. */
        SimpleFeatureStore featureStore = (SimpleFeatureStore) outStore.getFeatureSource();
        featureStore.addFeatures(contourFeatures);
View Full Code Here

        ShapefileDataStore ds = (ShapefileDataStore) factory.createNewDataStore(params);

        SimpleFeatureSource fs = shapeDS.getFeatureSource(shapeDS
                .getTypeNames()[0]);

        ds.createSchema(fs.getSchema());
        ds.forceSchemaCRS(fs.getSchema().getCoordinateReferenceSystem());
        FeatureWriter<SimpleFeatureType, SimpleFeature> writer = ds.getFeatureWriter(ds
                .getTypeNames()[0], Transaction.AUTO_COMMIT);

        SimpleFeatureIterator it = fs.getFeatures().features();
View Full Code Here

        ShapefileDataStore newDataStore = (ShapefileDataStore) dataStoreFactory.createNewDataStore(params);

        /*
         * TYPE is used as a template to describe the file contents
         */
        newDataStore.createSchema(TYPE);
       
        // docs break transaction
        /*
         * Write the features to the shapefile
         */
 
View Full Code Here

                    SimpleFeatureTypeBuilder tb = new SimpleFeatureTypeBuilder();
                    tb.setName(filename);
                    GeometryDescriptor gd = sf.getFeatureType().getGeometryDescriptor();
                    tb.add("the_geom", gd.getType().getBinding(), gd.getCoordinateReferenceSystem());
                    SimpleFeatureType sft = tb.buildFeatureType();
                    sds.createSchema(sft);

                    SimpleFeatureBuilder fb = new SimpleFeatureBuilder(sft);
                    fb.add(g);
                    SimpleFeature footprintFeature = fb.buildFeature(null);
                    SimpleFeatureStore fs = (SimpleFeatureStore) sds.getFeatureSource();
View Full Code Here

    File directory = IOUtils.createTempDirectory("sxttmp");
        File file = new File(directory, m_sFilename);

        try {
            ShapefileDataStore dataStore = new ShapefileDataStore(DataUtilities.fileToURL(file));
            dataStore.createSchema(m_FeatureType);
            manager.addResource(new ShapefileResource(dataStore, directory));
           
            return dataStore;
        } catch(Throwable t) {
            LOGGER.log(Level.SEVERE, "Could not create shapefile output ", t);
View Full Code Here

 
    ShapefileDataStore store=null;
    Transaction transaction=null;
    try{
      store = (ShapefileDataStore) dataStoreFactory.createNewDataStore(params);
      store.createSchema(fc.getSchema());
     
      final SimpleFeatureStore featureStore =(SimpleFeatureStore) store.getFeatureSource(fc.getSchema().getName());
      transaction=featureStore.getTransaction();
     
      featureStore.addFeatures(fc);   
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.