You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@sedona.apache.org by "Kontinuation (via GitHub)" <gi...@apache.org> on 2025/03/17 14:37:45 UTC
[PR] [SEDONA-722] Fix precision loss problems caused by casting world coordinates from double to float [sedona]
Kontinuation opened a new pull request, #1860:
URL: https://github.com/apache/sedona/pull/1860
## Did you read the Contributor Guide?
- Yes, I have read the [Contributor Rules](https://sedona.apache.org/latest/community/rule/) and [Contributor Development Guide](https://sedona.apache.org/latest/community/develop/)
## Is this PR related to a ticket?
- Yes, and the PR name follows the format `[SEDONA-XXX] my subject`.
## What changes were proposed in this PR?
The world coordinates were silently casted from double to float when getting world coordinates from grid coordinates. This affects the precision of `RS_RasterToWorldCoord*`, `RS_PixelAsPolygon`, etc.
## How was this patch tested?
Updated the expected results of tests to more precise coordinates.
## Did this PR include necessary documentation updates?
- No, this PR does not affect any public API so no need to change the documentation.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@sedona.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [SEDONA-722] Fix precision loss problems caused by casting world coordinates from double to float [sedona]
Posted by "jiayuasu (via GitHub)" <gi...@apache.org>.
jiayuasu merged PR #1860:
URL: https://github.com/apache/sedona/pull/1860
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@sedona.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [SEDONA-722] Fix precision loss problems caused by casting world coordinates from double to float [sedona]
Posted by "Kontinuation (via GitHub)" <gi...@apache.org>.
Kontinuation commented on code in PR #1860:
URL: https://github.com/apache/sedona/pull/1860#discussion_r1998891395
##########
common/src/main/java/org/apache/sedona/common/utils/RasterUtils.java:
##########
@@ -467,10 +466,11 @@ public static AffineTransform2D translateAffineTransform(
public static Point2D getWorldCornerCoordinates(GridCoverage2D raster, int colX, int rowY)
throws TransformException {
+ Point2D.Double gridCoord = new DirectPosition2D(colX - 1, rowY - 1);
return raster
.getGridGeometry()
.getGridToCRS2D(PixelOrientation.UPPER_LEFT)
- .transform(new GridCoordinates2D(colX - 1, rowY - 1), null);
+ .transform(gridCoord, null);
Review Comment:
`GridCoordinates2D` is not a subclass of `Point2D.Double`, so the result of transform will be `Point2D.Float`: https://github.com/openjdk/jdk/blob/jdk-17%2B35/src/java.desktop/share/classes/java/awt/geom/AffineTransform.java#L2899-L2906. We explicitly use `Point2D.Double` here to avoid loss of precision.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@sedona.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org