Drabble commented on code in PR #860:
URL: 
https://github.com/apache/incubator-baremaps/pull/860#discussion_r1623290051


##########
baremaps-geoparquet/src/main/java/org/apache/baremaps/geoparquet/data/GeoParquetGroupImpl.java:
##########
@@ -414,6 +427,22 @@ public List<Geometry> getGeometryValues(int fieldIndex) {
     return geometries;
   }
 
+  @Override
+  public Envelope getEnvelopeValue(int fieldIndex) {
+    return getEnvelopeValues(fieldIndex).get(0);
+  }
+
+  @Override
+  public List<Envelope> getEnvelopeValues(int fieldIndex) {
+    return getGroupValues(fieldIndex).stream().map(group -> {
+      var xMin = group.getDoubleValue(0);
+      var yMin = group.getDoubleValue(1);
+      var xMax = group.getDoubleValue(2);
+      var yMax = group.getDoubleValue(3);

Review Comment:
   With a Overture maps file this fails because the bbox uses float values.
   
   ```suggestion
         var xMin = group.getFloatValue(0);
         var yMin = group.getFloatValue(1);
         var xMax = group.getFloatValue(2);
         var yMax = group.getFloatValue(3);
   ```



##########
baremaps-core/src/main/java/org/apache/baremaps/storage/geoparquet/GeoParquetTypeConversion.java:
##########
@@ -69,9 +80,33 @@ public static List<Object> asRowValues(GeoParquetGroup 
group) {
         case DOUBLE -> values.add(group.getDoubleValue(i));
         case STRING -> values.add(group.getStringValue(i));
         case GEOMETRY -> values.add(group.getGeometryValue(i));
-        case GROUP -> values.add(null); // TODO: 
values.add(asDataRow(group.getGroupValue(i)));
+        case ENVELOPE -> values.add(group.getEnvelopeValue(i));
+        case GROUP -> values.add(asNested(group.getGroupValue(i)));
       }
     }
     return values;
   }
+
+  public static Map<String, Object> asNested(GeoParquetGroup group) {
+    Map<String, Object> nested = new HashMap<>();
+    Schema schema = group.getSchema();
+    List<Field> fields = schema.fields();
+    for (int i = 0; i < fields.size(); i++) {
+      Field field = fields.get(i);
+      nested.put(field.name(), switch (field.type()) {
+        case BINARY -> group.getBinaryValue(i).getBytes();

Review Comment:
   When an optional field or a group is null in the geoparquet file, this will 
raise an exception. The same thing happens in the `asRowValues` method. I 
tested it with real Overture data.



-- 
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]

Reply via email to