Skip to content

Commit 348dbbf

Browse files
committed
Update GeoParquet type conversion to return Geometry from Envelope; enhance handling of envelope values in data retrieval.
1 parent 2636a91 commit 348dbbf

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

baremaps-calcite/src/main/java/org/apache/baremaps/calcite/geoparquet/GeoParquetTypeConversion.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ private static RelDataType toRelDataTypeFromField(RelDataTypeFactory typeFactory
8080
} else if (type == Type.GEOMETRY) {
8181
return typeFactory.createJavaType(Geometry.class);
8282
} else if (type == Type.ENVELOPE) {
83-
return typeFactory.createJavaType(Envelope.class);
83+
return typeFactory.createJavaType(Geometry.class);
8484
} else if (type == Type.LONG || type == Type.INT96) {
8585
return typeFactory.createSqlType(SqlTypeName.BIGINT);
8686
} else if (type == Type.GROUP) {
@@ -173,7 +173,10 @@ public static Object convertValue(Field field, GeoParquetGroup group, int index)
173173
} else if (type == Type.GEOMETRY) {
174174
return group.getGeometryValues(index);
175175
} else if (type == Type.ENVELOPE) {
176-
return group.getEnvelopeValues(index);
176+
List<Envelope> envelopes = group.getEnvelopeValues(index);
177+
return envelopes.stream()
178+
.map(envelope -> envelope != null ? GEOMETRY_FACTORY.toGeometry(envelope) : null)
179+
.collect(Collectors.toList());
177180
} else if (type == Type.GROUP) {
178181
return group.getGroupValues(index).stream().map(GeoParquetTypeConversion::asNested)
179182
.toList();
@@ -201,7 +204,8 @@ public static Object convertValue(Field field, GeoParquetGroup group, int index)
201204
} else if (type == Type.GEOMETRY) {
202205
return group.getGeometryValue(index);
203206
} else if (type == Type.ENVELOPE) {
204-
return group.getEnvelopeValue(index);
207+
Envelope envelope = group.getEnvelopeValue(index);
208+
return envelope != null ? GEOMETRY_FACTORY.toGeometry(envelope) : null;
205209
} else if (type == Type.GROUP) {
206210
return asNested(group.getGroupValue(index));
207211
} else {

0 commit comments

Comments
 (0)