jiayuasu commented on code in PR #1011:
URL: https://github.com/apache/sedona/pull/1011#discussion_r1319288617
##########
common/src/test/java/org/apache/sedona/common/raster/RasterConstructorsTest.java:
##########
@@ -55,6 +58,22 @@ public void fromGeoTiff() throws IOException,
FactoryException {
assertEquals(4, gridCoverage2D.getNumSampleDimensions());
}
+ @Test
+ public void testAsRasterWithEmptyRaster() throws FactoryException,
ParseException {
+ GridCoverage2D raster = RasterConstructors.makeEmptyRaster(2, 255,
255, 3, -215, 2, -2, 0, 0, 4326);
+ Geometry geom = Constructors.geomFromWKT("POLYGON((15 15, 18 20, 15
24, 24 25, 15 15))", 0);
+ GridCoverage2D rasterized = RasterConstructors.asRaster(geom, raster,
"d", 3093151, 3d);
+ byte[] actual = RasterOutputs.asGeoTiff(rasterized);
+ byte[] expected = new byte[] {77, 77, 0, 42, 0, 0, 0, 8, 0, 16, 1, 0,
0, 3, 0, 0, 0, 1, 0, 4, 0, 0, 1, 1, 0, 3, 0, 0, 0, 1, 0, 5, 0, 0, 1, 2, 0, 3,
0, 0, 0, 1, 0, 64, 0, 0, 1, 3, 0, 3, 0, 0, 0, 1, 0, 1, 0, 0, 1, 6, 0, 3, 0, 0,
0, 1, 0, 1, 0, 0, 1, 17, 0, 4, 0, 0, 0, 1, 0, 0, 1, -128, 1, 21, 0, 3, 0, 0, 0,
1, 0, 1, 0, 0, 1, 22, 0, 3, 0, 0, 0, 1, 0, 5, 0, 0, 1, 23, 0, 4, 0, 0, 0, 1, 0,
0, 0, -96, 1, 26, 0, 5, 0, 0, 0, 1, 0, 0, 0, -48, 1, 27, 0, 5, 0, 0, 0, 1, 0,
0, 0, -40, 1, 40, 0, 3, 0, 0, 0, 1, 0, 1, 0, 0, 1, 83, 0, 3, 0, 0, 0, 1, 0, 3,
0, 0, -123, -40, 0, 12, 0, 0, 0, 16, 0, 0, 0, -32, -121, -81, 0, 3, 0, 0, 0,
16, 0, 0, 1, 96, -92, -127, 0, 2, 0, 0, 0, 4, 51, 46, 48, 0, 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};
+ assertArrayEquals(expected, actual);
Review Comment:
Agree. To make things easier, add a test case that uses a Point geometry and
checks if the corresponding pixel has the expected rasterized value.
--
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]