Package org.geotools.coverage.grid.io

Examples of org.geotools.coverage.grid.io.StructuredGridCoverage2DReader


     * @throws TransformException
     * @throws FactoryException
     */
    public List<GridCoverageRequest> splitRequest()
            throws UnsupportedOperationException, IOException, MismatchedDimensionException, TransformException, FactoryException {
        StructuredGridCoverage2DReader structuredReader = null;
        if (reader instanceof StructuredGridCoverage2DReader) {
            structuredReader = (StructuredGridCoverage2DReader) reader;
        } else {
            throw new IllegalArgumentException("The method is only supported for StructuredGridCoverage2DReaders");
        }

        // Getting the granule source
        final String coverageName = getCoverageName();
       
        final GranuleSource source = structuredReader.getGranules(coverageName, true);
        if (source == null) {
            throw new IllegalArgumentException("No granule source available for that coverageName");
        }

        // Preparing a query containing all the specified dimensions.
View Full Code Here


     * Prepare the DimensionBean list for this reader
     * @return
     * @throws IOException
     */
    public List<DimensionBean> setupDimensions() throws IOException {
        StructuredGridCoverage2DReader structuredReader = null;
        if (reader instanceof StructuredGridCoverage2DReader) {
            structuredReader = (StructuredGridCoverage2DReader) reader;
        } else {
            // TODO: only structuredGridCoverage2DReaders are currently supported.
            throw new UnsupportedOperationException("Only structuredGridCoverage2DReaders are currently supported");
View Full Code Here

    }

    @Override
    protected Object handleObjectGet() throws Exception {
        String nativeCoverageName = coverage.getNativeCoverageName();
        StructuredGridCoverage2DReader reader = (StructuredGridCoverage2DReader) coverage.getGridCoverageReader(null, null);
        if(nativeCoverageName == null) {
            if(reader.getGridCoverageNames().length > 1) {
                throw new IllegalStateException("The grid coverage configuration for " + coverage.getName()
                        + " does not specify a native coverage name, yet the reader provides more than one coverage. " +
                        "Please assign a native coverage name (the GUI does so automatically)");
            } else {
                nativeCoverageName = reader.getGridCoverageNames()[0];
            }
        }
       
        GranuleSource source = reader.getGranules(nativeCoverageName, true);
        SimpleFeatureType schema = source.getSchema();
        List<AttributeTypeInfo> attributes = new CatalogBuilder(catalog).getAttributes(schema, null);
       
        return new IndexSchema(attributes);
    }
View Full Code Here

    }
   
    @Override
    public boolean allowDelete() {
        try {
            StructuredGridCoverage2DReader reader = (StructuredGridCoverage2DReader) coverage
                    .getGridCoverageReader(null, null);
            return !reader.isReadOnly();
        } catch(IOException e) {
            throw new RestletException("Failed to determine if the reader index can be written to",
                    Status.SERVER_ERROR_INTERNAL, e);
        }
    }
View Full Code Here

        }
    }
   
    @Override
    protected void handleObjectDelete() throws Exception {
        StructuredGridCoverage2DReader reader = (StructuredGridCoverage2DReader) coverage
                .getGridCoverageReader(null, null);
        String nativeCoverageName = getNativeCoverageName(reader);

        // setup deletion filter
        Query q = getResourceQuery();
       
        // perform the delete
        GranuleStore store = (GranuleStore) reader.getGranules(nativeCoverageName, false);
        int removed = store.removeGranules(q.getFilter());
        if(LOGGER.isLoggable(Level.FINE)) {
            LOGGER.fine("Removed " + removed + " granules from the reader granule store");
        }
    }
View Full Code Here

     */
    protected abstract Query getResourceQuery();

    @Override
    protected Object handleObjectGet() throws Exception {
        StructuredGridCoverage2DReader reader = (StructuredGridCoverage2DReader) coverage
                .getGridCoverageReader(null, null);
        String nativeCoverageName = getNativeCoverageName(reader);

        GranuleSource source = reader.getGranules(nativeCoverageName, true);
        Query q = getResourceQuery();
        return forceNonNullNamespace(source.getGranules(q));
    }
View Full Code Here

                try {
                    EoCatalogBuilder builder = new EoCatalogBuilder(getCatalog());
                    CoverageInfo coverage = (CoverageInfo) ((LayerInfo) entry.getLayer()).getResource();
                    CoverageStoreInfo store = coverage.getStore();
                    String url = store.getURL();
                    StructuredGridCoverage2DReader reader = (StructuredGridCoverage2DReader) coverage.getGridCoverageReader(null, null);
                    LayerInfo layer = builder.createEoOutlineLayer(url, ws, groupName, coverage.getNativeCoverageName(), reader);
                    lgEntryPanel.items.add(new EoLayerGroupEntry(layer, layer.getDefaultStyle(), groupName));
                } catch(Exception e) {
                    LOGGER.log(Level.SEVERE, "Failed to create outlines layer", e);
                    String layerName = entry.getLayer().prefixedName();
View Full Code Here

        getCatalog().add(store);
        builder.setStore(store);
        // Input reader used for reading the mosaic folder
        GridCoverage2DReader reader = null;
        // Reader used for checking if the mosaic has been configured correctly
        StructuredGridCoverage2DReader reader2 = null;

        try {
            // Selection of the reader to use for the mosaic
            reader = (GridCoverage2DReader) imageMosaicFormat.getReader(DataUtilities
                    .fileToURL(mosaic));

            // configure the coverage
            configureCoverageInfo(builder, store, reader);

            // check the coverage is actually there
            CoverageStoreInfo storeInfo = getCatalog().getCoverageStoreByName("watertemp4");
            assertNotNull(storeInfo);
            CoverageInfo ci = getCatalog().getCoverageByName("mosaic");
            assertNotNull(ci);
            assertEquals(storeInfo, ci.getStore());

            // Harvesting of the Mosaic
            URL zipHarvest = getClass().getResource("test-data/harvesting.zip");
            // Extract a Byte array from the zip file
            InputStream is = null;
            byte[] bytes;
            try {
                is = zipHarvest.openStream();
                bytes = IOUtils.toByteArray(is);
            } finally {
                IOUtils.closeQuietly(is);
            }
            // Create the POST request
            MockHttpServletRequest request = createRequest("/rest/workspaces/gs/coveragestores/watertemp4/file.imagemosaic");
            request.setMethod("POST");
            request.setContentType("application/zip");
            request.setBodyContent(bytes);
            request.setHeader("Content-type", "application/zip");
            // Get The response
            MockHttpServletResponse response = dispatch(request);
            // Get the Mosaic Reader
            reader2 = (StructuredGridCoverage2DReader) storeInfo.getGridCoverageReader(null,
                    GeoTools.getDefaultHints());
            // Test if all the TIME DOMAINS are present
            String[] metadataNames = reader2.getMetadataNames();
            assertNotNull(metadataNames);
            assertEquals("true", reader2.getMetadataValue("HAS_TIME_DOMAIN"));
            assertEquals(
                    "2008-10-31T00:00:00.000Z,2008-11-01T00:00:00.000Z,2008-11-02T00:00:00.000Z",
                    reader2.getMetadataValue(metadataNames[0]));
            // Removal of all the data associated to the mosaic
            reader2.delete(true);
        } finally {
            // Reader disposal
            if (reader != null) {
                try {
                    reader.dispose();
                } catch (Throwable t) {
                    // Does nothing
                }
            }
            if (reader2 != null) {
                try {
                    reader2.dispose();
                } catch (Throwable t) {
                    // Does nothing
                }
            }
        }
View Full Code Here

        }

        try {
            GridCoverageReader reader = info.getGridCoverageReader(null, null);
            if(reader instanceof StructuredGridCoverage2DReader) {
                StructuredGridCoverage2DReader sr = (StructuredGridCoverage2DReader) reader;
                return !sr.isReadOnly();
            } else {
                return false;
            }
        } catch(IOException e) {
            throw new RestletException("Failed to access the existing reader to " +
View Full Code Here

       
        // theoretically allowPost was just called, so all these should not need a check
        try {
            CoverageStoreInfo info = catalog.getCoverageStoreByName(workspace, coveragestore);
            GridCoverageReader reader = info.getGridCoverageReader(null, null);
            StructuredGridCoverage2DReader sr = (StructuredGridCoverage2DReader) reader;
            // This method returns a List of the harvested files.
            final List<File> uploadedFiles = doFileUpload(method, workspace, coveragestore, format);
            // File Harvesting
            sr.harvest(null, uploadedFiles, GeoTools.getDefaultHints());
        } catch(IOException e) {
            throw new RestletException("File harvest failed", Status.SERVER_ERROR_INTERNAL, e);
        }
    }
View Full Code Here

TOP

Related Classes of org.geotools.coverage.grid.io.StructuredGridCoverage2DReader

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.