Package org.geotools.data.shapefile

Examples of org.geotools.data.shapefile.ShapefileDataStoreFactory


          if(!outputDirectory.exists())
          {
            outputDirectory.mkdir();
          }
         
      ShapefileDataStoreFactory dataStoreFactory = new ShapefileDataStoreFactory();
     
      Map<String, Serializable> params = new HashMap<String, Serializable>();
      params.put("url", outputShapefile.toURI().toURL());
      params.put("create spatial index", Boolean.TRUE);
     
      ShapefileDataStore dataStore = (ShapefileDataStore)dataStoreFactory.createNewDataStore(params);
      dataStore.forceSchemaCRS(DefaultGeographicCRS.WGS84);

          SimpleFeatureType STOP_TYPE = DataUtilities.createType(
                    "Stop",                
                    "location:Point:srid=4326," +
View Full Code Here


        if( !diffLayer.hasResource(FeatureSource.class) ){
            MessageDialog.openError(display.getActiveShell(), Messages.differenceOp_inputError1, diffLayer.getName()+Messages.differenceOp_inputError2);
            return;
        }
       
        ShapefileDataStoreFactory dsfac = new ShapefileDataStoreFactory();
        File tmp = File.createTempFile(layers[0].getName() + "_" + layers[1].getName() + "_diff", ".shp"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        DataStore ds = dsfac.createDataStore(tmp.toURL());
        final SimpleFeatureType newSchema = FeatureTypes.newFeatureType(
                fromLayer.getSchema().getAttributeDescriptors().toArray(
                        new AttributeDescriptor[0]), "diff"); //$NON-NLS-1$
        ds.createSchema(newSchema);
       
View Full Code Here

            pm.done();
            if (statement != null)
                statement.close();
        }

        ShapefileDataStoreFactory factory = new ShapefileDataStoreFactory();
        Map<String, Serializable> params = new HashMap<String, Serializable>();
        params.put("url", outputShapeFile.toURI().toURL());
        params.put("create spatial index", Boolean.TRUE);
        ShapefileDataStore dStore = (ShapefileDataStore) factory.createNewDataStore(params);
        dStore.createSchema(featureType);
        dStore.forceSchemaCRS(mapCrs);

        JGrassToolsPlugin.getDefault().writeToShapefile(dStore, newCollection);
View Full Code Here

                newCollection.add(feature);
                pm.worked(1);
            }
            pm.done();

            ShapefileDataStoreFactory factory = new ShapefileDataStoreFactory();
            Map<String, Serializable> params = new HashMap<String, Serializable>();
            params.put("url", outputLinesShapeFile.toURI().toURL());
            params.put("create spatial index", Boolean.TRUE);
            ShapefileDataStore dStore = (ShapefileDataStore) factory.createNewDataStore(params);
            dStore.createSchema(featureType);
            dStore.forceSchemaCRS(mapCrs);

            JGrassToolsPlugin.getDefault().writeToShapefile(dStore, newCollection);

            JGrassToolsPlugin.getDefault().addServiceToCatalogAndMap(outputLinesShapeFile.getAbsolutePath(), true, true,
                    new NullProgressMonitor());

        } catch (Exception e1) {
            JGrassToolsPlugin.log(e1.getLocalizedMessage(), e1);
            e1.printStackTrace();
        }
        /*
         * create the points shapefile
         */

        File outputPointsShapeFile = new File(outputFolderFile, "gpspoints.shp");

        b = new SimpleFeatureTypeBuilder();
        b.setName("geopaparazzinotes");
        b.setCRS(mapCrs);
        b.add("the_geom", Point.class);
        b.add("ALTIMETRY", String.class);
        b.add("DATE", String.class);
        featureType = b.buildFeatureType();

        try {
            MathTransform transform = CRS.findMathTransform(DefaultGeographicCRS.WGS84, mapCrs);

            pm.beginTask("Import gps to points...", logsList.size());
            DefaultFeatureCollection newCollection = new DefaultFeatureCollection();
            int index = 0;
            for( GpsLog log : logsList ) {
                List<GpsPoint> gpsPointList = log.points;
                for( GpsPoint gpsPoint : gpsPointList ) {
                    Coordinate c = new Coordinate(gpsPoint.lon, gpsPoint.lat);
                    Point point = gF.createPoint(c);

                    Point reprojectPoint = (Point) JTS.transform(point, transform);
                    Object[] values = new Object[]{reprojectPoint, String.valueOf(gpsPoint.altim), gpsPoint.utctime};

                    SimpleFeatureBuilder builder = new SimpleFeatureBuilder(featureType);
                    builder.addAll(values);
                    SimpleFeature feature = builder.buildFeature(featureType.getTypeName() + "." + index++);
                    newCollection.add(feature);
                }
                pm.worked(1);
            }
            pm.done();

            ShapefileDataStoreFactory factory = new ShapefileDataStoreFactory();
            Map<String, Serializable> params = new HashMap<String, Serializable>();
            params.put("url", outputPointsShapeFile.toURI().toURL());
            params.put("create spatial index", Boolean.TRUE);
            ShapefileDataStore dStore = (ShapefileDataStore) factory.createNewDataStore(params);
            dStore.createSchema(featureType);
            dStore.forceSchemaCRS(mapCrs);

            JGrassToolsPlugin.getDefault().writeToShapefile(dStore, newCollection);

View Full Code Here

                    newCollection.add(feature);
                }
                pm.worked(1);
            }

            ShapefileDataStoreFactory factory = new ShapefileDataStoreFactory();
            Map<String, Serializable> params = new HashMap<String, Serializable>();
            params.put("url", outputPointsShapeFile.toURI().toURL());
            params.put("create spatial index", Boolean.TRUE);
            ShapefileDataStore dStore = (ShapefileDataStore) factory.createNewDataStore(params);
            dStore.createSchema(featureType);
            dStore.forceSchemaCRS(mapCrs);

            JGrassToolsPlugin.getDefault().writeToShapefile(dStore, newCollection);
View Full Code Here

            s = s.substring(0, lastIndexOf == -1 ? s.length() : lastIndexOf + 1);
            lastIndexOf = s.lastIndexOf(File.separator);
            s = s.substring(0, lastIndexOf == -1 ? s.length() : lastIndexOf + 1);
            file = new File(s + type.getName().getLocalPart() + ".shp"); //$NON-NLS-1$
        }
        ShapefileDataStoreFactory factory = new ShapefileDataStoreFactory();
        Map<String, Serializable> params = new HashMap<String, Serializable>();
        params.put(ShapefileDataStoreFactory.URLP.key, file.toURI().toURL());
        params.put(ShapefileDataStoreFactory.CREATE_SPATIAL_INDEX.key, true);
       
        DataStore ds = factory.createDataStore(params);
        ds.createSchema(type);
        List<IService> service = CatalogPlugin.getDefault().getServiceFactory().createService(
                file.toURI().toURL());
        for( IService service2 : service ) {
            try {
View Full Code Here

        if (!canWrite(file)) {
            throw new IOException(MessageFormat.format(Messages.CatalogExport_cannotWrite,
                    file.getAbsolutePath()));
        }
        // creates the shapefile
        ShapefileDataStoreFactory dataStoreFactory = new ShapefileDataStoreFactory();
        Map<String, Serializable> params = new HashMap<String, Serializable>();
        params.put("url", URLUtils.fileToURL(file)); //$NON-NLS-1$
        params.put("create spatial index", Boolean.TRUE); //$NON-NLS-1$
        ShapefileDataStore ds = (ShapefileDataStore) dataStoreFactory.createDataStore(params);
        ds.createSchema(type);
       
        SimpleFeatureStore featureSource = (SimpleFeatureStore) ds.getFeatureSource();
        List<FeatureId> ids = featureSource.addFeatures(fc);
        return ids.size() >= 0;
View Full Code Here

    if (file.exists()){
        return;
    }
   
    // create and write the new shapefile   
    ShapefileDataStoreFactory factory = new ShapefileDataStoreFactory();
    Map params = new HashMap();
    params.put( "url", file.toURL() );
    ShapefileDataStore dataStore =
        (ShapefileDataStore) factory.createNewDataStore( params );   
    dataStore.createSchema( featureType );
   
    FeatureStore store = (FeatureStore) dataStore.getFeatureSource();
    store.addFeatures( source.getFeatures() );
    dataStore.forceSchemaCRS( crs );
View Full Code Here

    private static final String OLD_URLP_KEY = "shapefile url"; //$NON-NLS-1$
    private static ShapefileDataStoreFactory shpDSFactory;

    public static ShapefileDataStoreFactory getSHPDSFactory(){
        if(shpDSFactory == null)
            shpDSFactory = new ShapefileDataStoreFactory();
        return shpDSFactory;
    }
View Full Code Here

        return shpURL; // clean!
    }

    @Override
    protected String doOtherChecks( Map<String, Serializable> params ) {
        ShapefileDataStoreFactory factory = getSHPDSFactory();
        if( !factory.canProcess(params) ) {
            // this is tough we don't have a good error message out of the geotools factory canProcess method
            // So we will try (and fail!) to connect ...
            DataStore datastore = null;
            try {
                datastore = factory.createDataStore(params);
            }
            catch (Throwable t){
                return t.getLocalizedMessage(); // We cannot connect because of this ...
            }
            finally {
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.