Skip to content

Commit

Permalink
Merge branch 'trunk' into enhance-complex-datasets-with-pf
Browse files Browse the repository at this point in the history
  • Loading branch information
jmichel-otb committed Jul 12, 2016
2 parents 8b7793e + bf7b478 commit a897355
Show file tree
Hide file tree
Showing 129 changed files with 2,492 additions and 1,345 deletions.
39 changes: 39 additions & 0 deletions autotest/cpp/test_gdal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,4 +282,43 @@ namespace tut
GetGDALDriverManager()->DeregisterDriver( poDriver );
delete poDriver;
}

// Test that GDALSwapWords() with unaligned buffers
template<> template<> void object::test<10>()
{
GByte abyBuffer[ 8 * 2 + 1 ] = { 0, 1, 2, 3, 4, 5, 6, 7, 255, 7, 6, 5, 4, 3, 2, 1, 0 };
GDALSwapWords(abyBuffer, 4, 2, 9 );
ensure( abyBuffer[0] == 3 );
ensure( abyBuffer[1] == 2 );
ensure( abyBuffer[2] == 1 );
ensure( abyBuffer[3] == 0 );

ensure( abyBuffer[9] == 4 );
ensure( abyBuffer[10] == 5 );
ensure( abyBuffer[11] == 6 );
ensure( abyBuffer[12] == 7 );
GDALSwapWords(abyBuffer, 4, 2, 9 );

GDALSwapWords(abyBuffer, 8, 2, 9 );
ensure( abyBuffer[0] == 7 );
ensure( abyBuffer[1] == 6 );
ensure( abyBuffer[2] == 5 );
ensure( abyBuffer[3] == 4 );
ensure( abyBuffer[4] == 3 );
ensure( abyBuffer[5] == 2 );
ensure( abyBuffer[6] == 1 );
ensure( abyBuffer[7] == 0 );

ensure( abyBuffer[9] == 0 );
ensure( abyBuffer[10] == 1 );
ensure( abyBuffer[11] == 2 );
ensure( abyBuffer[12] == 3 );
ensure( abyBuffer[13] == 4 );
ensure( abyBuffer[14] == 5 );
ensure( abyBuffer[15] == 6 );
ensure( abyBuffer[16] == 7 );
GDALSwapWords(abyBuffer, 4, 2, 9 );

}

} // namespace tut
Binary file added autotest/gcore/data/dbl_min.tif
Binary file not shown.
Binary file added autotest/gcore/data/flt_min.tif
Binary file not shown.
19 changes: 19 additions & 0 deletions autotest/gcore/data/pixfun_complex.vrt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<VRTDataset rasterXSize="20" rasterYSize="20">
<VRTRasterBand dataType="CFloat32" band="1" subClass="VRTDerivedRasterBand">
<Description>Make complex</Description>
<PixelFunctionType>complex</PixelFunctionType>
<SourceTransferType>CFloat32</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>
<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_dB_c.vrt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<VRTDataset rasterXSize="5" rasterYSize="6">
<VRTRasterBand dataType="Float32" band="1" subClass="VRTDerivedRasterBand">
<Description>dB</Description>
<PixelFunctionType>dB</PixelFunctionType>
<SourceTransferType>CFloat64</SourceTransferType>
<SimpleSource>
<SourceFilename relativeToVRT="1">cint_sar.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_dB_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>dB</Description>
<PixelFunctionType>dB</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_log10_c.vrt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<VRTDataset rasterXSize="5" rasterYSize="6">
<VRTRasterBand dataType="Float32" band="1" subClass="VRTDerivedRasterBand">
<Description>Log10</Description>
<PixelFunctionType>log10</PixelFunctionType>
<SourceTransferType>CFloat64</SourceTransferType>
<SimpleSource>
<SourceFilename relativeToVRT="1">cint_sar.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>
File renamed without changes.
86 changes: 85 additions & 1 deletion autotest/gcore/gdal_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,88 @@ def stats_square_shape():

return 'success'

###############################################################################
# Test when nodata = FLT_MIN (#6578)

def stats_flt_min():

shutil.copyfile('data/flt_min.tif', 'tmp/flt_min.tif')
try:
os.remove('tmp/flt_min.tif.aux.xml')
except:
pass

ds = gdal.Open('tmp/flt_min.tif')
stats = ds.GetRasterBand(1).GetStatistics(0, 1)
nodata = ds.GetRasterBand(1).GetNoDataValue()
ds = None

os.remove('tmp/flt_min.tif.aux.xml')

ds = gdal.Open('tmp/flt_min.tif')
minmax = ds.GetRasterBand(1).ComputeRasterMinMax()
ds = None

os.remove('tmp/flt_min.tif')

if nodata != 1.17549435082228751e-38:
gdaltest.post_reason('did not get expected nodata')
print("%.18g" % nodata)
return 'fail'

if stats != [0.0, 1.0, 0.33333333333333337, 0.47140452079103168]:
gdaltest.post_reason('did not get expected stats')
print(stats)
return 'fail'

if minmax != (0.0, 1.0):
gdaltest.post_reason('did not get expected minmax')
print(minmax)
return 'fail'

return 'success'

###############################################################################
# Test when nodata = DBL_MIN (#6578)

def stats_dbl_min():

shutil.copyfile('data/dbl_min.tif', 'tmp/dbl_min.tif')
try:
os.remove('tmp/dbl_min.tif.aux.xml')
except:
pass

ds = gdal.Open('tmp/dbl_min.tif')
stats = ds.GetRasterBand(1).GetStatistics(0, 1)
nodata = ds.GetRasterBand(1).GetNoDataValue()
ds = None

os.remove('tmp/dbl_min.tif.aux.xml')

ds = gdal.Open('tmp/dbl_min.tif')
minmax = ds.GetRasterBand(1).ComputeRasterMinMax()
ds = None

os.remove('tmp/dbl_min.tif')

if nodata != 2.22507385850720138e-308:
gdaltest.post_reason('did not get expected nodata')
print("%.18g" % nodata)
return 'fail'

if stats != [0.0, 1.0, 0.33333333333333337, 0.47140452079103168]:
gdaltest.post_reason('did not get expected stats')
print(stats)
return 'fail'

if minmax != (0.0, 1.0):
gdaltest.post_reason('did not get expected minmax')
print(minmax)
return 'fail'

return 'success'

###############################################################################
# Run tests

Expand All @@ -431,7 +513,9 @@ def stats_square_shape():
stats_nodata_posinf_linux,
stats_nodata_posinf_msvc,
stats_stddev_huge_values,
stats_square_shape
stats_square_shape,
stats_flt_min,
stats_dbl_min
]

if __name__ == '__main__':
Expand Down
Loading

0 comments on commit a897355

Please sign in to comment.