Skip to content

Commit

Permalink
Merge branch 'master' of github.com:OSGeo/gdal
Browse files Browse the repository at this point in the history
* 'master' of github.com:OSGeo/gdal: (27 commits)
  OGR SQL: Support ISO-8601 literal dates with IN operator (OSGeo#3978) (fixes OSGeo#3977)
  CI Ubuntu 20.04: add pdfium dependency
  PDF: update PDFium dependency to pdfium/4538
  autotest/pyscripts/test_gdal_utils.py - add tests for ColorPalette and the correspondent gdal.ColorTable
  gdal-utils/osgeo_utils/auxiliary/color_table.py - color_table_from_color_palette - move the logic from get_color_table and handle the case of non-numeric palette
  gdal/swig/python/gdal-utils/osgeo_utils/auxiliary/color_palette.py - add support methods (color_entry_to_color, is_numeric), make 'ndv' an attribute to fix issues with creating gdal.ColorTable from ColorPalette
  Overview/rasterio: fix RMS on large Float32 values
  CI fedora: install libxslt-devel to fix lxml python package installation
  github action: fix Spatialite build
  Doc: Remove not needed percent signs
  Doc: typo
  ogr_flatgeobuf.py: test reading SRS using COORDINATEMETADATA[]
  FlatGeobuf: accept COORDINATEMETADATA[] construct on reading but ignore it (backportable commit)
  netCDF: put Sentinel5 /PRODUCT/SUPPORT_DATA attributes in a json:SUPPORT_DATA metadata domain
  netCDF multidim: deal with Sentinel5 verbose metadata
  gdalmdiminfo: deal properly with GEDTST_JSON subtype
  Multidim API: add JSON as a possible subtype of (string) extended data type
  netCDF multidim: avoid error message if units attribute on a variable is not of type string
  netCDF: expose Sentinel5 verbose metadata in json:ISO_METADATA/ESA_METADATA/EOP_METADATA/QA_STATISTICS/GRANULE_DESCRIPTION/ALGORITHM_SETTINGS metadata domains
  gdalgeoloc: improve backmap hole filling
  ...
  • Loading branch information
a0x8o committed Jun 10, 2022
1 parent 1ff20a7 commit ba1e26a
Show file tree
Hide file tree
Showing 28 changed files with 46,319 additions and 273 deletions.
4 changes: 4 additions & 0 deletions alg/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ ifeq ($(QHULL_SETTING),internal)
CPPFLAGS := -DINTERNAL_QHULL $(CPPFLAGS)
endif

<<<<<<< HEAD:alg/GNUmakefile
CPPFLAGS := -iquote ../frmts/vrt -iquote ../frmts/mem $(CPPFLAGS) $(OPENCL_FLAGS) $(PROJ_FLAGS) $(PROJ_INCLUDE) -iquote marching_squares
=======
CPPFLAGS := -I../frmts/vrt -I../frmts/mem $(CPPFLAGS) $(OPENCL_FLAGS) $(PROJ_FLAGS) $(PROJ_INCLUDE) -Imarching_squares
>>>>>>> 2ac37d0503 (Merge branch 'master' of github.com:OSGeo/gdal):gdal/alg/GNUmakefile

CXXFLAGS := $(WARN_EFFCPLUSPLUS) $(WARN_OLD_STYLE_CAST) $(CXXFLAGS)

Expand Down
24 changes: 24 additions & 0 deletions alg/gdal_alg_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ void CPL_DLL * GDALCloneTransformer( void *pTransformerArg );
void GDALRefreshGenImgProjTransformer(void* hTransformArg);
void GDALRefreshApproxTransformer(void* hTransformArg);

<<<<<<< HEAD:alg/gdal_alg_priv.h
int GDALTransformLonLatToDestGenImgProjTransformer(void* hTransformArg,
double* pdfX,
double* pdfY);
Expand All @@ -188,11 +189,14 @@ bool GDALTransformIsTranslationOnPixelBoundaries(GDALTransformerFunc pfnTransfor
void *pTransformerArg);

typedef struct _CPLQuadTree CPLQuadTree;
=======
>>>>>>> 2ac37d0503 (Merge branch 'master' of github.com:OSGeo/gdal):gdal/alg/gdal_alg_priv.h

typedef struct {
GDALTransformerInfo sTI;

bool bReversed;
<<<<<<< HEAD:alg/gdal_alg_priv.h
double dfOversampleFactor;

// Map from target georef coordinates back to geolocation array
Expand All @@ -203,6 +207,16 @@ typedef struct {

bool bUseArray;
void *pAccessors;
=======

// Map from target georef coordinates back to geolocation array
// pixel line coordinates. Built only if needed.
size_t nBackMapWidth;
size_t nBackMapHeight;
double adfBackMapGeoTransform[6]; // Maps georef to pixel/line.
float *pafBackMapX;
float *pafBackMapY;
>>>>>>> 2ac37d0503 (Merge branch 'master' of github.com:OSGeo/gdal):gdal/alg/gdal_alg_priv.h

// Geolocation bands.
GDALDatasetH hDS_X;
Expand All @@ -212,8 +226,15 @@ typedef struct {
int bSwapXY;

// Located geolocation data.
<<<<<<< HEAD:alg/gdal_alg_priv.h
int nGeoLocXSize;
int nGeoLocYSize;
=======
size_t nGeoLocXSize;
size_t nGeoLocYSize;
double *padfGeoLocX;
double *padfGeoLocY;
>>>>>>> 2ac37d0503 (Merge branch 'master' of github.com:OSGeo/gdal):gdal/alg/gdal_alg_priv.h
double dfMinX;
double dfYAtMinX;
double dfMinY;
Expand All @@ -232,10 +253,13 @@ typedef struct {
double dfLINE_OFFSET;
double dfLINE_STEP;

<<<<<<< HEAD:alg/gdal_alg_priv.h
bool bOriginIsTopLeftCorner;
bool bGeographicSRSWithMinus180Plus180LongRange;
CPLQuadTree *hQuadTree;

=======
>>>>>>> 2ac37d0503 (Merge branch 'master' of github.com:OSGeo/gdal):gdal/alg/gdal_alg_priv.h
char ** papszGeolocationInfo;

} GDALGeoLocTransformInfo;
Expand Down
74 changes: 74 additions & 0 deletions alg/gdaltransformer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ typedef struct {
} GDALGenImgProjTransformInfo;

/************************************************************************/
<<<<<<< HEAD:alg/gdaltransformer.cpp
/* ==================================================================== */
/* GDALReprojectionTransformer */
/* ==================================================================== */
Expand All @@ -135,6 +136,8 @@ struct GDALReprojectionTransformInfo
};

/************************************************************************/
=======
>>>>>>> 2ac37d0503 (Merge branch 'master' of github.com:OSGeo/gdal):gdal/alg/gdaltransformer.cpp
/* GDALTransformFunc */
/* */
/* Documentation for GDALTransformFunc typedef. */
Expand Down Expand Up @@ -991,6 +994,73 @@ GDALSuggestedWarpOutput2( GDALDatasetH hSrcDS,
}
}

/* -------------------------------------------------------------------- */
/* Special case for geolocation array, to quickly find the bounds. */
/* -------------------------------------------------------------------- */
bool bIsGeographicCoords = false;
if( pfnTransformer == GDALGenImgProjTransform )
{
const GDALGenImgProjTransformInfo* pGIPTI =
static_cast<const GDALGenImgProjTransformInfo*>(pTransformArg);
if( pGIPTI->pSrcTransformer == GDALGeoLocTransform &&
pGIPTI->pDstTransformer == nullptr &&
pGIPTI->adfDstGeoTransform[0] == 0 &&
pGIPTI->adfDstGeoTransform[1] == 1 &&
pGIPTI->adfDstGeoTransform[2] == 0 &&
pGIPTI->adfDstGeoTransform[3] == 0 &&
pGIPTI->adfDstGeoTransform[4] == 0 &&
pGIPTI->adfDstGeoTransform[5] == 1 )
{
const GDALGeoLocTransformInfo* pGLTI =
static_cast<const GDALGeoLocTransformInfo*>(pGIPTI->pSrcTransformArg);

if( pGIPTI->pReproject == nullptr )
{
const char* pszGLSRS = CSLFetchNameValue(pGLTI->papszGeolocationInfo, "SRS");
if( pszGLSRS == nullptr )
{
bIsGeographicCoords = true;
}
else
{
OGRSpatialReference oSRS;
if( oSRS.SetFromUserInput(pszGLSRS) == OGRERR_NONE &&
oSRS.IsGeographic() )
{
bIsGeographicCoords = true;
}
}
}

for( const auto& xy: {
std::pair<double, double>(pGLTI->dfMinX, pGLTI->dfYAtMinX),
std::pair<double, double>(pGLTI->dfXAtMinY, pGLTI->dfMinY),
std::pair<double, double>(pGLTI->dfMaxX, pGLTI->dfYAtMaxX),
std::pair<double, double>(pGLTI->dfXAtMaxY, pGLTI->dfMaxY) } )
{
double x = xy.first;
double y = xy.second;
if( pGLTI->bSwapXY )
{
std::swap(x, y);
}
double xOut = std::numeric_limits<double>::quiet_NaN();
double yOut = std::numeric_limits<double>::quiet_NaN();
if( pGIPTI->pReproject == nullptr ||
pGIPTI->pReproject(pGIPTI->pReprojectArg, false, 1,
&x, &y, nullptr, nullptr) )
{
xOut = x;
yOut = y;
}
dfMinXOut = std::min(dfMinXOut, xOut);
dfMinYOut = std::min(dfMinYOut, yOut);
dfMaxXOut = std::max(dfMaxXOut, xOut);
dfMaxYOut = std::max(dfMaxYOut, yOut);
}
}
}

/* -------------------------------------------------------------------- */
/* Compute the distance in "georeferenced" units from the top */
/* corner of the transformed input image to the bottom left */
Expand Down Expand Up @@ -1104,8 +1174,12 @@ GDALSuggestedWarpOutput2( GDALDatasetH hSrcDS,
/* Recompute some bounds so that all return values are consistent */
/* -------------------------------------------------------------------- */
double dfMaxXOutNew = dfMinXOut + (*pnPixels) * dfPixelSizeX;
<<<<<<< HEAD:alg/gdaltransformer.cpp
if( bIsGeographicCoords &&
((dfMaxXOut <= 180 && dfMaxXOutNew > 180) || dfMaxXOut == 180) )
=======
if( bIsGeographicCoords && dfMaxXOut <= 180 && dfMaxXOutNew > 180 )
>>>>>>> 2ac37d0503 (Merge branch 'master' of github.com:OSGeo/gdal):gdal/alg/gdaltransformer.cpp
{
dfMaxXOut = 180;
dfPixelSizeX = (dfMaxXOut - dfMinXOut) / *pnPixels;
Expand Down
4 changes: 4 additions & 0 deletions apps/gdalmdiminfo_lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,11 @@ static void SerializeJSON(const CPLJSONObject& obj,

case CPLJSONObject::Type::Long:
{
<<<<<<< HEAD:apps/gdalmdiminfo_lib.cpp
serializer.Add( static_cast<int64_t>(obj.ToLong()) );
=======
serializer.Add( obj.ToLong() );
>>>>>>> 2ac37d0503 (Merge branch 'master' of github.com:OSGeo/gdal):gdal/apps/gdalmdiminfo_lib.cpp
break;
}

Expand Down
31 changes: 31 additions & 0 deletions autotest/gcore/geoloc.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@
###############################################################################

import array
<<<<<<< HEAD
import random
from osgeo import gdal, osr
=======
from osgeo import gdal
>>>>>>> 2ac37d0503 (Merge branch 'master' of github.com:OSGeo/gdal)

import gdaltest
import pytest
Expand All @@ -42,16 +46,24 @@

def test_geoloc_1():

<<<<<<< HEAD
tst = gdaltest.GDALTest('VRT', 'warpsst.vrt', 1, 63034)
=======
tst = gdaltest.GDALTest('VRT', 'warpsst.vrt', 1, 61957)
>>>>>>> 2ac37d0503 (Merge branch 'master' of github.com:OSGeo/gdal)
return tst.testOpen(check_filelist=False)


###############################################################################
# Test that we take into account the min/max of the geoloc arrays


<<<<<<< HEAD
@pytest.mark.parametrize("use_temp_datasets", ['YES', 'NO'])
def test_geoloc_bounds(use_temp_datasets):
=======
def test_geoloc_bounds():
>>>>>>> 2ac37d0503 (Merge branch 'master' of github.com:OSGeo/gdal)

lon_ds = gdal.GetDriverByName('GTiff').Create('/vsimem/lon.tif', 360, 1, 1, gdal.GDT_Float32)
lon_ds.WriteRaster(0, 0, 360, 1, array.array('f', [91 + 0.5 * x for x in range(178)] + [-179.9 + 0.5 * x for x in range(182)]))
Expand All @@ -70,12 +82,21 @@ def test_geoloc_bounds(use_temp_datasets):
'X_DATASET': '/vsimem/lon.tif',
'X_BAND' : '1',
'Y_DATASET': '/vsimem/lat.tif',
<<<<<<< HEAD
'Y_BAND' : '1'
}
ds.SetMetadata(md, 'GEOLOCATION')
with gdaltest.config_option('GDAL_GEOLOC_USE_TEMP_DATASETS', use_temp_datasets):
warped_ds = gdal.Warp('', ds, format='MEM')
assert warped_ds
=======
'Y_BAND' : '1',
'SRS': 'GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AXIS["Latitude",NORTH],AXIS["Longitude",EAST],AUTHORITY["EPSG","4326"]]'
}
ds.SetMetadata(md, 'GEOLOCATION')
warped_ds = gdal.Warp('', ds, format='MEM')
assert warped_ds
>>>>>>> 2ac37d0503 (Merge branch 'master' of github.com:OSGeo/gdal)

gdal.Unlink('/vsimem/lon.tif')
gdal.Unlink('/vsimem/lat.tif')
Expand All @@ -88,8 +109,12 @@ def test_geoloc_bounds(use_temp_datasets):
# Test that the line filling logic works


<<<<<<< HEAD
@pytest.mark.parametrize("use_temp_datasets", ['YES', 'NO'])
def test_geoloc_fill_line(use_temp_datasets):
=======
def test_geoloc_fill_line():
>>>>>>> 2ac37d0503 (Merge branch 'master' of github.com:OSGeo/gdal)


ds = gdal.GetDriverByName('MEM').Create('', 200, 372)
Expand All @@ -106,6 +131,7 @@ def test_geoloc_fill_line(use_temp_datasets):
}
ds.SetMetadata(md, 'GEOLOCATION')
ds.GetRasterBand(1).Fill(1)
<<<<<<< HEAD
with gdaltest.config_option('GDAL_GEOLOC_USE_TEMP_DATASETS', use_temp_datasets):
warped_ds = gdal.Warp('', ds, format='MEM')
assert warped_ds
Expand Down Expand Up @@ -326,3 +352,8 @@ def check_point(x,y):

gdal.Unlink('/vsimem/lon.tif')
gdal.Unlink('/vsimem/lat.tif')
=======
warped_ds = gdal.Warp('', ds, format='MEM')
assert warped_ds
assert warped_ds.GetRasterBand(1).Checksum() == 25798
>>>>>>> 2ac37d0503 (Merge branch 'master' of github.com:OSGeo/gdal)
4 changes: 4 additions & 0 deletions autotest/gcore/rasterio.py
Original file line number Diff line number Diff line change
Expand Up @@ -1176,7 +1176,11 @@ def test_rasterio_rms_halfsize_downsampling_float32():
if math.isnan(expected[i]):
assert math.isnan(got[i])
else:
<<<<<<< HEAD
assert got[i] == pytest.approx(expected[i], rel=1e-7), i
=======
assert got[i] == pytest.approx(expected[i], rel=1e-7)
>>>>>>> 2ac37d0503 (Merge branch 'master' of github.com:OSGeo/gdal)

ds.BuildOverviews('RMS', [2])
ovr_data = ds.GetRasterBand(1).GetOverview(0).ReadRaster()
Expand Down
9 changes: 9 additions & 0 deletions autotest/gdrivers/netcdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4882,6 +4882,12 @@ def test_netcdf_open_coords_no_georef_indexing_variables():

def test_netcdf_metadata_sentinel5():

<<<<<<< HEAD
=======
if not gdaltest.netcdf_drv_has_nc4:
pytest.skip()

>>>>>>> 2ac37d0503 (Merge branch 'master' of github.com:OSGeo/gdal)
ds = gdal.Open('data/netcdf/fake_ISO_METADATA.nc')
assert ds is not None
assert "json:ISO_METADATA" in ds.GetMetadataDomainList()
Expand Down Expand Up @@ -4923,6 +4929,7 @@ def test_netcdf_metadata_sentinel5():
assert j['attributes']['ISO_METADATA'] == expected


<<<<<<< HEAD
###############################################################################
# Test opening a file with particular georeferencing encoding

Expand Down Expand Up @@ -5245,6 +5252,8 @@ def test_netcdf_read_geogcrs_component_names():
assert srs.GetAttrValue('GEOGCS|PRIMEM') == 'Greenwich'


=======
>>>>>>> 2ac37d0503 (Merge branch 'master' of github.com:OSGeo/gdal)
def test_clean_tmp():
# [KEEP THIS AS THE LAST TEST]
# i.e. please do not add any tests after this one. Put new ones above.
Expand Down
4 changes: 4 additions & 0 deletions autotest/gdrivers/vrtwarp.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,11 @@ def test_vrtwarp_9():
vrtwarp_ds = gdal.Warp('tmp/vrtwarp_9.vrt', 'tmp/sstgeo.vrt', options='-overwrite -of VRT -geoloc')
assert vrtwarp_ds.GetRasterBand(1).GetOverviewCount() == 1
assert vrtwarp_ds.GetRasterBand(1).Checksum() == expected_cs_main
<<<<<<< HEAD
assert vrtwarp_ds.GetRasterBand(1).GetOverview(0).Checksum() == 62489, \
=======
assert vrtwarp_ds.GetRasterBand(1).GetOverview(0).Checksum() == 63696, \
>>>>>>> 2ac37d0503 (Merge branch 'master' of github.com:OSGeo/gdal)
(vrtwarp_ds.GetRasterBand(1).GetOverview(0).XSize, vrtwarp_ds.GetRasterBand(1).GetOverview(0).YSize)
vrtwarp_ds = None

Expand Down
6 changes: 6 additions & 0 deletions autotest/ogr/ogr_flatgeobuf.py
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,7 @@ def test_ogr_flatgeobuf_ossfuzz_bug_29462():


###############################################################################
<<<<<<< HEAD
# Check that we don't crash or leak


Expand All @@ -828,6 +829,8 @@ def test_ogr_flatgeobuf_read_invalid_geometries(filename):
pass

###############################################################################
=======
>>>>>>> 2ac37d0503 (Merge branch 'master' of github.com:OSGeo/gdal)


def test_ogr_flatgeobuf_read_coordinate_metadata_wkt():
Expand All @@ -837,6 +840,7 @@ def test_ogr_flatgeobuf_read_coordinate_metadata_wkt():
got_srs = lyr.GetSpatialRef()
assert got_srs is not None
assert got_srs.IsGeographic()
<<<<<<< HEAD


###############################################################################
Expand Down Expand Up @@ -912,3 +916,5 @@ def test_ogr_flatgeobuf_invalid_output_filename():
with gdaltest.error_handler():
assert ds.CreateLayer('foo') is None

=======
>>>>>>> 2ac37d0503 (Merge branch 'master' of github.com:OSGeo/gdal)
Loading

0 comments on commit ba1e26a

Please sign in to comment.