Package org.geotools.data.shapefile

Examples of org.geotools.data.shapefile.ShapefileDataStoreFactory


    ShapefileDataStore getDS( IProgressMonitor monitor ) throws IOException {
        if (ds == null) {
            dsInstantiationLock.lock();
            try {
                if (ds == null) {
                    ShapefileDataStoreFactory dsf = new ShapefileDataStoreFactory();
                    if (dsf.canProcess(params)) {

                        try {
                            ds = (ShapefileDataStore) dsf.createDataStore(params);
                            // openIndexGenerationDialog(ds);
                            // hit it lightly to make sure it exists.
                            ds.getFeatureSource();

                        } catch (IOException e) {
                            msg = e;
                            try {
                                params.remove(ShapefileDataStoreFactory.CREATE_SPATIAL_INDEX.key);
                                ds = (ShapefileDataStore) dsf.createDataStore(params);
                                // hit it lightly to make sure it exists.
                                ds.getFeatureSource();

                            } catch (Exception e2) {
                                msg = e2;
View Full Code Here


   
    try {
      /*
       * Get an output file name and create the new shapefile
       */
      ShapefileDataStoreFactory dataStoreFactory = new ShapefileDataStoreFactory();

      Map<String, Serializable> params = new HashMap<String, Serializable>();
      params.put("url", outputFile.toURI().toURL());
      params.put("create spatial index", Boolean.TRUE);

      ShapefileDataStore newDataStore = (ShapefileDataStore) dataStoreFactory
          .createNewDataStore(params);
      newDataStore.setStringCharset(Charset.forName("UTF-8"));
      newDataStore.createSchema(features.get(0).getFeatureType());

      /*
 
View Full Code Here

        String commitOld = args.get(0);
        String commitNew = args.get(1);
        String path = args.get(2);
        String shapefile = args.get(3);

        ShapefileDataStoreFactory dataStoreFactory = new ShapefileDataStoreFactory();

        File file = new File(shapefile);
        if (file.exists() && !overwrite) {
            throw new CommandFailedException(
                    "The selected shapefile already exists. Use -o to overwrite");
        }

        Map<String, Serializable> params = new HashMap<String, Serializable>();
        params.put(ShapefileDataStoreFactory.URLP.key, file.toURI().toURL());
        params.put(ShapefileDataStoreFactory.CREATE_SPATIAL_INDEX.key, Boolean.FALSE);
        params.put(ShapefileDataStoreFactory.ENABLE_SPATIAL_INDEX.key, Boolean.FALSE);

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

        SimpleFeatureType outputFeatureType;
        try {
            outputFeatureType = getFeatureType(path, cli);
View Full Code Here

        };

        SimpleFeatureType outputFeatureType = rule.getFeatureType();
        String path = getOriginTreesFromOutputFeatureType(outputFeatureType);

        ShapefileDataStoreFactory dataStoreFactory = new ShapefileDataStoreFactory();
        Map<String, Serializable> params = new HashMap<String, Serializable>();
        params.put(ShapefileDataStoreFactory.URLP.key, shapeFile.toURI().toURL());
        params.put(ShapefileDataStoreFactory.CREATE_SPATIAL_INDEX.key, Boolean.TRUE);

        DataStore dataStore = dataStoreFactory.createNewDataStore(params);
        try {
            dataStore.createSchema(outputFeatureType);

            final String typeName = dataStore.getTypeNames()[0];
            final SimpleFeatureSource source = dataStore.getFeatureSource(typeName);
View Full Code Here

        }

        String path = args.get(0);
        String shapefile = args.get(1);

        ShapefileDataStoreFactory dataStoreFactory = new ShapefileDataStoreFactory();

        File targetShapefile = new File(shapefile);
        if (!targetShapefile.isAbsolute()) {
            File pwd = cli.getGeogig().getPlatform().pwd();
            String relativePath = targetShapefile.getPath();
            targetShapefile = new File(pwd, relativePath);
        }
        if (targetShapefile.exists() && !overwrite) {
            throw new CommandFailedException(
                    "The selected shapefile already exists. Use -o to overwrite");
        }

        Map<String, Serializable> params = new HashMap<String, Serializable>();
        URL targetShapefileAsUrl = targetShapefile.toURI().toURL();
        params.put(ShapefileDataStoreFactory.URLP.key, targetShapefileAsUrl);
        params.put(ShapefileDataStoreFactory.CREATE_SPATIAL_INDEX.key, Boolean.FALSE);
        params.put(ShapefileDataStoreFactory.ENABLE_SPATIAL_INDEX.key, Boolean.FALSE);

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

        SimpleFeatureType outputFeatureType;
        ObjectId featureTypeId;
        if (sFeatureTypeId != null) {
View Full Code Here

       
        File shpFile = new File("./target/screenMapTest/"
                + feature.getFeatureType().getName().getLocalPart() + ".shp");
        shpFile.getParentFile().mkdirs();

        ShapefileDataStoreFactory dataStoreFactory = new ShapefileDataStoreFactory();
        Map<String, Serializable> params = new HashMap<String, Serializable>();
        params.put(ShapefileDataStoreFactory.URLP.key, shpFile.toURI().toURL());
        shapeFileDataStore = dataStoreFactory.createNewDataStore(params);
        shapeFileDataStore.createSchema(feature.getFeatureType());
        SimpleFeatureStore featureStore = (SimpleFeatureStore) shapeFileDataStore
                .getFeatureSource(shapeFileDataStore.getTypeNames()[0]);
        featureStore.addFeatures(DataUtilities.collection(feature));
View Full Code Here

    protected void generalizeShapeFile(String shapeFileName, String targetDirName,
            String generalizations) throws IOException {
        File shapeFile = new File(shapeFileName);
        if (shapeFile.exists() == false)
            throw new IOException("Could not find " + shapeFileName);
        DataStore shapeDS = new ShapefileDataStoreFactory().createDataStore(shapeFile.toURI()
                .toURL());

        File targetDir = new File(targetDirName);
        if (targetDir.exists() == false)
            throw new IOException("Could not find " + targetDir);
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

            POINTMAP.put(20.0, new HashMap<String, Integer>());
            POINTMAP.put(50.0, new HashMap<String, Integer>());

            URL url = TestData.url("shapes/streams.shp");

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

            String typeName = ds.getSchema().getTypeName();
            REPOSITORY.register("dsStreams", ds);
View Full Code Here

        out.close();
        // ////////

        url = TestData.url("shapes/streams.shp");

        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

TOP

Related Classes of org.geotools.data.shapefile.ShapefileDataStoreFactory

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.