Kontinuation commented on code in PR #1061:
URL: https://github.com/apache/sedona/pull/1061#discussion_r1376974369
##########
common/src/test/java/org/apache/sedona/common/raster/RasterAccessorsTest.java:
##########
@@ -60,6 +59,22 @@ public void testSrid() throws FactoryException {
assertEquals(4326, RasterAccessors.srid(multiBandRaster));
}
+ @Test
+ public void testRotation() throws IOException, FactoryException {
+ GridCoverage2D emptyRaster = RasterConstructors.makeEmptyRaster(2, 10,
15, 1, 2, 1, -2, 10, 10, 0);
+ double actual = RasterAccessors.getRotation(emptyRaster);
+ double expected = -1.4711276743037347;
+ assertEquals(expected, actual, 1e-9);
+ }
+
+ @Test
+ public void testGeoTransform() throws FactoryException {
+ GridCoverage2D emptyRaster = RasterConstructors.makeEmptyRaster(1, 10,
15, 1, 2, 1, -1, 10, 10, 0);
+ double[] actual = RasterAccessors.getGeoTransform(emptyRaster);
+ double[] expected = new double[] {10.04987562112089,
10.04987562112089, -1.4711276743037347, -1.5707963267948966, 0.0, 0.0};
Review Comment:
We are getting 0 offsets for rasters with non-zero offsets, this is caused
by the problem mentioned above.
##########
common/src/main/java/org/apache/sedona/common/raster/RasterAccessors.java:
##########
@@ -127,6 +128,70 @@ public static String getGeoReference(GridCoverage2D
raster, String format) {
}
}
+
+ public static double[] getGeoTransform(GridCoverage2D raster) throws
FactoryException {
+ // size of a pixel along the transformed i axis
+ double magnitudeI;
+
+ // size of a pixel along the transformed j axis
+ double magnitudeJ;
+
+ // angle by which the raster is rotated (Radians positive clockwise)
+ double thetaI;
+
+ // angle from transformed i axis to transformed j axis (Radians
positive counter-clockwise)
+ double thetaIJ;
+
+ RenderedImage renderedImage = raster.getRenderedImage();
+
+ // x ordinate of the upper-left corner of the upper-left pixel
+ double offsetX = renderedImage.getTileGridXOffset();
+
+ // y ordinate of the upper-left corner of the upper-left pixel
+ double offsetY = renderedImage.getTileGridYOffset();
Review Comment:
This is not correct. `offsetX` and `offsetY` should be directly retrieved
from the upperLeftX and upperLeftY components of the raster metadata.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]