-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add GDALViewshedGenerate binding #142
base: main
Are you sure you want to change the base?
Conversation
… > 3.10 (not sure about this approach...)
… compatible GDAL versions
… WILL run, but produces invalid test results
Question: Invalid test results across GDAL versionsI found in my testing that different versions of GDAL pass different sections of the test:
My solution for this is to return an error for any case where tests produce an invalid result, the current behaviour for the above is:
Do you prefer the approach I've implemented, which prevents the user from running |
… case in `TestViewshedCreationOptions`
@tbonfort I'm not sure if you're being notified about new PRs, but I'd really appreciate it if you could review this PR when you get the chance |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I had missed the notifications. LGTM after these few nitpicks.
#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(3, 1, 0) | ||
ret = GDALViewshedGenerate(bnd, pszDriverName, pszTargetRasterName, papszCreationOptions, dfObserverX, dfObserverY, dfObserverHeight, dfTargetHeight, dfVisibleVal, dfInvisibleVal, dfOutOfRangeVal, | ||
dfNoDataVal, dfCurvCoeff, GDALViewshedMode(eMode), dfMaxDistance, nullptr, nullptr, GDALViewshedOutputType(heightMode), nullptr); | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#endif | |
#else | |
CPLError(CE_Failure, CPLE_AppDefined, "Viewshed not implemented in gdal < 3.1"); | |
#endif |
// TODO: Should I put a 'warning' in the documentation for `Viewshed` instead of disallowing the last two configurations? | ||
if !CheckMinVersion(3, 1, 0) { | ||
return nil, errors.New("failed to run, 'viewshed' not supported on GDAL versions < 3.1.0") | ||
} else if !CheckMinVersion(3, 4, 2) { | ||
return nil, errors.New("cannot run 'viewshed' with GDAL version <= 3.4.1, as some tests produce invalid results under these conditions") | ||
} else if !CheckMinVersion(3, 10, 0) && heightMode == MinTargetHeightFromDem { | ||
return nil, errors.New("height mode CANNOT be `MinTargetHeightFromDem` when running a GDAL version < 3.10, as some tests produce invalid results under these conditions") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would just leave this section out, it is not godal's role to circumvent fixed bugs in gdal. A comment with a link to the gdal PR/issue numbers is sufficient I believe
if !CheckMinVersion(3, 1, 0) { | ||
_, err := Viewshed(Band{}, nil, "none", 1, 1, 0, 0, 255, 0, 0, -1, 0, MEdge, 0, Normal) | ||
assert.EqualError(t, err, "failed to run, 'viewshed' not supported on GDAL versions < 3.1.0") | ||
return | ||
} else if !CheckMinVersion(3, 4, 2) { | ||
_, err := Viewshed(Band{}, nil, "none", 1, 1, 0, 0, 255, 0, 0, -1, 0, MEdge, 0, Normal) | ||
assert.EqualError(t, err, "cannot run 'viewshed' with GDAL version <= 3.4.1, as some tests produce invalid results under these conditions") | ||
return | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these versions of gdal are too old, no need to test for this.
if !CheckMinVersion(3, 1, 0) { | |
_, err := Viewshed(Band{}, nil, "none", 1, 1, 0, 0, 255, 0, 0, -1, 0, MEdge, 0, Normal) | |
assert.EqualError(t, err, "failed to run, 'viewshed' not supported on GDAL versions < 3.1.0") | |
return | |
} else if !CheckMinVersion(3, 4, 2) { | |
_, err := Viewshed(Band{}, nil, "none", 1, 1, 0, 0, 255, 0, 0, -1, 0, MEdge, 0, Normal) | |
assert.EqualError(t, err, "cannot run 'viewshed' with GDAL version <= 3.4.1, as some tests produce invalid results under these conditions") | |
return | |
} |
if !CheckMinVersion(3, 1, 0) { | ||
_, err := Viewshed(Band{}, nil, "none", 1, 1, 0, 0, 255, 0, 0, -1, 0, MEdge, 0, Normal) | ||
assert.EqualError(t, err, "failed to run, 'viewshed' not supported on GDAL versions < 3.1.0") | ||
return | ||
} else if !CheckMinVersion(3, 4, 2) { | ||
_, err := Viewshed(Band{}, nil, "none", 1, 1, 0, 0, 255, 0, 0, -1, 0, MEdge, 0, Normal) | ||
assert.EqualError(t, err, "cannot run 'viewshed' with GDAL version <= 3.4.1, as some tests produce invalid results under these conditions") | ||
return | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these versions of gdal are too old, no need to test for this.
if !CheckMinVersion(3, 1, 0) { | |
_, err := Viewshed(Band{}, nil, "none", 1, 1, 0, 0, 255, 0, 0, -1, 0, MEdge, 0, Normal) | |
assert.EqualError(t, err, "failed to run, 'viewshed' not supported on GDAL versions < 3.1.0") | |
return | |
} else if !CheckMinVersion(3, 4, 2) { | |
_, err := Viewshed(Band{}, nil, "none", 1, 1, 0, 0, 255, 0, 0, -1, 0, MEdge, 0, Normal) | |
assert.EqualError(t, err, "cannot run 'viewshed' with GDAL version <= 3.4.1, as some tests produce invalid results under these conditions") | |
return | |
} |
GDALViewshedGenerate
bindingViewshed
go function (calls binding)TestViewshedSimpleHeight
to test the binding