|
25 | 25 | import org.apache.parquet.schema.Types; |
26 | 26 | import org.junit.Assert; |
27 | 27 | import org.junit.Test; |
| 28 | +import org.locationtech.jts.io.ParseException; |
| 29 | +import org.locationtech.jts.io.WKBWriter; |
| 30 | +import org.locationtech.jts.io.WKTReader; |
28 | 31 |
|
29 | 32 | public class TestGeospatialStatistics { |
30 | 33 |
|
31 | 34 | @Test |
32 | | - public void testAddGeospatialData() { |
| 35 | + public void testAddGeospatialData() throws ParseException { |
33 | 36 | PrimitiveType type = Types.optional(PrimitiveType.PrimitiveTypeName.BINARY) |
34 | 37 | .as(LogicalTypeAnnotation.geometryType()) |
35 | 38 | .named("a"); |
36 | 39 | GeospatialStatistics.Builder builder = GeospatialStatistics.newBuilder(type); |
37 | | - builder.update(Binary.fromString("POINT (1 1)")); |
38 | | - builder.update(Binary.fromString("POINT (2 2)")); |
| 40 | + WKTReader wktReader = new WKTReader(); |
| 41 | + WKBWriter wkbWriter = new WKBWriter(); |
| 42 | + // Convert Geometry to WKB and update the builder |
| 43 | + builder.update(Binary.fromConstantByteArray(wkbWriter.write(wktReader.read("POINT (1 1)")))); |
| 44 | + builder.update(Binary.fromConstantByteArray(wkbWriter.write(wktReader.read("POINT (2 2)")))); |
39 | 45 | GeospatialStatistics statistics = builder.build(); |
40 | 46 | Assert.assertTrue(statistics.isValid()); |
41 | 47 | Assert.assertNotNull(statistics.getBoundingBox()); |
42 | 48 | Assert.assertNotNull(statistics.getGeospatialTypes()); |
43 | 49 | } |
44 | 50 |
|
45 | 51 | @Test |
46 | | - public void testMergeGeospatialStatistics() { |
| 52 | + public void testMergeGeospatialStatistics() throws ParseException { |
47 | 53 | PrimitiveType type = Types.optional(PrimitiveType.PrimitiveTypeName.BINARY) |
48 | 54 | .as(LogicalTypeAnnotation.geometryType()) |
49 | 55 | .named("a"); |
| 56 | + |
| 57 | + WKTReader wktReader = new WKTReader(); |
| 58 | + WKBWriter wkbWriter = new WKBWriter(); |
| 59 | + |
50 | 60 | GeospatialStatistics.Builder builder1 = GeospatialStatistics.newBuilder(type); |
51 | | - builder1.update(Binary.fromString("POINT (1 1)")); |
| 61 | + builder1.update(Binary.fromConstantByteArray(wkbWriter.write(wktReader.read("POINT (1 1)")))); |
52 | 62 | GeospatialStatistics statistics1 = builder1.build(); |
53 | 63 |
|
54 | 64 | GeospatialStatistics.Builder builder2 = GeospatialStatistics.newBuilder(type); |
55 | | - builder2.update(Binary.fromString("POINT (2 2)")); |
| 65 | + builder2.update(Binary.fromConstantByteArray(wkbWriter.write(wktReader.read("POINT (2 2)")))); |
56 | 66 | GeospatialStatistics statistics2 = builder2.build(); |
57 | 67 |
|
58 | 68 | statistics1.merge(statistics2); |
|
0 commit comments