Skip to content

Commit

Permalink
MRG: Merge trunk into branch
Browse files Browse the repository at this point in the history
  • Loading branch information
jmichel-otb committed Jul 8, 2016
2 parents 57e607d + 5c295ab commit e7965e4
Show file tree
Hide file tree
Showing 458 changed files with 6,911 additions and 2,177 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ language: cpp
compiler:
- clang

# remove libogdi3.2-dev : it pulls projects.h from PROJ.4 which no longer exists
before_install:
- sudo mv /etc/apt/sources.list.d/pgdg-source.list* /tmp
- sudo apt-get remove postgis libpq5 libpq-dev postgresql-9.1-postgis postgresql-9.2-postgis postgresql-9.3-postgis postgresql-9.1 postgresql-9.2 postgresql-9.3 libgdal1
Expand All @@ -17,6 +16,7 @@ before_install:
- sudo apt-get install python-numpy postgis postgresql-9.1 postgresql-client-9.1 postgresql-9.1-postgis-2.1 postgresql-9.1-postgis-2.1-scripts libpq-dev libpng12-dev libjpeg-dev libgif-dev liblzma-dev libgeos-dev libcurl4-gnutls-dev libproj-dev libxml2-dev libexpat-dev libxerces-c-dev libnetcdf-dev netcdf-bin libpoppler-dev libspatialite-dev gpsbabel swig libhdf4-alt-dev libhdf5-serial-dev libpodofo-dev poppler-utils libfreexl-dev unixodbc-dev libwebp-dev openjdk-7-jdk libepsilon-dev libgta-dev liblcms2-2 libpcre3-dev mercurial cmake libcrypto++-dev
- sudo apt-get install python-lxml
- sudo apt-get install python-pip
- sudo apt-get install libogdi3.2-dev
# Boost for Mongo
- sudo apt-get install libboost-regex-dev libboost-system-dev libboost-thread-dev
- sudo pip install pyflakes
Expand Down
45 changes: 43 additions & 2 deletions autotest/alg/warp.py
Original file line number Diff line number Diff line change
Expand Up @@ -1696,6 +1696,46 @@ def warp_52():

return 'success'

###############################################################################
# Test Grey+Alpha

def warp_53():

for typestr in ('Byte', 'UInt16', 'Int16'):
src_ds = gdal.Translate('', '../gcore/data/byte.tif',
options = '-of MEM -b 1 -b 1 -ot ' + typestr)
src_ds.GetRasterBand(2).SetColorInterpretation(gdal.GCI_AlphaBand)
src_ds.GetRasterBand(2).Fill(255)
import struct
zero = struct.pack('B' * 1, 0)
src_ds.GetRasterBand(2).WriteRaster(10,10,1,1,zero,
buf_type = gdal.GDT_Byte)
dst_ds = gdal.Translate('', src_ds,
options = '-of MEM -a_srs EPSG:32611')

for option in ( '-wo USE_GENERAL_CASE=TRUE', '' ):
# First checksum is proj 4.8, second proj 4.9.2
for alg_name, expected_cs in ( ('near', [3781,3843]),
('cubic',[3942,4133]),
('cubicspline',[3874,4076]),
('bilinear',[4019,3991]) ):
dst_ds.GetRasterBand(1).Fill(0)
dst_ds.GetRasterBand(2).Fill(0)
gdal.Warp(dst_ds, src_ds,
options = '-r ' + alg_name + ' ' + option)
cs1 = dst_ds.GetRasterBand(1).Checksum()
cs2 = dst_ds.GetRasterBand(2).Checksum()
if (not cs1 in expected_cs) or (not cs2 in [3903, 4138]):
gdaltest.post_reason('fail')
print(typestr)
print(option)
print(alg_name)
print(cs1)
print(cs2)
return 'fail'

return 'success'

gdaltest_list = [
warp_1,
warp_1_short,
Expand Down Expand Up @@ -1765,9 +1805,10 @@ def warp_52():
warp_49,
warp_50,
warp_51,
warp_52
warp_52,
warp_53
]

#gdaltest_list = [ warp_53 ]

if __name__ == '__main__':

Expand Down
33 changes: 24 additions & 9 deletions autotest/cpp/test_virtualmem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,19 +119,19 @@ static int test_two_pages()
return TRUE;
}

static void test_raw_auto(int bFileMapping)
static void test_raw_auto(const char* pszFormat, int bFileMapping)
{
printf("test_raw_auto(bFileMapping=%d)\n", bFileMapping);
printf("test_raw_auto(format=%s, bFileMapping=%d)\n", pszFormat, bFileMapping);

GDALAllRegister();

CPLString osTmpFile;

if( bFileMapping )
osTmpFile = CPLResetExtension(CPLGenerateTempFilename("ehdr"), "img");
osTmpFile = CPLResetExtension(CPLGenerateTempFilename(pszFormat), "img");
else
osTmpFile = "/vsimem/tmp.img";
GDALDatasetH hDS = GDALCreate(GDALGetDriverByName("EHdr"),
GDALDatasetH hDS = GDALCreate(GDALGetDriverByName(pszFormat),
osTmpFile.c_str(),
400, 300, 2, GDT_Byte, NULL );
assert(hDS);
Expand All @@ -140,24 +140,37 @@ static void test_raw_auto(int bFileMapping)
GIntBig nLineSpace1;
int nPixelSpace2;
GIntBig nLineSpace2;
if( !bFileMapping )
{
char** papszOptions = CSLSetNameValue(NULL, "USE_DEFAULT_IMPLEMENTATION", "NO" );
assert( GDALGetVirtualMemAuto(GDALGetRasterBand(hDS, 1),
GF_Write,
&nPixelSpace1,
&nLineSpace1,
papszOptions) == NULL );
CSLDestroy(papszOptions);
}
CPLVirtualMem* pVMem1 = GDALGetVirtualMemAuto(GDALGetRasterBand(hDS, 1),
GF_Write,
&nPixelSpace1,
&nLineSpace1,
NULL);
char** papszOptions = CSLSetNameValue(NULL, "USE_DEFAULT_IMPLEMENTATION",
(bFileMapping) ? "NO" : "YES");
CPLVirtualMem* pVMem2 = GDALGetVirtualMemAuto(GDALGetRasterBand(hDS, 2),
GF_Write,
&nPixelSpace2,
&nLineSpace2,
NULL);
papszOptions);
CSLDestroy(papszOptions);
assert(pVMem1 != NULL);
assert(pVMem2 != NULL);
assert(CPLVirtualMemIsFileMapping(pVMem1) == bFileMapping);
assert(nPixelSpace1 == 1);
assert(nPixelSpace1 == ((EQUAL(pszFormat, "GTIFF") && bFileMapping) ? 2 : 1));
if( bFileMapping )
assert(nLineSpace1 == 400 * 2);
else
assert(nLineSpace1 == 400);
assert(nLineSpace1 == 400 * nPixelSpace1);

GByte* pBase1 = (GByte*) CPLVirtualMemGetAddr(pVMem1);
GByte* pBase2 = (GByte*) CPLVirtualMemGetAddr(pVMem2);
Expand Down Expand Up @@ -214,8 +227,10 @@ int main(int /* argc */, char* /* argv */[])
if( !test_two_pages() )
return 0;

test_raw_auto(TRUE);
test_raw_auto(FALSE);
test_raw_auto("EHDR", TRUE);
test_raw_auto("EHDR", FALSE);
test_raw_auto("GTIFF", TRUE);
test_raw_auto("GTIFF", FALSE);

CPLVirtualMemManagerTerminate();
GDALDestroyDriverManager();
Expand Down
43 changes: 41 additions & 2 deletions autotest/cpp/testcopywords.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -471,8 +471,8 @@ void check_GDT_CFloat32and64()

int main(int /* argc */, char* /* argv */ [])
{
pIn = (char*)malloc(128);
pOut = (char*)malloc(128);
pIn = (char*)malloc(256);
pOut = (char*)malloc(256);

check_GDT_Byte();
check_GDT_Int16();
Expand All @@ -484,6 +484,45 @@ int main(int /* argc */, char* /* argv */ [])
check_GDT_CInt32();
check_GDT_CFloat32and64();

memset(pIn, 0xff, 256);
GInt16* pInShort = (GInt16*)pIn;
GInt16* pOutShort = (GInt16*)pOut;
for(int i=0;i<9;i++)
{
pInShort[2*i+0] = 0x1234;
pInShort[2*i+1] = 0x5678;
}
for(int iSpacing=0;iSpacing<4;iSpacing++)
{
memset(pOut, 0xff, 256);
GDALCopyWords(pInShort, GDT_Int16, sizeof(short),
pOutShort, GDT_Int16, (iSpacing + 1) * sizeof(short),
18);
for(int i=0;i<9;i++)
{
AssertRes(GDT_Int16, pInShort[2*i+0], GDT_Int16, pInShort[2*i+0], pOutShort[(iSpacing+1)*(2*i+0)], __LINE__);
AssertRes(GDT_Int16, pInShort[2*i+1], GDT_Int16, pInShort[2*i+1], pOutShort[(iSpacing+1)*(2*i+1)], __LINE__);
}
}
for(int iSpacing=0;iSpacing<4;iSpacing++)
{
memset(pIn, 0xff, 256);
memset(pOut, 0xff, 256);
for(int i=0;i<9;i++)
{
pInShort[(iSpacing+1)*(2*i+0)] = 0x1234;
pInShort[(iSpacing+1)*(2*i+1)] = 0x5678;
}
GDALCopyWords(pInShort, GDT_Int16, (iSpacing + 1) * sizeof(short),
pOutShort, GDT_Int16, sizeof(short),
18);
for(int i=0;i<9;i++)
{
AssertRes(GDT_Int16, pInShort[(iSpacing+1)*(2*i+0)], GDT_Int16, pInShort[(iSpacing+1)*(2*i+0)], pOutShort[2*i+0], __LINE__);
AssertRes(GDT_Int16, pInShort[(iSpacing+1)*(2*i+1)], GDT_Int16, pInShort[(iSpacing+1)*(2*i+1)], pOutShort[2*i+1], __LINE__);
}
}

free(pIn);
free(pOut);

Expand Down
18 changes: 18 additions & 0 deletions autotest/gcore/data/pixfun_cmul_c.vrt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<VRTDataset rasterXSize="5" rasterYSize="6">
<VRTRasterBand dataType="CFloat32" band="1" subClass="VRTDerivedRasterBand">
<Description>Product with complex conjugate</Description>
<PixelFunctionType>cmul</PixelFunctionType>
<SimpleSource>
<SourceFilename relativeToVRT="1">cint_sar.tif</SourceFilename>
<SourceBand>1</SourceBand>
<SrcRect xOff="0" yOff="0" xSize="5" ySize="6"/>
<DstRect xOff="0" yOff="0" xSize="5" ySize="6"/>
</SimpleSource>
<SimpleSource>
<SourceFilename relativeToVRT="1">cint_sar.tif</SourceFilename>
<SourceBand>1</SourceBand>
<SrcRect xOff="0" yOff="0" xSize="5" ySize="6"/>
<DstRect xOff="0" yOff="0" xSize="5" ySize="6"/>
</SimpleSource>
</VRTRasterBand>
</VRTDataset>
18 changes: 18 additions & 0 deletions autotest/gcore/data/pixfun_cmul_r.vrt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<VRTDataset rasterXSize="20" rasterYSize="20">
<VRTRasterBand dataType="Float32" band="1" subClass="VRTDerivedRasterBand">
<Description>Product with complex conjugate</Description>
<PixelFunctionType>cmul</PixelFunctionType>
<SimpleSource>
<SourceFilename relativeToVRT="1">uint16.tif</SourceFilename>
<SourceBand>1</SourceBand>
<SrcRect xOff="0" yOff="0" xSize="20" ySize="20"/>
<DstRect xOff="0" yOff="0" xSize="20" ySize="20"/>
</SimpleSource>
<SimpleSource>
<SourceFilename relativeToVRT="1">int32.tif</SourceFilename>
<SourceBand>1</SourceBand>
<SrcRect xOff="0" yOff="0" xSize="20" ySize="20"/>
<DstRect xOff="0" yOff="0" xSize="20" ySize="20"/>
</SimpleSource>
</VRTRasterBand>
</VRTDataset>
13 changes: 13 additions & 0 deletions autotest/gcore/data/pixfun_conj_c.vrt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<VRTDataset rasterXSize="5" rasterYSize="6">
<VRTRasterBand dataType="CInt16" band="1" subClass="VRTDerivedRasterBand">
<Description>conjugate</Description>
<PixelFunctionType>conj</PixelFunctionType>
<SourceTransferType>CInt16</SourceTransferType>
<SimpleSource>
<SourceFilename relativeToVRT="1">cint_sar.tif</SourceFilename>
<SourceBand>1</SourceBand>
<SrcRect xOff="0" yOff="0" xSize="5" ySize="6"/>
<DstRect xOff="0" yOff="0" xSize="5" ySize="6"/>
</SimpleSource>
</VRTRasterBand>
</VRTDataset>
13 changes: 13 additions & 0 deletions autotest/gcore/data/pixfun_conj_r.vrt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<VRTDataset rasterXSize="20" rasterYSize="20">
<VRTRasterBand dataType="Float64" band="1" subClass="VRTDerivedRasterBand">
<Description>conjugate</Description>
<PixelFunctionType>conj</PixelFunctionType>
<SourceTransferType>Int32</SourceTransferType>
<SimpleSource>
<SourceFilename relativeToVRT="1">int32.tif</SourceFilename>
<SourceBand>1</SourceBand>
<SrcRect xOff="0" yOff="0" xSize="20" ySize="20"/>
<DstRect xOff="0" yOff="0" xSize="20" ySize="20"/>
</SimpleSource>
</VRTRasterBand>
</VRTDataset>
13 changes: 13 additions & 0 deletions autotest/gcore/data/pixfun_dB2amp.vrt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<VRTDataset rasterXSize="20" rasterYSize="20">
<VRTRasterBand dataType="Float64" band="1" subClass="VRTDerivedRasterBand">
<Description>db to amplitude</Description>
<PixelFunctionType>dB2amp</PixelFunctionType>
<SourceTransferType>Float64</SourceTransferType>
<SimpleSource>
<SourceFilename relativeToVRT="1">float32.tif</SourceFilename>
<SourceBand>1</SourceBand>
<SrcRect xOff="0" yOff="0" xSize="20" ySize="20"/>
<DstRect xOff="0" yOff="0" xSize="20" ySize="20"/>
</SimpleSource>
</VRTRasterBand>
</VRTDataset>
13 changes: 13 additions & 0 deletions autotest/gcore/data/pixfun_dB2pow.vrt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<VRTDataset rasterXSize="20" rasterYSize="20">
<VRTRasterBand dataType="Float64" band="1" subClass="VRTDerivedRasterBand">
<Description>dB to power</Description>
<PixelFunctionType>dB2pow</PixelFunctionType>
<SourceTransferType>Float64</SourceTransferType>
<SimpleSource>
<SourceFilename relativeToVRT="1">float32.tif</SourceFilename>
<SourceBand>1</SourceBand>
<SrcRect xOff="0" yOff="0" xSize="20" ySize="20"/>
<DstRect xOff="0" yOff="0" xSize="20" ySize="20"/>
</SimpleSource>
</VRTRasterBand>
</VRTDataset>
18 changes: 18 additions & 0 deletions autotest/gcore/data/pixfun_diff_c.vrt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<VRTDataset rasterXSize="5" rasterYSize="6">
<VRTRasterBand dataType="CFloat32" band="1" subClass="VRTDerivedRasterBand">
<Description>Difference</Description>
<PixelFunctionType>diff</PixelFunctionType>
<SimpleSource>
<SourceFilename relativeToVRT="1">cint_sar.tif</SourceFilename>
<SourceBand>1</SourceBand>
<SrcRect xOff="0" yOff="0" xSize="5" ySize="6"/>
<DstRect xOff="0" yOff="0" xSize="5" ySize="6"/>
</SimpleSource>
<SimpleSource>
<SourceFilename relativeToVRT="1">cfloat64.tif</SourceFilename>
<SourceBand>1</SourceBand>
<SrcRect xOff="0" yOff="0" xSize="5" ySize="6"/>
<DstRect xOff="0" yOff="0" xSize="5" ySize="6"/>
</SimpleSource>
</VRTRasterBand>
</VRTDataset>
18 changes: 18 additions & 0 deletions autotest/gcore/data/pixfun_diff_r.vrt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<VRTDataset rasterXSize="5" rasterYSize="6">
<VRTRasterBand dataType="Float32" band="1" subClass="VRTDerivedRasterBand">
<Description>Difference</Description>
<PixelFunctionType>diff</PixelFunctionType>
<SimpleSource>
<SourceFilename relativeToVRT="1">int32.tif</SourceFilename>
<SourceBand>1</SourceBand>
<SrcRect xOff="0" yOff="0" xSize="5" ySize="6"/>
<DstRect xOff="0" yOff="0" xSize="5" ySize="6"/>
</SimpleSource>
<SimpleSource>
<SourceFilename relativeToVRT="1">float32.tif</SourceFilename>
<SourceBand>1</SourceBand>
<SrcRect xOff="10" yOff="10" xSize="5" ySize="6"/>
<DstRect xOff="0" yOff="0" xSize="5" ySize="6"/>
</SimpleSource>
</VRTRasterBand>
</VRTDataset>
13 changes: 13 additions & 0 deletions autotest/gcore/data/pixfun_imag_c.vrt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<VRTDataset rasterXSize="5" rasterYSize="6">
<VRTRasterBand dataType="Float64" band="1" subClass="VRTDerivedRasterBand">
<Description>Imaginary part</Description>
<PixelFunctionType>imag</PixelFunctionType>
<SourceTransferType>CFloat64</SourceTransferType>
<SimpleSource>
<SourceFilename relativeToVRT="1">cint_sar.tif</SourceFilename>
<SourceBand>1</SourceBand>
<SrcRect xOff="0" yOff="0" xSize="5" ySize="6"/>
<DstRect xOff="0" yOff="0" xSize="5" ySize="6"/>
</SimpleSource>
</VRTRasterBand>
</VRTDataset>
13 changes: 13 additions & 0 deletions autotest/gcore/data/pixfun_imag_r.vrt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<VRTDataset rasterXSize="20" rasterYSize="20">
<VRTRasterBand dataType="Float32" band="1" subClass="VRTDerivedRasterBand">
<Description>Imaginary part</Description>
<PixelFunctionType>imag</PixelFunctionType>
<SourceTransferType>Float32</SourceTransferType>
<SimpleSource>
<SourceFilename relativeToVRT="1">float32.tif</SourceFilename>
<SourceBand>1</SourceBand>
<SrcRect xOff="0" yOff="0" xSize="20" ySize="20"/>
<DstRect xOff="0" yOff="0" xSize="20" ySize="20"/>
</SimpleSource>
</VRTRasterBand>
</VRTDataset>
13 changes: 13 additions & 0 deletions autotest/gcore/data/pixfun_intensity_c.vrt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<VRTDataset rasterXSize="5" rasterYSize="6">
<VRTRasterBand dataType="Float64" band="1" subClass="VRTDerivedRasterBand">
<Description>Intensity</Description>
<PixelFunctionType>intensity</PixelFunctionType>
<SourceTransferType>CFloat64</SourceTransferType>
<SimpleSource>
<SourceFilename relativeToVRT="1">cint_sar.tif</SourceFilename>
<SourceBand>1</SourceBand>
<SrcRect xOff="0" yOff="0" xSize="5" ySize="6"/>
<DstRect xOff="0" yOff="0" xSize="5" ySize="6"/>
</SimpleSource>
</VRTRasterBand>
</VRTDataset>
13 changes: 13 additions & 0 deletions autotest/gcore/data/pixfun_intensity_r.vrt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<VRTDataset rasterXSize="20" rasterYSize="20">
<VRTRasterBand dataType="Float32" band="1" subClass="VRTDerivedRasterBand">
<Description>Intensity</Description>
<PixelFunctionType>intensity</PixelFunctionType>
<SourceTransferType>Float32</SourceTransferType>
<SimpleSource>
<SourceFilename relativeToVRT="1">float32.tif</SourceFilename>
<SourceBand>1</SourceBand>
<SrcRect xOff="0" yOff="0" xSize="20" ySize="20"/>
<DstRect xOff="0" yOff="0" xSize="20" ySize="20"/>
</SimpleSource>
</VRTRasterBand>
</VRTDataset>
Loading

0 comments on commit e7965e4

Please sign in to comment.