-
Notifications
You must be signed in to change notification settings - Fork 653
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
[SEDONA-376] Add RS_SetValues #986
Conversation
docs/api/sql/Raster-operators.md
Outdated
```sql | ||
SELECT RS_BandAsArray( | ||
RS_SetValues( | ||
RS_AddBandAsArray( |
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.
This should be RS_AddBandFromArray
return setValues(raster, band, colX, rowY, width, height, values, false); | ||
} | ||
|
||
private static void ensureBand(GridCoverage2D raster, int band) throws IllegalArgumentException { |
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.
Isn't this ensureBand function implemented at several places? If so, we need to share it across functions.
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.
Sure! I will make one implementation public and use that.
docs/api/sql/Raster-operators.md
Outdated
@@ -963,6 +963,47 @@ Output: | |||
-3.000000 | |||
``` | |||
|
|||
### RS_SetValues | |||
|
|||
Introduction: Returns raster with new values for specified pixels for designated band. |
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.
Please clearly explain how this setValue works. It should cover the region specified by the min point from colX and rowY.
* @throws IllegalArgumentException | ||
*/ | ||
public static void ensureBand(GridCoverage2D raster, int band) throws IllegalArgumentException { | ||
if (band > RasterAccessors.numBands(raster)) { |
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.
This should also check if the band is 1-indexed, e.g., band cannot < 1
for (int j = rowY; j < rowY + height; j++) { | ||
for (int i = colX; i < colX + width; i++) { | ||
double[] pixel = rasterCopied.getPixel(i, j, (double[]) null); | ||
if (keepNoData && noDataValue != pixel[band - 1]) { |
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.
A better implementation of this if condition is
if (keepNoData && noDataValue == pixel[band-1]) {
continue;
}
else pixel[band-1] = values[iterator]
Did you read the Contributor Guide?
Is this PR related to a JIRA ticket?
[SEDONA-XXX] my subject
.What changes were proposed in this PR?
How was this patch tested?
Did this PR include necessary documentation updates?