Package org.geotools.data

Examples of org.geotools.data.DataStoreFactorySpi


      StringBuilder availableStr = new StringBuilder();
      StringBuilder missingStr = new StringBuilder();
      Iterator<DataStoreFactorySpi> all = DataStoreFinder.getAllDataStores();
      Logger log = LoggerFactory.getLogger(DataStoreFactory.class);
      while (all.hasNext()) {
        DataStoreFactorySpi factory = all.next();
        if (!factory.isAvailable()) {
          log.warn("Datastore factory " + factory.getDisplayName() + "(" + factory.getDescription()
              + ") is not available");
          if (missingStr.length() != 0) {
            missingStr.append(",");
          }
          missingStr.append(factory.getDisplayName());
        } else {
          if (availableStr.length() != 0) {
            availableStr.append(",");
          }
          availableStr.append(factory.getDisplayName());
        }
      }
      throw new IOException(
          "No datastore found. Possible causes are missing factory or missing library for your datastore"
              + " (e.g. database driver).\nCheck the isAvailable() method of your"
View Full Code Here


     * @param params ConnectionParameters
     */
    public IService createService( URL providedId, Map<String, Serializable> params ) {
        Iterator<DataStoreFactorySpi> available = DataStoreFinder.getAvailableDataStores();
        while( available.hasNext() ) {
            DataStoreFactorySpi factory = available.next();
            if (factory.canProcess(params)) {
                ID id = createID(providedId, factory, params);
                if( id == null ){
                    // cannot represent this in our catalog as we have
                    // no idea how to create an "id" for it
                    continue;
View Full Code Here

           
            if ( factoryClassName == null ) {
                throw new RestletException( "Unsupported format: " + format, Status.CLIENT_ERROR_BAD_REQUEST );
            }
           
            DataStoreFactorySpi factory;
            try {
                Class factoryClass = Class.forName( factoryClassName );
                factory = (DataStoreFactorySpi) factoryClass.newInstance();
            }
            catch ( Exception e ) {
View Full Code Here

        params = new HashMap();
        for ( Object o : properties.keySet() ) {
            params.put( o.toString(), properties.get( o ) );
        }
       
        DataStoreFactorySpi factory = null;
        for ( Iterator<DataStoreFactorySpi> i =  DataStoreFinder.getAvailableDataStores(); i.hasNext(); ) {
            DataStoreFactorySpi f = i.next();
            if ( f.canProcess( params ) ) {
                factory = f;
                break;
            }
        }
       
View Full Code Here

    // SPI
    final String SPIClass = properties.getProperty("SPI");
    try {
      // create a datastore as instructed
      final DataStoreFactorySpi spi = (DataStoreFactorySpi) Class.forName(SPIClass).newInstance();
      return createDataStoreParamsFromPropertiesFile(properties, spi);
    } catch (Exception e) {
      final IOException ioe = new IOException();
      throw (IOException) ioe.initCause(e);
    }
View Full Code Here

    public static void dropDatastore(File datastoreProperties) throws IOException {
        final Properties properties = createGranuleCatalogProperties(datastoreProperties);
        final String SPIClass = properties.getProperty("SPI");
        try {
            // drop a datastore. Right now, only postGIS drop is supported
            final DataStoreFactorySpi spi = (DataStoreFactorySpi) Class.forName(SPIClass).newInstance();
            Utils.dropDB(spi, properties);
        } catch (Exception e) {
            final IOException ioe = new IOException();
            throw (IOException) ioe.initCause(e);
        }
View Full Code Here

        Properties properties = createGranuleCatalogProperties(datastoreProperties);
        // SPI
        final String SPIClass = properties.getProperty("SPI");
        try {
            // create a datastore as instructed
            final DataStoreFactorySpi spi = (DataStoreFactorySpi) Class.forName(SPIClass).newInstance();

            // set ParentLocation parameter since for embedded database like H2 we must change the database
            // to incorporate the path where to write the db
            properties.put("ParentLocation", DataUtilities.fileToURL(parent).toExternalForm());
View Full Code Here

        // grab all features
        SimpleFeatureCollection featureCollection = featureSource.getFeatures();

        // And create a new Shapefile with a slight modified schema
        DataStoreFactorySpi factory = new ShapefileDataStoreFactory();
        Map<String, Serializable> create = new HashMap<String, Serializable>();
        create.put("url", file.toURI().toURL());
        create.put("create spatial index", Boolean.TRUE);
        DataStore dataStore = factory.createNewDataStore(create);
        SimpleFeatureType featureType = SimpleFeatureTypeBuilder.retype(schema, worldCRS);
        dataStore.createSchema(featureType);

        // carefully open an iterator and writer to process the results
        Transaction transaction = new DefaultTransaction("Reproject");
View Full Code Here

        query.setCoordinateSystemReproject(map.getCoordinateReferenceSystem());

        SimpleFeatureCollection featureCollection = featureSource.getFeatures(query);

        // And create a new Shapefile with the results
        DataStoreFactorySpi factory = new ShapefileDataStoreFactory();

        Map<String, Serializable> create = new HashMap<String, Serializable>();
        create.put("url", file.toURI().toURL());
        create.put("create spatial index", Boolean.TRUE);
        DataStore newDataStore = factory.createNewDataStore(create);

        newDataStore.createSchema(featureCollection.getSchema());
        Transaction transaction = new DefaultTransaction("Reproject");
        SimpleFeatureStore featureStore;
        featureStore = (SimpleFeatureStore) newDataStore.getFeatureSource(typeName);
View Full Code Here

                }
               
                // SPI
                final String SPIClass=properties.getProperty("SPI");
              // create a datastore as instructed
            final DataStoreFactorySpi spi= (DataStoreFactorySpi) Class.forName(SPIClass).newInstance();
        
            // get the params
            final Map<String, Serializable> params = new HashMap<String, Serializable>()
            final Param[] paramsInfo = spi.getParametersInfo();
            for(Param p:paramsInfo){
              // search for this param and set the value if found
              if(properties.containsKey(p.key))
                params.put(p.key, (Serializable)Converters.convert(properties.getProperty(p.key), p.type));
              else
                if(p.required&& p.sample==null)
                {
                     if (LOGGER.isLoggable(Level.FINE))
                        LOGGER.fine("Required parameter missing: "+p.toString());
                  return false;
                }
            }           
            // H2 workadound
                    if (Utils.isH2Store(spi)) {
                        Utils.fixH2DatabaseLocation(params,
                                DataUtilities.fileToURL(sourceF.getParentFile()).toExternalForm());
                    }
           
            tileIndexStore=spi.createDataStore(params);
              if(tileIndexStore==null)
                return false;
                 
              }
              else {
View Full Code Here

TOP

Related Classes of org.geotools.data.DataStoreFactorySpi

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.