Skip to content

Commit

Permalink
Add compatibility check in godalGridCreate, update test behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
pericles-tpt committed Sep 8, 2023
1 parent 3e9c76c commit b14a350
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
9 changes: 7 additions & 2 deletions godal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1696,10 +1696,15 @@ void test_godal_error_handling(cctx *ctx) {
void godalGridCreate(cctx *ctx, char *pszAlgorithm, GDALGridAlgorithm eAlgorithm, GUInt32 nPoints, const double *padfX, const double *padfY, const double *padfZ, double dfXMin,
double dfXMax, double dfYMin, double dfYMax, GUInt32 nXSize, GUInt32 nYSize, GDALDataType eType, void *pData) {
godalWrap(ctx);

CPLErr ret;
void *ppOptions;

if (!GDALHasTriangulation() && eAlgorithm == GGA_Linear) {
CPLError(CE_Failure, CPLE_AppDefined, "unable to run GGA_Linear algorithm, since GDAL built without QHull support");
godalUnwrap();
return;
}

void *ppOptions;
#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(3, 7, 0)
ret = GDALGridParseAlgorithmAndOptions(pszAlgorithm, &eAlgorithm, &ppOptions);
#else
Expand Down
12 changes: 10 additions & 2 deletions godal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"os"
"path"
"path/filepath"
"strings"
"syscall"
"testing"
"time"
Expand Down Expand Up @@ -3992,8 +3993,15 @@ func TestGridCreateLinear(t *testing.T) {
var gridCreateBindingPoints = make([]float64, outXSize*outYSize)
err = GridCreate("linear", xCoords, yCoords, zCoords, 0, 1, 0, 1, outXSize, outYSize, gridCreateBindingPoints)
if err != nil {
t.Error(err)
return
// Handles QHull error differently here, as it's a compatibility issue not a gridding error
isQhullError := strings.HasSuffix(err.Error(), "without QHull support")
if isQhullError {
t.Log(`Skipping test, GDAL was built without "Delaunay triangulation" support which is required for the "Linear" gridding algorithm`)
return
} else {
t.Error(err)
return
}
}

var (
Expand Down

0 comments on commit b14a350

Please sign in to comment.