Package org.geotools.data.directory

Examples of org.geotools.data.directory.DirectoryDataStore


        }
       
        // are we creating a directory of shapefiles store, or a single one?
        File dir = DataUtilities.urlToFile(url);
        if (dir != null && dir.isDirectory()) {
            return new DirectoryDataStore(DataUtilities.urlToFile(url), new ShpFileStoreFactory(
                    this, params));
        } else {
            ShpFiles shpFiles = new ShpFiles(url);

            boolean isLocal = shpFiles.isLocal();
View Full Code Here


    // until we get rid of the latter let's be a little lax on this one...
    public void testFeatureSource() throws Exception {
        File file = copyShapefiles("shapes/archsites.shp");
        tempDir = file.getParentFile();
       
        DataStore dds = new DirectoryDataStore(tempDir, getFileStoreFactory());
        FeatureSource fs = dds.getFeatureSource("archsites");
        assertNotNull(fs);
        assertSame(dds, fs.getDataStore());
        dds.dispose();
    }
View Full Code Here

    public void testCreateSchema() throws Exception {
        File dir = File.createTempFile("foo", "shp", new File("target"));
        dir.delete();
        dir.mkdir();
       
        DataStore ds = new DirectoryDataStore(dir, getFileStoreFactory());
        assertEquals(0, ds.getTypeNames().length);
       
        SimpleFeatureTypeBuilder tb = new SimpleFeatureTypeBuilder();
        tb.setName("foo");
        tb.add("geom", Polygon.class);
        tb.add("bar", Integer.class);
        ds.createSchema(tb.buildFeatureType());
       
        SimpleFeatureType ft = ds.getSchema("foo");
        assertNotNull(ft);
       
        //clean up
        ds.dispose();
        for (File f : dir.listFiles()) {
            f.delete();
        }
        dir.delete();
    }
View Full Code Here

        Map params = new HashMap();
        params.put(ShapefileDataStoreFactory.URLP.key, DataUtilities.fileToURL(tempDir));
        DataStore store = DataStoreFinder.getDataStore(params);
       
        assertNotNull(store);
        DirectoryDataStore dds = (DirectoryDataStore) store;
        List<String> typeNames = Arrays.asList(dds.getTypeNames());
        assertEquals(2, typeNames.size());
        assertTrue(typeNames.contains("archsites"));
        assertTrue(typeNames.contains("bugsites"));
        dds.dispose();
    }
View Full Code Here

        params.put(ShapefileDataStoreFactory.URLP.key, DataUtilities.fileToURL(tempDir));
        params.put(ShapefileDataStoreFactory.FILE_TYPE.key, "shapefile");
        DataStore store = DataStoreFinder.getDataStore(params);
       
        assertNotNull(store);
        DirectoryDataStore dds = (DirectoryDataStore) store;
        List<String> typeNames = Arrays.asList(dds.getTypeNames());
        assertEquals(2, typeNames.size());
        assertTrue(typeNames.contains("archsites"));
        assertTrue(typeNames.contains("bugsites"));
        dds.dispose();
    }
View Full Code Here

    public void testTypeNames() throws Exception {
        copyShapefiles("shapes/archsites.shp");
        File f = copyShapefiles("shapes/bugsites.shp");
        tempDir = f.getParentFile();
       
        DataStore store = new DirectoryDataStore(tempDir, getFileStoreFactory());
        List<String> typeNames = Arrays.asList(store.getTypeNames());
        assertEquals(2, typeNames.size());
        assertTrue(typeNames.contains("archsites"));
        assertTrue(typeNames.contains("bugsites"));
        store.dispose();
    }
View Full Code Here

    @Test
    public void testSchema() throws Exception {
        File file = copyShapefiles("shapes/archsites.shp");
        tempDir = file.getParentFile();
       
        DataStore dds = new DirectoryDataStore(tempDir, getFileStoreFactory());
      
        assertEquals(1, dds.getTypeNames().length);
        assertEquals("archsites", dds.getTypeNames()[0]);
        dds.dispose();
    }
View Full Code Here

            IOUtils.closeQuietly(ifos);
        }

        //create a new shapefile feature store
        ShapefileDataStoreFactory shpFactory = new ShapefileDataStoreFactory();
        DirectoryDataStore dir = new DirectoryDataStore(mosaic.getFile(),
            new ShapefileDataStoreFactory.ShpFileStoreFactory(shpFactory, new HashMap()));

        try {
           dir.createSchema(typeBuilder.buildFeatureType());

           FeatureWriter<SimpleFeatureType, SimpleFeature> w =
                   dir.getFeatureWriterAppend(mosaic.getName(), Transaction.AUTO_COMMIT);

           try {
               for (Granule g : mosaic.granules()) {
                   if (g.getEnvelope() == null) {
                       LOGGER.warning("Skipping " + g.getFile().getAbsolutePath() + ", no envelope");
                   }
   
                   SimpleFeature f = w.next();
                   f.setDefaultGeometry(JTS.toGeometry((BoundingBox)g.getEnvelope()));
                   f.setAttribute("location", g.getFile().getName());
                   if (mosaic.getTimeMode() != TimeMode.NONE) {
                       f.setAttribute("time", g.getTimestamp());
                   }
                   w.write();

                   //track total bounds
                   envelope.include(g.getEnvelope());
               }

           }
           finally {
               w.close();
           }
        }
        finally {
            dir.dispose();
        }

        // have the image mosaic write the property file
        ImageMosaicFormat format = new ImageMosaicFormat();
        ImageMosaicReader reader = format.getReader(mosaic.getFile());
View Full Code Here

TOP

Related Classes of org.geotools.data.directory.DirectoryDataStore

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.