Skip to content
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

Merged
merged 14 commits into from
Aug 26, 2023
Merged

Conversation

furqaankhan
Copy link
Contributor

Did you read the Contributor Guide?

Is this PR related to a JIRA ticket?

What changes were proposed in this PR?

  • Add RS_SetValues

How was this patch tested?

  • Passed added tests

Did this PR include necessary documentation updates?

  • Yes, I have updated the documentation update.

```sql
SELECT RS_BandAsArray(
RS_SetValues(
RS_AddBandAsArray(
Copy link
Member

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 {
Copy link
Member

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.

Copy link
Contributor Author

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.

@@ -963,6 +963,47 @@ Output:
-3.000000
```

### RS_SetValues

Introduction: Returns raster with new values for specified pixels for designated band.
Copy link
Member

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)) {
Copy link
Member

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]) {
Copy link
Member

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]

@jiayuasu jiayuasu merged commit 976f52a into apache:master Aug 26, 2023
39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants