Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TileDB support - https://www.tiledb.io #1402

Merged
merged 27 commits into from
Apr 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
85b023d
TileDB driver
normanb Mar 16, 2019
067471e
Merge remote-tracking branch 'upstream/master' into tiledb-dev
normanb Mar 21, 2019
bb93a43
TileDB support
normanb Mar 24, 2019
4774997
removed tabs
normanb Apr 4, 2019
3c9e43f
resolve extension if driver is not found
normanb Apr 5, 2019
e4fa2b3
updated tiledb doc
normanb Apr 5, 2019
a730932
made tiledbdataset SetBuffer static for performance
normanb Apr 5, 2019
99377cb
updated tiledb test license and test file.
normanb Apr 8, 2019
478fa0a
removed global order setting for reads
normanb Apr 8, 2019
f102725
tiledb ci
normanb Apr 8, 2019
e4f6f6d
formatting whitespace
normanb Apr 9, 2019
a8357c6
compiler settings for tiledb ci
normanb Apr 9, 2019
bc438fd
ci changes
normanb Apr 9, 2019
1de5fb6
TileDB: add missing member initializations
rouault Apr 9, 2019
4ba9c44
TileDB: remove tiff.h dependency
rouault Apr 9, 2019
26d4d21
TileDB: fix memleak in Identify(), and use more idiomatic GetSiblingF…
rouault Apr 9, 2019
a6b22fe
TileDB: move tests to autotest/gdrivers
rouault Apr 9, 2019
143f0c4
TileDB: move inclusion of tiledb header to dedicated file to avoid wa…
rouault Apr 9, 2019
d9ead61
TileDB: small doc updates
rouault Apr 9, 2019
9bf4d5b
TileDB: be more robust to arbitrary metadata in SUBDATASETS domain
rouault Apr 9, 2019
c4da0d0
TileDB: another fix to be more robust to arbitrary metadata in SUBDAT…
rouault Apr 9, 2019
bc893c7
TileDB: 'cleanup' related to papszCopyOptions
rouault Apr 9, 2019
24337c5
TileDB: use more extensively std::unique_ptr
rouault Apr 9, 2019
56bfb3f
TileDB: fix crash when opening non existing subdataset
rouault Apr 9, 2019
b1f01a4
removed custom error handler
normanb Apr 11, 2019
5a176b1
TileDB: improve exception catching regarding memleaks
rouault Apr 11, 2019
dbadeb0
removed tiledb from ci
normanb Apr 12, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Empty file.
16 changes: 16 additions & 0 deletions autotest/gdrivers/data/tiledb_array/tiledb_array.tdb.aux.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<PAMDataset>
<SRS dataAxisToSRSAxisMapping="1,2">PROJCS["NAD27 / UTM zone 16N",GEOGCS["NAD27",DATUM["North_American_Datum_1927",SPHEROID["Clarke 1866",6378206.4,294.978698213898,AUTHORITY["EPSG","7008"]],AUTHORITY["EPSG","6267"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4267"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",-87],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Easting",EAST],AXIS["Northing",NORTH],AUTHORITY["EPSG","26716"]]</SRS>
<GeoTransform> 4.4465000000000000e+05, 1.0000000000000000e+01, 0.0000000000000000e+00, 4.6405100000000000e+06, 0.0000000000000000e+00, -1.0000000000000000e+01</GeoTransform>
<Metadata domain="IMAGE_STRUCTURE">
<MDI key="DATA_TYPE">1</MDI>
<MDI key="NBITS">8</MDI>
<MDI key="X_SIZE">699</MDI>
<MDI key="Y_SIZE">929</MDI>
</Metadata>
<Metadata>
<MDI key="AREA_OR_POINT">Area</MDI>
<MDI key="TIFFTAG_RESOLUTIONUNIT">1 (unitless)</MDI>
<MDI key="TIFFTAG_XRESOLUTION">72</MDI>
<MDI key="TIFFTAG_YRESOLUTION">72</MDI>
</Metadata>
</PAMDataset>
39 changes: 39 additions & 0 deletions autotest/gdrivers/tiledb_read.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env pytest
# -*- coding: utf-8 -*-
###############################################################################
# $Id$
#
# Project: GDAL/OGR Test Suite
# Purpose: Test basic read support for all datatypes from a TileDB array.
# Author: TileDB, Inc
#
###############################################################################
# Copyright (c) 2019, TileDB, Inc
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
###############################################################################

import pytest

import gdaltest

@pytest.mark.require_driver('TileDB')
def test_tiledb_open():
ut = gdaltest.GDALTest('TileDB', 'tiledb_array', 1, 4857)
ut.testOpen()
114 changes: 114 additions & 0 deletions autotest/gdrivers/tiledb_write.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
#!/usr/bin/env pytest
# -*- coding: utf-8 -*-
###############################################################################
# $Id$
#
# Project: GDAL/OGR Test Suite
# Purpose: Test read/write functionality for GeoTIFF format.
# Author: TileDB, Inc
#
###############################################################################
# Copyright (c) 2019, TileDB, Inc
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
###############################################################################

from osgeo import gdal
import pytest

import gdaltest

@pytest.mark.require_driver('TileDB')
def test_tiledb_write_complex():
gdaltest.tiledb_drv = gdal.GetDriverByName('TileDB')

src_ds = gdal.Open('../gcore/data/cfloat64.tif')

new_ds = gdaltest.tiledb_drv.CreateCopy('tmp/tiledb_complex64', src_ds)

bnd = new_ds.GetRasterBand(1)
assert bnd.Checksum() == 5028, 'Didnt get expected checksum on still-open file'

bnd = None
new_ds = None

gdaltest.tiledb_drv.Delete('tmp/tiledb_complex64')

@pytest.mark.require_driver('TileDB')
def test_tiledb_write_custom_blocksize():
gdaltest.tiledb_drv = gdal.GetDriverByName('TileDB')

src_ds = gdal.Open('../gcore/data/utmsmall.tif')

options = ['BLOCKXSIZE=32', 'BLOCKYSIZE=32']

new_ds = gdaltest.tiledb_drv.CreateCopy('tmp/tiledb_custom', src_ds,
options=options)

bnd = new_ds.GetRasterBand(1)
assert bnd.Checksum() == 50054, 'Didnt get expected checksum on still-open file'
assert bnd.GetBlockSize() == [32, 32]

bnd = None
new_ds = None

gdaltest.tiledb_drv.Delete('tmp/tiledb_custom')

@pytest.mark.require_driver('TileDB')
def test_tiledb_write_rgb():
gdaltest.tiledb_drv = gdal.GetDriverByName('TileDB')

src_ds = gdal.Open('../gcore/data/rgbsmall.tif')

new_ds = gdaltest.tiledb_drv.CreateCopy('tmp/tiledb_rgb', src_ds)

assert new_ds.RasterCount == 3, 'Didnt get expected band count'
bnd = new_ds.GetRasterBand(2)
assert bnd.Checksum() == 21053, 'Didnt get expected checksum on still-open file'

new_ds = None

gdaltest.tiledb_drv.Delete('tmp/tiledb_rgb')

@pytest.mark.require_driver('TileDB')
@pytest.mark.require_driver('HDF5')
def test_tiledb_write_subdatasets():
gdaltest.tiledb_drv = gdal.GetDriverByName('TileDB')

src_ds = gdal.Open('data/DeepBlue-SeaWiFS-1.0_L3_20100101_v004-20130604T131317Z.h5')

new_ds = gdaltest.tiledb_drv.CreateCopy('tmp/test_sds_array', src_ds,
False)

assert new_ds is not None
new_ds = None
src_ds = None

src_ds = gdal.Open('tmp/test_sds_array')
assert 'tmp/test_sds_array/test_sds_array.tdb.aux.xml' in src_ds.GetFileList()
src_ds = None

src_ds = gdal.Open('TILEDB:"tmp/test_sds_array":viewing_zenith_angle')
assert src_ds.GetRasterBand(1).Checksum() == 42472
src_ds = None

src_ds = gdal.Open('TILEDB:"tmp/test_sds_array":i_dont_exist')
assert not src_ds

gdaltest.tiledb_drv.Delete('tmp/test_sds_array')
1 change: 1 addition & 0 deletions gdal/GDALmake.opt.in
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,7 @@ LIBZ_SETTING = @LIBZ_SETTING@
LIBLZMA_SETTING = @LIBLZMA_SETTING@
WEBP_SETTING = @WEBP_SETTING@
ZSTD_SETTING = @ZSTD_SETTING@
TILEDB_SETTING = @TILEDB_SETTING@

#
# DDS via Crunch Support.
Expand Down
108 changes: 71 additions & 37 deletions gdal/apps/gdal_translate_bin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,57 +265,91 @@ MAIN_START(argc, argv)

int bUsageError = FALSE;
GDALDatasetH hOutDS = nullptr;
if( psOptionsForBinary->bCopySubDatasets &&
CSLCount(GDALGetMetadata( hDataset, "SUBDATASETS" )) > 0 )
GDALDriverH hOutDriver = nullptr;

if ( psOptionsForBinary->pszFormat == nullptr )
{
hOutDriver = GDALGetDriverByName(
GetOutputDriverForRaster( psOptionsForBinary->pszDest )
);
}
else
{
hOutDriver = GDALGetDriverByName( psOptionsForBinary->pszFormat );
}

if ( hOutDriver == nullptr )
{
char **papszSubdatasets = GDALGetMetadata(hDataset,"SUBDATASETS");
char *pszSubDest = static_cast<char *>(
CPLMalloc(strlen(psOptionsForBinary->pszDest) + 32));
fprintf( stderr, "Output driver not found.\n");
GDALClose( hDataset );
GDALDestroyDriverManager();
exit( 1 );
}

CPLString osPath = CPLGetPath(psOptionsForBinary->pszDest);
CPLString osBasename = CPLGetBasename(psOptionsForBinary->pszDest);
CPLString osExtension = CPLGetExtension(psOptionsForBinary->pszDest);
CPLString osTemp;
bool bCopyCreateSubDatasets = ( GDALGetMetadataItem( hOutDriver, GDAL_DCAP_SUBCREATECOPY, nullptr ) != nullptr );

const char* pszFormat = nullptr;
if ( CSLCount(papszSubdatasets)/2 < 10 )
{
pszFormat = "%s_%d";
}
else if ( CSLCount(papszSubdatasets)/2 < 100 )
if( psOptionsForBinary->bCopySubDatasets &&
CSLCount(GDALGetMetadata( hDataset, "SUBDATASETS" )) > 0 )
{
if ( bCopyCreateSubDatasets )
{
pszFormat = "%s_%002d";
// GDAL sets the size of the dataset with subdatasets to 512x512
// this removes the srcwin function from this operation
hOutDS = GDALTranslate(psOptionsForBinary->pszDest, hDataset, psOptions, &bUsageError);
GDALClose(hOutDS);
}
else
{
pszFormat = "%s_%003d";
}
char **papszSubdatasets = GDALGetMetadata(hDataset,"SUBDATASETS");
char *pszSubDest = static_cast<char *>(
CPLMalloc(strlen(psOptionsForBinary->pszDest) + 32));

const char* pszDest = pszSubDest;
CPLString osPath = CPLGetPath(psOptionsForBinary->pszDest);
CPLString osBasename = CPLGetBasename(psOptionsForBinary->pszDest);
CPLString osExtension = CPLGetExtension(psOptionsForBinary->pszDest);
CPLString osTemp;

for( int i = 0; papszSubdatasets[i] != nullptr; i += 2 )
{
char* pszSource = CPLStrdup(strstr(papszSubdatasets[i],"=")+1);
osTemp = CPLSPrintf( pszFormat, osBasename.c_str(), i/2 + 1 );
osTemp = CPLFormFilename( osPath, osTemp, osExtension );
strcpy( pszSubDest, osTemp.c_str() );
hDataset = GDALOpenEx( pszSource, GDAL_OF_RASTER, nullptr,
psOptionsForBinary->papszOpenOptions, nullptr );
CPLFree(pszSource);
if( !psOptionsForBinary->bQuiet )
printf("Input file size is %d, %d\n", GDALGetRasterXSize(hDataset), GDALGetRasterYSize(hDataset));
hOutDS = GDALTranslate(pszDest, hDataset, psOptions, &bUsageError);
if(bUsageError == TRUE)
Usage();
if (hOutDS == nullptr)
break;
GDALClose(hOutDS);
const char* pszFormat = nullptr;
if ( CSLCount(papszSubdatasets)/2 < 10 )
{
pszFormat = "%s_%d";
}
else if ( CSLCount(papszSubdatasets)/2 < 100 )
{
pszFormat = "%s_%002d";
}
else
{
pszFormat = "%s_%003d";
}

const char* pszDest = pszSubDest;

for( int i = 0; papszSubdatasets[i] != nullptr; i += 2 )
{
char* pszSource = CPLStrdup(strstr(papszSubdatasets[i],"=")+1);
osTemp = CPLSPrintf( pszFormat, osBasename.c_str(), i/2 + 1 );
osTemp = CPLFormFilename( osPath, osTemp, osExtension );
strcpy( pszSubDest, osTemp.c_str() );
hDataset = GDALOpenEx( pszSource, GDAL_OF_RASTER, nullptr,
psOptionsForBinary->papszOpenOptions, nullptr );
CPLFree(pszSource);
if( !psOptionsForBinary->bQuiet )
printf("Input file size is %d, %d\n", GDALGetRasterXSize(hDataset), GDALGetRasterYSize(hDataset));
hOutDS = GDALTranslate(pszDest, hDataset, psOptions, &bUsageError);
if (hOutDS == nullptr)
break;
GDALClose(hOutDS);
}

CPLFree(pszSubDest);
}

if(bUsageError == TRUE)
Usage();
GDALClose(hDataset);
GDALTranslateOptionsFree(psOptions);
GDALTranslateOptionsForBinaryFree(psOptionsForBinary);
CPLFree(pszSubDest);

GDALDestroyDriverManager();
return 0;
Expand Down
4 changes: 3 additions & 1 deletion gdal/apps/gdal_translate_lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -655,9 +655,11 @@ GDALDatasetH GDALTranslate( const char *pszDest, GDALDatasetH hSrcDataset,

if( psOptions->panBandList == nullptr )
{

psOptions->nBandCount = GDALGetRasterCount( hSrcDataset );
if( psOptions->nBandCount == 0 )
if( ( psOptions->nBandCount == 0 ) && (psOptions->bStrict ) )
{
// if not strict then the driver can fail if it doesn't support zero bands
CPLError( CE_Failure, CPLE_AppDefined, "Input file has no bands, and so cannot be translated." );
GDALTranslateOptionsFree(psOptions);
return nullptr;
Expand Down
Loading