jiayuasu commented on code in PR #1011:
URL: https://github.com/apache/sedona/pull/1011#discussion_r1320472497
##########
common/src/main/java/org/apache/sedona/common/raster/RasterOutputs.java:
##########
@@ -74,6 +77,25 @@ public static byte[] asGeoTiff(GridCoverage2D raster) {
return asGeoTiff(raster, null, -1);
}
+ /**
+ * Creates a GeoTiff file with the provided raster. Primarily used for
testing.
+ * @param raster The raster to be stored as .tiff
+ * @param filePath The path where the .tiff should be stored.
+ *
+ * @return true if file is created, otherwise throws IOException
+ * @throws IOException
+ * */
+ public static boolean toGeoTiff(GridCoverage2D raster, String filePath) {
Review Comment:
This function should be called `writeToDiskFile`. It takes a byte[] array as
input and write the file to disk. This is a generic function that works with
the result of asGeoTiff, asArcGrid, and so on.
##########
spark/common/src/test/resources/testToGeoTiffFunction/test1.tiff:
##########
Review Comment:
This file is generated by your `toGeoTiff`. It should not be committed. And
again, the test should not write result back to the resources folder.
##########
common/src/test/java/org/apache/sedona/common/raster/RasterOutputTest.java:
##########
@@ -44,6 +44,19 @@ public void testAsGeoTiff() throws IOException {
assertEquals(rasterTest.getEnvelope().toString(),
rasterOg.getEnvelope().toString());
}
+ @Test
+ public void testToGeoTiff() throws IOException {
+ GridCoverage2D rasterOg = rasterFromGeoTiff(resourceFolder +
"raster/test1.tiff");
+ String filePath = System.getProperty("user.dir") +
"/../spark/common/src/test/resources/testToGeoTiffFunction/test1.tiff";
Review Comment:
The file path is wrong. It should be `System.getProperty("user.dir") +
"/target/estToGeoTiffFunction/test1.tiff";`. Do not add content to the test
resource folder.
--
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]