Search in sources :

Example 11 with Dataset

use of org.gdal.gdal.Dataset in project com.revolsys.open by revolsys.

the class Gdal method getDataset.

public static Dataset getDataset(final File file, final int mode) {
    if (isAvailable()) {
        final String path = file.getAbsolutePath();
        if (file.exists()) {
            final Dataset dataset = gdal.Open(path, mode);
            if (dataset == null) {
                throw new GdalException();
            } else {
                final Resource resource = new PathResource(file);
                setProjectionFromPrjFile(dataset, resource);
                final long modifiedTime = loadSettings(dataset, resource);
                return dataset;
            }
        } else {
            throw new IllegalArgumentException("File no found: " + path);
        }
    } else {
        throw new IllegalStateException("GDAL is not available");
    }
}
Also used : Dataset(org.gdal.gdal.Dataset) PathResource(com.revolsys.spring.resource.PathResource) PathResource(com.revolsys.spring.resource.PathResource) Resource(com.revolsys.spring.resource.Resource)

Aggregations

Dataset (org.gdal.gdal.Dataset)11 File (java.io.File)3 FileImageInputStreamExt (it.geosolutions.imageio.stream.input.FileImageInputStreamExt)2 Dimension (java.awt.Dimension)2 Rectangle (java.awt.Rectangle)2 BufferedImage (java.awt.image.BufferedImage)2 IOException (java.io.IOException)2 URL (java.net.URL)2 Vector (java.util.Vector)2 Driver (org.gdal.gdal.Driver)2 BoundingBox (com.revolsys.geometry.model.BoundingBox)1 PathResource (com.revolsys.spring.resource.PathResource)1 Resource (com.revolsys.spring.resource.Resource)1 GCP (it.geosolutions.imageio.core.GCP)1 DriverCreateCapabilities (it.geosolutions.imageio.gdalframework.GDALUtilities.DriverCreateCapabilities)1 EnhancedImageReadParam (it.geosolutions.imageio.imageioimpl.EnhancedImageReadParam)1 URIImageInputStream (it.geosolutions.imageio.stream.input.URIImageInputStream)1 BandedSampleModel (java.awt.image.BandedSampleModel)1 ColorModel (java.awt.image.ColorModel)1 PixelInterleavedSampleModel (java.awt.image.PixelInterleavedSampleModel)1