Examples of GranuleCatalog


Examples of org.geotools.gce.imagemosaic.catalog.GranuleCatalog

        //
        // create the index
        //
        // do we have a datastore.properties file?
        final File parent = new File(runConfiguration.getParameter(Prop.ROOT_MOSAIC_DIR));
        GranuleCatalog catalog;
       
        // Consider checking that from the indexer if any
        final File datastoreProperties = new File(parent, "datastore.properties");
        // GranuleCatalog catalog = null;
        if (Utils.checkFileReadable(datastoreProperties)) {
            // read the properties file
            catalog = createGranuleCatalogFromDatastore(parent, datastoreProperties, create,runConfiguration.getHints());
        } else {

            // we do not have a datastore properties file therefore we continue with a shapefile datastore
            final URL file = new File(parent, runConfiguration.getParameter(Utils.Prop.INDEX_NAME) + ".shp").toURI().toURL();
            final Properties params = new Properties();
            params.put(ShapefileDataStoreFactory.URLP.key, file);
            if (file.getProtocol().equalsIgnoreCase("file")) {
                params.put(ShapefileDataStoreFactory.CREATE_SPATIAL_INDEX.key, Boolean.TRUE);
            }
            params.put(ShapefileDataStoreFactory.MEMORY_MAPPED.key, USE_MEMORY_MAPPED_BUFFERS);
            params.put(ShapefileDataStoreFactory.DBFTIMEZONE.key, TimeZone.getTimeZone("UTC"));
            params.put(Utils.Prop.LOCATION_ATTRIBUTE, runConfiguration.getParameter(Utils.Prop.LOCATION_ATTRIBUTE));
            catalog = GranuleCatalogFactory.createGranuleCatalog(params, false, create, Utils.SHAPE_SPI,runConfiguration.getHints());
            MultiLevelROIProvider roi = MultiLevelROIProviderFactory.createFootprintProvider(parent);
            catalog.setMultiScaleROIProvider(roi);
        }

        return catalog;
    }
View Full Code Here

Examples of org.geotools.gce.imagemosaic.catalog.GranuleCatalog

     * @param hints
     * @return
     * @throws IOException
     */
    public static GranuleCatalog createGranuleCatalogFromDatastore(File parent, File datastoreProperties, boolean create, Hints hints) throws IOException {
        GranuleCatalog catalog = null;
        Utilities.ensureNonNull("datastoreProperties", datastoreProperties);
        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());

            catalog = GranuleCatalogFactory.createGranuleCatalog(properties, false, create, spi,hints);
            MultiLevelROIProvider rois = MultiLevelROIProviderFactory.createFootprintProvider(parent);
            catalog.setMultiScaleROIProvider(rois);
        } catch (Exception e) {
            final IOException ioe = new IOException();
            throw (IOException) ioe.initCause(e);
        }
        return catalog;
View Full Code Here

Examples of org.geotools.gce.imagemosaic.catalog.GranuleCatalog

            if (!catalogBean.getLocationAttribute().equalsIgnoreCase(hintLocation)) {
                throw new DataSourceException("wrong location attribute");
            }
        }
        // Create the catalog
        GranuleCatalog catalog = GranuleCatalogFactory.createGranuleCatalog(sourceURL, catalogBean, null,hints);
        File parent = DataUtilities.urlToFile(sourceURL).getParentFile();
        MultiLevelROIProvider rois = MultiLevelROIProviderFactory.createFootprintProvider(parent);
        catalog.setMultiScaleROIProvider(rois);
       
        return catalog;
    }
View Full Code Here

Examples of org.geotools.gce.imagemosaic.catalog.GranuleCatalog

            configHandler.indexingPreamble();
            startTransaction();

            // start looking into catalog
            final GranuleCatalog catalog = configHandler.getCatalog();
            for (String typeName : catalog.getTypeNames()) {

                // how many rows for this feature type?
                final Query query = new Query(typeName);
                int numFiles = catalog.getGranulesCount(query);
                if (numFiles <= 0) {
                    // empty table?
                    LOGGER.log(Level.FINE, "No rows in the typeName: " + typeName);
                    continue;
                }
                setNumFiles(numFiles);

                // cool, now let's walk over the features
                final SimpleFeatureCollection coll = catalog.getGranules(query);
                // create an iterator
                it = coll.features();
                // TODO setup index name

                while (it.hasNext()) {
View Full Code Here

Examples of org.geotools.gce.imagemosaic.catalog.GranuleCatalog

        final MosaicConfigurationBean configuration = source.getConfiguration();
        if (configuration == null) {
            throw new DataSourceException("Unable to create reader for this mosaic since we could not parse the configuration.");
        }
        extractProperties(configuration);
        GranuleCatalog catalog = source.getCatalog();
        if (catalog == null) {
            throw new DataSourceException("Unable to create reader for this mosaic since the inner catalog is null.");
        }

        final SimpleFeatureType schema = catalog.getType(configuration.getCatalogConfigurationBean().getTypeName());
        if (schema == null) {
            throw new DataSourceException("Unable to create reader for this mosaic since the inner catalog schema is null.");
        }
       
        granuleCatalog = catalog;
View Full Code Here

Examples of org.geotools.gce.imagemosaic.catalog.GranuleCatalog

                if (beans.isEmpty() && !datastoreProperties.exists()) {
                    throw new DataSourceException("No mosaic properties file or datastore properties file have been found");
                }
               
                // Catalog initialization from datastore
                GranuleCatalog catalog = null;
                final Properties params = CatalogManager.createGranuleCatalogProperties(datastoreProperties);

                // Since we are dealing with a catalog from an existing store, make sure to scan for all the typeNames on initialization
                final Object typeNames=params.get(Utils.SCAN_FOR_TYPENAMES);
                if (typeNames!=null){
                    params.put(Utils.SCAN_FOR_TYPENAMES, Boolean.valueOf(typeNames.toString()));
                } else {
                    params.put(Utils.SCAN_FOR_TYPENAMES, Boolean.TRUE);
                }
                if (beans.size() > 0) {
                    catalog = GranuleCatalogFactory.createGranuleCatalog(sourceURL, beans.get(0).getCatalogConfigurationBean(), params, getHints());
                } else {
                    catalog = CatalogManager.createGranuleCatalogFromDatastore(parent, datastoreProperties, true, getHints());
                }
                MultiLevelROIProvider rois = MultiLevelROIProviderFactory.createFootprintProvider(parent);
                catalog.setMultiScaleROIProvider(rois);
                if (granuleCatalog != null) {
                    granuleCatalog.dispose();
                }
                granuleCatalog = catalog;
View Full Code Here

Examples of org.geotools.gce.imagemosaic.catalog.GranuleCatalog

     * @param source
     * @return
     */
    private static boolean checkDescriptor(final ImageMosaicDescriptor source) {
        //TODO: improve checks
        final GranuleCatalog catalog = source.getCatalog();
        final MosaicConfigurationBean configuration = source.getConfiguration();
        if (configuration == null) {
            if (LOGGER.isLoggable(Level.FINE)) {
                LOGGER.fine("Mosaic configuration is missing");
            }
View Full Code Here

Examples of org.geotools.gce.imagemosaic.catalog.GranuleCatalog

     
 
      assertTrue(new ImageMosaicFormat().accepts(relativeMosaic));
      reader = (ImageMosaicReader) new ImageMosaicReader(relativeMosaic);
     
      GranuleCatalog catalog = reader.getRasterManager(reader.defaultName).granuleCatalog;
      assertTrue(catalog.getClass().toString().endsWith("GTDataStoreGranuleCatalog"));
    } finally {
        if (inStream != null){
                        IOUtils.closeQuietly(inStream);
                    }
     
      try {
        if (reader != null){
          reader.dispose();
        }
      } catch (Throwable t){
        //Eat exception
      }
    }
   
    try {
     
//      c1.setCaching(true);
      c1.setParameter(Prop.CACHING, "true");

                ImageMosaicEventHandlers eventHandler = new ImageMosaicEventHandlers();
                final ImageMosaicConfigHandler catalogHandler = new ImageMosaicConfigHandler(c1,
                        eventHandler);
                // TODO
                // build the index
                builder = new ImageMosaicDirectoryWalker(catalogHandler, eventHandler);
                eventHandler.addProcessingEventListener(new CatalogBuilderListener());
      builder.run();
      final File relativeMosaic = TestData.file(this, "/caching/" + c1.getIndexName() + ".shp");
      final File propertiesFile = TestData.file(this, "/caching/" + c1.getIndexName() + ".properties");
      inStream = new FileInputStream(propertiesFile);
      prop.load(inStream);
     
      String value = prop.getProperty("Caching");
      assertNotNull(value);
      assertTrue (value.toLowerCase().equals("true"));
     
      assertTrue(relativeMosaic.exists());
 
      assertTrue(new ImageMosaicFormat().accepts(relativeMosaic));
      reader = (ImageMosaicReader) new ImageMosaicReader(relativeMosaic);
     
      GranuleCatalog catalog = reader.getRasterManager(reader.defaultName).granuleCatalog;
      assertTrue(catalog.getClass().toString().endsWith("STRTreeGranuleCatalog"));

    } finally {
                    if (inStream != null){
                        IOUtils.closeQuietly(inStream);
                    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.