Skip to content

Commit

Permalink
Merge pull request OSGeo#3 from OSGeo/master
Browse files Browse the repository at this point in the history
rebase
  • Loading branch information
lucianpls authored Sep 11, 2020
2 parents 50ae810 + feb7ccf commit a1b2b0c
Show file tree
Hide file tree
Showing 203 changed files with 8,577 additions and 9,693 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/ubuntu_20.04.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ jobs:
- name: Build
run: docker build -f .github/workflows/ubuntu_20.04/Dockerfile -t gdal .

- name: Run tests
- name: Run pytest
# --security-opt seccomp=unconfined, so that the userfaulfd syscall is available
run: docker run --security-opt seccomp=unconfined --rm gdal sh -c "cd /build/autotest && pip3 install -U -r requirements.txt && pytest"

- name: Run SWIG C# tests
run: docker run --rm gdal sh -c "cd /build/gdal/swig/csharp && make && make && make test"
3 changes: 2 additions & 1 deletion .github/workflows/ubuntu_20.04/build-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ DEBIAN_FRONTEND=noninteractive apt-get install -y --fix-missing --no-install-rec
libcfitsio-dev openjdk-8-jdk libzstd-dev \
libpq-dev libssl-dev libboost-dev \
autoconf automake bash-completion libarmadillo-dev \
libopenexr-dev libheif-dev
libopenexr-dev libheif-dev \
mono-mcs libmono-system-drawing4.0-cil

# Build likbkea
KEA_VERSION=1.4.13
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/ubuntu_20.04/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@ make "-j$(nproc)" USER_DEFS=-Werror
make install "-j$(nproc)"
ldconfig

cd ../autotest/cpp
make "-j$(nproc)"
(cd ../autotest/cpp && make "-j$(nproc)")

(cd ./swig/csharp && make generate)
2 changes: 1 addition & 1 deletion .github/workflows/windows_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
platform: ${{ matrix.platform }}
PROJ_BRANCH: "${{ matrix.PROJ_BRANCH }}"
APPVEYOR: true # to skip some tests
PYTHON_VERSION: "3.7.8"
PYTHON_VERSION: "3.7.9"

steps:

Expand Down
62 changes: 0 additions & 62 deletions autotest/alg/tps.py

This file was deleted.

4 changes: 3 additions & 1 deletion autotest/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@

# These files may be non-importable, and don't contain tests anyway.
# So we skip searching them during test collection.
collect_ignore = ["kml_generate_test_files.py", "gdrivers/netcdf_cfchecks.py"]
collect_ignore = ["kml_generate_test_files.py",
"gdrivers/netcdf_cfchecks.py",
"gdrivers/generate_bag.py"]

# we set ECW to not resolve projection and datum strings to get 3.x behavior.
gdal.SetConfigOption("ECW_DO_NOT_RESOLVE_DATUM_PROJECTION", "YES")
Expand Down
59 changes: 57 additions & 2 deletions autotest/cpp/test_gdal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1417,7 +1417,7 @@ namespace tut

// Inline JSON with minimal structure
{
auto poTMS = gdal::TileMatrixSet::parse("{\"type\": \"TileMatrixSetType\", \"tileMatrix\": [{ \"topLeftCorner\": [-180, 90],\"scaleDenominator\":1.0}] }");
auto poTMS = gdal::TileMatrixSet::parse("{\"type\": \"TileMatrixSetType\", \"supportedCRS\": \"http://www.opengis.net/def/crs/OGC/1.3/CRS84\", \"tileMatrix\": [{ \"topLeftCorner\": [-180, 90],\"scaleDenominator\":1.0}] }");
ensure( poTMS != nullptr );
ensure( poTMS->haveAllLevelsSameTopLeft() );
ensure( poTMS->haveAllLevelsSameTileSize() );
Expand All @@ -1428,7 +1428,7 @@ namespace tut
// Invalid scaleDenominator
{
CPLPushErrorHandler(CPLQuietErrorHandler);
ensure( gdal::TileMatrixSet::parse("{\"type\": \"TileMatrixSetType\", \"tileMatrix\": [{ \"topLeftCorner\": [-180, 90],\"scaleDenominator\":0.0}] }") == nullptr);
ensure( gdal::TileMatrixSet::parse("{\"type\": \"TileMatrixSetType\", \"supportedCRS\": \"http://www.opengis.net/def/crs/OGC/1.3/CRS84\", \"tileMatrix\": [{ \"topLeftCorner\": [-180, 90],\"scaleDenominator\":0.0}] }") == nullptr);
CPLPopErrorHandler();
}

Expand Down Expand Up @@ -1567,6 +1567,61 @@ namespace tut
ensure_equals( vmw.mMinTileRow, 0 );
ensure_equals( vmw.mMaxTileRow, 1 );
}

{
auto poTMS = gdal::TileMatrixSet::parse(
"{"
" \"identifier\" : \"CDBGlobalGrid\","
" \"title\" : \"CDBGlobalGrid\","
" \"boundingBox\" : {"
" \"crs\" : \"http://www.opengis.net/def/crs/EPSG/0/4326\","
" \"lowerCorner\" : ["
" -90,"
" -180"
" ],"
" \"upperCorner\" : ["
" 90,"
" 180"
" ]"
" },"
" \"supportedCRS\" : \"http://www.opengis.net/def/crs/EPSG/0/4326\","
" \"wellKnownScaleSet\" : \"http://www.opengis.net/def/wkss/OGC/1.0/CDBGlobalGrid\","
" \"tileMatrices\" : ["
" {"
" \"identifier\" : \"-10\","
" \"scaleDenominator\" : 397569609.975977063179,"
" \"matrixWidth\" : 360,"
" \"matrixHeight\" : 180,"
" \"tileWidth\" : 1,"
" \"tileHeight\" : 1,"
" \"topLeftCorner\" : ["
" 90,"
" -180"
" ],"
" \"variableMatrixWidths\" : ["
" {"
" \"coalesce\" : 12,"
" \"minTileRow\" : 0,"
" \"maxTileRow\" : 0"
" },"
" {"
" \"coalesce\" : 12,"
" \"minTileRow\" : 179,"
" \"maxTileRow\" : 179"
" }"
" ]"
" }"
" ]"
"}");
ensure( poTMS != nullptr );
ensure_equals( poTMS->tileMatrixList().size(), 1U );
const auto &tm = poTMS->tileMatrixList()[0];
ensure_equals( tm.mVariableMatrixWidthList.size(), 2U );
const auto& vmw = tm.mVariableMatrixWidthList[0];
ensure_equals( vmw.mCoalesce, 12 );
ensure_equals( vmw.mMinTileRow, 0 );
ensure_equals( vmw.mMaxTileRow, 0 );
}
}

} // namespace tut
12 changes: 12 additions & 0 deletions autotest/cpp/test_osr_set_proj_search_paths.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,18 @@ int main()
auto t1 = CPLCreateJoinableThread(func1, nullptr);
CPLJoinThread(t1);

{
const char* const apszDummyPaths[] = { "/i/am/dummy", nullptr };
OSRSetPROJSearchPaths(apszDummyPaths);
auto tokens2 = OSRGetPROJSearchPaths();
if( strcmp(tokens2[0], "/i/am/dummy") != 0 )
{
fprintf(stderr, "failure not expected (5)\n");
exit(1);
}
CSLDestroy(tokens2);
}

// Use OSRSetPROJSearchPaths to restore search paths
OSRSetPROJSearchPaths(tokens);

Expand Down
Binary file added autotest/gcore/data/byte_gcp_pixelispoint.tif
Binary file not shown.
15 changes: 13 additions & 2 deletions autotest/gcore/gdal_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -701,8 +701,19 @@ def test_stats_float32_with_nodata_slightly_above_float_max():
'did not get expected stats'


###############################################################################
# Run tests
def test_stats_clear():

filename = '/vsimem/out.tif'
gdal.Translate(filename, 'data/byte.tif')
ds = gdal.Open(filename)
assert ds.GetRasterBand(1).GetStatistics(False, False) == [0,0,0,-1]
assert ds.GetRasterBand(1).ComputeStatistics(False) != [0,0,0,-1]

ds = gdal.Open(filename)
assert ds.GetRasterBand(1).GetStatistics(False, False) != [0,0,0,-1]
ds.ClearStatistics()

ds = gdal.Open(filename)
assert ds.GetRasterBand(1).GetStatistics(False, False) == [0,0,0,-1]

gdal.GetDriverByName('GTiff').Delete(filename)
27 changes: 27 additions & 0 deletions autotest/gcore/tiff_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -802,6 +802,33 @@ def test_tiff_read_geomatrix():

gdal.SetConfigOption('GTIFF_POINT_GEO_IGNORE', None)

###############################################################################
# Test reading a GeoTIFF file with tiepoints in PixelIsPoint format.


def test_tiff_read_tiepoints_pixelispoint():

ds = gdal.Open('data/byte_gcp_pixelispoint.tif')
assert ds.GetMetadataItem('AREA_OR_POINT') == 'Point'
assert ds.GetGCPCount() == 4
gcp = ds.GetGCPs()[0]
assert (gcp.GCPPixel == pytest.approx(0.5, abs=1e-5) and \
gcp.GCPLine == pytest.approx(0.5, abs=1e-5) and \
gcp.GCPX == pytest.approx(-180, abs=1e-5) and \
gcp.GCPY == pytest.approx(90, abs=1e-5) and \
gcp.GCPZ == pytest.approx(0, abs=1e-5))

with gdaltest.config_option('GTIFF_POINT_GEO_IGNORE', 'YES'):
ds = gdal.Open('data/byte_gcp_pixelispoint.tif')
assert ds.GetMetadataItem('AREA_OR_POINT') == 'Point'
assert ds.GetGCPCount() == 4
gcp = ds.GetGCPs()[0]
assert (gcp.GCPPixel == pytest.approx(0, abs=1e-5) and \
gcp.GCPLine == pytest.approx(0, abs=1e-5) and \
gcp.GCPX == pytest.approx(-180, abs=1e-5) and \
gcp.GCPY == pytest.approx(90, abs=1e-5) and \
gcp.GCPZ == pytest.approx(0, abs=1e-5))

###############################################################################
# Test that we don't crash when reading a TIFF with corrupted GeoTIFF tags

Expand Down
34 changes: 34 additions & 0 deletions autotest/gcore/tiff_write.py
Original file line number Diff line number Diff line change
Expand Up @@ -3568,6 +3568,40 @@ def test_tiff_write_98():

gdaltest.tiff_drv.Delete('tmp/test_98.tif')

###############################################################################
# Create a rotated geotiff file (uses a geomatrix) with - PixelIsPoint


def test_tiff_write_tiepoints_pixelispoint():

tmpfilename = '/vsimem/test_tiff_write_tiepoints_pixelispoint.tif'

gdal.Translate(tmpfilename, 'data/byte_gcp_pixelispoint.tif')
ds = gdal.Open(tmpfilename)
assert ds.GetMetadataItem('AREA_OR_POINT') == 'Point'
assert ds.GetGCPCount() == 4
gcp = ds.GetGCPs()[0]
assert (gcp.GCPPixel == pytest.approx(0.5, abs=1e-5) and \
gcp.GCPLine == pytest.approx(0.5, abs=1e-5) and \
gcp.GCPX == pytest.approx(-180, abs=1e-5) and \
gcp.GCPY == pytest.approx(90, abs=1e-5) and \
gcp.GCPZ == pytest.approx(0, abs=1e-5))


with gdaltest.config_option('GTIFF_POINT_GEO_IGNORE', 'YES'):
gdal.Translate(tmpfilename, 'data/byte_gcp_pixelispoint.tif')
ds = gdal.Open(tmpfilename)
assert ds.GetMetadataItem('AREA_OR_POINT') == 'Point'
assert ds.GetGCPCount() == 4
gcp = ds.GetGCPs()[0]
assert (gcp.GCPPixel == pytest.approx(0, abs=1e-5) and \
gcp.GCPLine == pytest.approx(0, abs=1e-5) and \
gcp.GCPX == pytest.approx(-180, abs=1e-5) and \
gcp.GCPY == pytest.approx(90, abs=1e-5) and \
gcp.GCPZ == pytest.approx(0, abs=1e-5))

gdal.Unlink(tmpfilename)

###############################################################################
# Create copy into a RGB JPEG-IN-TIFF (#3887)

Expand Down
2 changes: 2 additions & 0 deletions autotest/gcore/transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,8 @@ def test_transformer_12():

tr = gdal.Transformer(ds, None, ['METHOD=GCP_TPS'])
assert tr is not None
(success, pnt) = tr.TransformPoint(0, 0, 0)
assert success and pnt[0] == pytest.approx(0, abs=1e-7) and pnt[1] == pytest.approx(0, abs=1e-7)

ds = gdal.Open("""
<VRTDataset rasterXSize="20" rasterYSize="20">
Expand Down
54 changes: 54 additions & 0 deletions autotest/gcore/vrt_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -1356,3 +1356,57 @@ def test_vrt_source_no_dstrect():
ds = None
gdal.Unlink(filename)


def test_vrt_dataset_rasterio_recursion_detection():

gdal.FileFromMemBuffer('/vsimem/test.vrt', """<VRTDataset rasterXSize="20" rasterYSize="20">
<VRTRasterBand dataType="Byte" band="1">
<SimpleSource>
<SourceFilename relativeToVRT="0">data/byte.tif</SourceFilename>
<SourceBand>1</SourceBand>
<SourceProperties RasterXSize="20" RasterYSize="20" DataType="Byte" BlockXSize="20" BlockYSize="20" />
<SrcRect xOff="0" yOff="0" xSize="20" ySize="20" />
<DstRect xOff="0" yOff="0" xSize="20" ySize="20" />
</SimpleSource>
<Overview>
<SourceFilename relativeToVRT="0">/vsimem/test.vrt</SourceFilename>
<SourceBand>1</SourceBand>
</Overview>
</VRTRasterBand>
</VRTDataset>""")

ds = gdal.Open('/vsimem/test.vrt')
with gdaltest.error_handler():
ds.ReadRaster(0,0,20,20,10,10)
gdal.Unlink('/vsimem/test.vrt')

def test_vrt_dataset_rasterio_recursion_detection_does_not_trigger():

vrt_text = """<VRTDataset rasterXSize="50" rasterYSize="50">
<VRTRasterBand dataType="Byte" band="1">
<ColorInterp>Red</ColorInterp>
<ComplexSource>
<SourceFilename>data/rgbsmall.tif</SourceFilename>
<SourceBand>1</SourceBand>
</ComplexSource>
</VRTRasterBand>
<VRTRasterBand dataType="Byte" band="2">
<ColorInterp>Green</ColorInterp>
<ComplexSource>
<SourceFilename>data/rgbsmall.tif</SourceFilename>
<SourceBand>2</SourceBand>
</ComplexSource>
</VRTRasterBand>
<VRTRasterBand dataType="Byte" band="3">
<ColorInterp>Blue</ColorInterp>
<ComplexSource>
<SourceFilename>data/rgbsmall.tif</SourceFilename>
<SourceBand>3</SourceBand>
</ComplexSource>
</VRTRasterBand>
</VRTDataset>"""
ds = gdal.Open(vrt_text)
got_data = ds.ReadRaster(0,0,50,50,25,25,resample_alg=gdal.GRIORA_Cubic)
ds = gdal.Open('data/rgbsmall.tif')
ref_data = ds.ReadRaster(0,0,50,50,25,25,resample_alg=gdal.GRIORA_Cubic)
assert got_data == ref_data
Loading

0 comments on commit a1b2b0c

Please sign in to comment.