-
Notifications
You must be signed in to change notification settings - Fork 129
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
RasterBand IO() fails to deduce buffer data type, aborts #43
Comments
This same type switch is used in Dataset IO() as well, so it will misbehave as well under the same conditions. |
This behaves as intended. Take notice at error message there:
Golang makes a difference between a slice and an array.
Slice is not an array, please consider reading https://golang.org/doc/effective_go.html#slices Even when you pass it, array is being copied, slice is passed by reference. It is possible to implement this also for arrays in Go via reflection, but this is not Go-way coding and the code itself will look ugly. |
Minor refactoring of this here - #51 to avoid code duplication. |
The type swtich at the top of RasterBand IO() (gdal.go:1130) used to guess the appropriate GDAL data type for the buffer fails if passed a sized array, aborting the IO() function and returning an error string.
This can be verified by using the examples/test_tiff code to try to write a dataset using this function. No data will be written.
The following code demonstrates the failure of a type switch in this situation. You can see that the reflect package gets it right, while the type switch fails to identify the type of the sized array buffer. However, if declared as an array of unknown size then assigned a slice the type switch will work as intended.
The text was updated successfully, but these errors were encountered: