Package org.geotools.data

Examples of org.geotools.data.FileDataStoreFactorySpi


     * @return true if we could try using the url with the factory
     */
    public static boolean consider( DataAccessFactory factory, URL url ) {
        // is this specifically the kind of thing that can take a url?
        if (factory instanceof FileDataStoreFactorySpi) {
            FileDataStoreFactorySpi fileFactory = (FileDataStoreFactorySpi) factory;
            return fileFactory.canProcess(url);
        }
        // Go through the params and see if a URL can even be used?
        // (It should be a required parameter that accepts a URL
        for( Param param : factory.getParametersInfo() ) {
            if (param.required) {
View Full Code Here


    }

    DataStore[] createDataStores(File shapeFile, File targetDir, SimpleFeatureType ft,
            Double[] distanceArray) throws IOException {

        FileDataStoreFactorySpi factory = new ShapefileDataStoreFactory();
        String shapeFileName = shapeFile.getAbsolutePath();

        String newShapeFileRelativeName = null;
        int index = shapeFileName.lastIndexOf(File.separator);
        if (index == -1)
            newShapeFileRelativeName = shapeFileName;
        else
            newShapeFileRelativeName = shapeFileName.substring(index + 1);

        DataStore[] result = new DataStore[distanceArray.length];

        for (int i = 0; i < distanceArray.length; i++) {

            String newShapeFileDirName = targetDir.getAbsolutePath();
            if (newShapeFileDirName.endsWith(File.separator) == false)
                newShapeFileDirName += File.separator;
            newShapeFileDirName += distanceArray[i] + File.separator;

            File dir = new File(newShapeFileDirName);
            if (dir.exists() == false)
                dir.mkdir();

            File file = new File(newShapeFileDirName + newShapeFileRelativeName);

            Map<String, Serializable> params = new HashMap<String, Serializable>();
            params.put(ShapefileDataStoreFactory.URLP.key, file.toURI().toURL());
            result[i] = factory.createNewDataStore(params);
            result[i].createSchema(ft);
            ((ShapefileDataStore) result[i]).forceSchemaCRS(ft.getCoordinateReferenceSystem());
        }
        return result;
    }
View Full Code Here

        ShapefileDataStore shapeDS = (ShapefileDataStore) new ShapefileDataStoreFactory()
                .createDataStore(url);

        Map<String, Serializable> params = new HashMap<String, Serializable>();
        FileDataStoreFactorySpi factory = new ShapefileDataStoreFactory();
        params.put(ShapefileDataStoreFactory.URLP.key, new File("target/0/streams.shp").toURI()
                .toURL());
        ShapefileDataStore ds = (ShapefileDataStore) factory.createNewDataStore(params);

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

        ds.createSchema(fs.getSchema());
View Full Code Here

            String ext = extension.toLowerCase().trim();
            if (!ext.startsWith(".")) {
                ext = "." + ext;
            }

            FileDataStoreFactorySpi factory = FileDataStoreFinder.getDataStoreFactory(ext);
            if (factory != null) {
                fileAssociations.put(ext, factory.getDescription());

            } else {
                // guess some common ones
                if (".csv".equals(ext)) {
                    fileAssociations.put(ext, "Comma-delimited files (*.csv)");
 
View Full Code Here

                } else {
                    ext = "*." + ext;
                }
            }

            FileDataStoreFactorySpi factory = FileDataStoreFinder.getDataStoreFactory(ext);
            if (factory != null) {
                fileAssociations.put(ext, factory.getDescription());

            } else {
                // guess some common ones
                if (".csv".equals(ext)) {
                    fileAssociations.put(ext, "Comma-delimited files (*.csv)");
 
View Full Code Here

            }
        }

        //look for a datastore that can handle the file
        String ext = FilenameUtils.getExtension(file.getName());
        FileDataStoreFactorySpi factory = FileDataStoreFinder.getDataStoreFactory(ext);
        if (factory != null) {
            return new DataStoreFormat(factory);
        }

        //look for a gridformat that can handle the file
View Full Code Here

        // if not, let's see if we have a file data store factory that knows about the extension
        String extension = "." + format;
        for (DataAccessFactory dataAccessFactory : DataStoreUtils.getAvailableDataStoreFactories()) {
            if (dataAccessFactory instanceof FileDataStoreFactorySpi) {
                FileDataStoreFactorySpi factory = (FileDataStoreFactorySpi) dataAccessFactory;
                for (String handledExtension : factory.getFileExtensions()) {
                    if (extension.equalsIgnoreCase(handledExtension)) {
                        return factory;
                    }
                }
            }
View Full Code Here

    @Test
    public void testLookupDataStoreFactory() {
        Object bean = applicationContext.getBean("testDataAccessFactoryProvider");
        TestDataAccessFactoryProvider factoryProvider = (TestDataAccessFactoryProvider) bean;

        FileDataStoreFactorySpi dataAccessFactory = EasyMock
                .createMock(FileDataStoreFactorySpi.class);
        expect(dataAccessFactory.getFileExtensions()).andReturn(new String[] { ".CUSTOM" }).anyTimes();
        replay(dataAccessFactory);

        factoryProvider.setDataStoreFactories(Collections.singletonList(dataAccessFactory));

        DataAccessFactory factory = DataStoreFileResource.lookupDataStoreFactory("custom");
View Full Code Here

TOP

Related Classes of org.geotools.data.FileDataStoreFactorySpi

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.