public Driver initialValue() { return gdal.GetDriverByName("MEM"); } }
/** * Init the drivers if the GDAL library is installed. */ public static void initDrivers() { gdal.AllRegister(); // GDAL init drivers } }
public java.nio.ByteBuffer ReadRaster_Direct(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type) { long buf_size = buf_xsize * buf_ysize * (gdal.GetDataTypeSize(buf_type) / 8); if ((int)buf_size != buf_size) throw new OutOfMemoryError(); java.nio.ByteBuffer nioBuffer = java.nio.ByteBuffer.allocateDirect((int)buf_size); int ret = ReadRaster_Direct(xoff, yoff, xsize, ysize, buf_xsize, buf_ysize, buf_type, nioBuffer); if (ret == gdalconstConstants.CE_None) return nioBuffer; else return null; }
public static void init() throws Throwable { if (gdal.GetDriverCount() == 0) { gdal.AllRegister(); } }
public GdalException() { super(gdal.GetLastErrorMsg().trim()); gdal.ErrorReset(); }
@Override protected GDALDataset open(File file, Map<?, Object> opts) throws IOException { Dataset ds = gdal.OpenShared(file.getAbsolutePath()); if (ds == null) { String lastErrMsg = gdal.GetLastErrorMsg(); String msg = "Unable to open file: " + file; if (lastErrMsg != null) { msg += ", " + lastErrMsg; } throw new IOException(msg); } return new GDALDataset(file, ds, this); }
final int threshold = getMaxMemorySizeForGDALMemoryDataset(); final int neededMemory = width * height * nBands * gdal.GetDataTypeSize(dataType) / 8; final Driver driver = gdal.GetDriverByName("GTiff"); tempDs = driver.Create(tempFile, width, height, nBands, dataType, (String[])null);
typeSizeInBytes = gdal.GetDataTypeSize(bufferType) / 8; bufferSize = nBands * pixels * typeSizeInBytes; gdal.GetLastErrorMsg()).toString()); LOGGER.info(new StringBuilder("Last error number: ").append( gdal.GetLastErrorNo()).toString()); LOGGER.info(new StringBuilder("Last error type: ").append( gdal.GetLastErrorType()).toString()); throw new RuntimeException(gdal.GetLastErrorMsg());
gdal.AllRegister(); final String versionInfo = gdal.VersionInfo("RELEASE_NAME"); if (versionInfo != null && versionInfo.trim().length() > 0) { if (LOGGER.isLoggable(Level.INFO)) final boolean showErrors = getAsBoolean(cplDebug); if (!showErrors) { gdal.PushErrorHandler("CPLQuietErrorHandler");
/** * Opens a dataset for the given file in read-only mode. * * @param file the file to open. * @throws IOException if the given file can not be opened. */ public DataSet(final Path file) throws IOException { ds = gdal.Open(file.toString()); if (ds == null) { String msg = gdal.GetLastErrorMsg(); if (msg == null) { msg = "Can not open \"" + file + "\"."; } throw new GDALException(msg); } }
/** * Allows to enable/disable GDAL caching mechanism. * * @param useCaching * <code>true</code> to enable GDAL caching. * <code>false</code> to disable GDAL caching. */ public static void setGdalCaching(boolean useCaching) { final String sOption = useCaching ? "YES" : "NO"; gdal.SetConfigOption("GDAL_FORCE_CACHING", sOption); }
/** * Acquires a {@link Dataset} and return it, given the name of the Dataset * source and the desired access type * * @param name * of the dataset source to be accessed (usually, a File * name). * @param accessType * @return the acquired {@link Dataset} */ public static Dataset acquireDataSet(final String name,final int accessType) { if (!isGDALAvailable()) { return null; } if(name == null) { throw new IllegalArgumentException("Provided parameter is null:name"); } return gdal.Open(name, accessType); }
private Dataset reproject( Dataset src, String dstCrsWkt ) { Driver vrtDriver = gdal.GetDriverByName( "MEM" ); Dataset region = vrtDriver.Create( "/tmp/whatever", width, height, src.getRasterCount() ); region.SetProjection( dstCrsWkt ); region.SetGeoTransform( getGeoTransform( bbox, width, height ) ); gdal.ReprojectImage( src, region ); return region; }
String gdalDataTypeName = gdal.GetDataTypeName(this.gdalDataType); String message = MessageFormat.format("The GDAL driver ''{0}'' does not support the data type ''{1}'' to create a new product." + " The available types are ''{2}''.", this.gdalDriver = gdal.GetDriverByName(this.writerDriver.getDriverName()); if (this.gdalDriver == null) { throw new NullPointerException("The GDAL driver '" + this.writerDriver.getDriverDisplayName() + "' ("+this.writerDriver.getDriverName()+") used to write the product does not exist.");
Dataset gdalDataset = gdal.Open(inputFile.toString(), gdalconst.GA_ReadOnly); if (gdalDataset == null) { String colorInterpretationName = gdal.GetColorInterpretationName(gdalBand.GetRasterColorInterpretation()); bandComponentElement.setAttributeString("data type", gdal.GetDataTypeName(gdalDataType)); bandComponentElement.setAttributeString("color interpretation", colorInterpretationName); bandComponentElement.setAttributeString("block size", tileWidth + "x" + tileHeight);
@Override protected boolean canOpen(File file, Map<?, Object> opts, Messages msgs) { Driver drv = gdalDrv != null ? gdalDrv : gdal.IdentifyDriver(file.getAbsolutePath()); if (drv == null) { String msg = "Unable to locate driver"; String lastErrMsg = gdal.GetLastErrorMsg(); if (lastErrMsg != null) { msg += ": " + lastErrMsg; } Messages.of(msgs).report(msg); return false; } return super.canOpen(file, opts, msgs); }
@Override public String GetLastErrorMsg() { return gdal.GetLastErrorMsg(); }
public static String[] GeneralCmdLineProcessor(String[] args) { return GeneralCmdLineProcessor(args, 0); }
/** * Check if the available creation data types of the driver contains the GDAL data type. * * @param gdalDataType The GDAl data type to check * * @return true if the driver can export the product containing the specified data type; false otherwise */ public boolean canExportProduct(int gdalDataType) { boolean allowedDataType = true; String gdalDataTypeName = gdal.GetDataTypeName(gdalDataType); if (this.creationDataTypes != null) { allowedDataType = this.creationDataTypes.contains(gdalDataTypeName); } return allowedDataType; }
dataset = gdal.AutoCreateWarpedVRT( dataset, dataset.GetProjection(),