You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@baremaps.apache.org by bc...@apache.org on 2024/10/12 12:09:27 UTC

(incubator-baremaps) branch geoparquet-filtering-and-simplification updated (37b44ea3 -> 2703d415)

This is an automated email from the ASF dual-hosted git repository.

bchapuis pushed a change to branch geoparquet-filtering-and-simplification
in repository https://gitbox.apache.org/repos/asf/incubator-baremaps.git


    omit 37b44ea3 Fix issues in group
     new 2703d415 Fix issues in group

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (37b44ea3)
            \
             N -- N -- N   refs/heads/geoparquet-filtering-and-simplification (2703d415)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../java/org/apache/baremaps/geoparquet/GeoParquetGroup.java     | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)


(incubator-baremaps) 01/01: Fix issues in group

Posted by bc...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

bchapuis pushed a commit to branch geoparquet-filtering-and-simplification
in repository https://gitbox.apache.org/repos/asf/incubator-baremaps.git

commit 2703d41581dfdefc40d530641cbe92fe6e0bdfc4
Author: Bertil Chapuis <bc...@gmail.com>
AuthorDate: Sat Oct 12 13:23:44 2024 +0200

    Fix issues in group
---
 .../baremaps/geoparquet/GeoParquetGroup.java       | 117 ++++++++++-----------
 .../baremaps/geoparquet/GeoParquetReaderTest.java  |   2 +-
 2 files changed, 54 insertions(+), 65 deletions(-)

diff --git a/baremaps-geoparquet/src/main/java/org/apache/baremaps/geoparquet/GeoParquetGroup.java b/baremaps-geoparquet/src/main/java/org/apache/baremaps/geoparquet/GeoParquetGroup.java
index 35617447..e375ed30 100644
--- a/baremaps-geoparquet/src/main/java/org/apache/baremaps/geoparquet/GeoParquetGroup.java
+++ b/baremaps-geoparquet/src/main/java/org/apache/baremaps/geoparquet/GeoParquetGroup.java
@@ -225,48 +225,6 @@ public class GeoParquetGroup {
     return new GeoParquetException(msg);
   }
 
-  public String toString() {
-    return toString("");
-  }
-
-  public String toString(String indent) {
-    StringBuilder builder = new StringBuilder();
-    appendToString(builder, indent);
-    return builder.toString();
-  }
-
-  private void appendToString(StringBuilder builder, String indent) {
-    int i = 0;
-    for (org.apache.parquet.schema.Type field : parquetSchema.getFields()) {
-      String name = field.getName();
-      Object object = data[i];
-      ++i;
-      if (object != null) {
-        if (object instanceof List<?>values) {
-          for (Object value : values) {
-            builder.append(indent).append(name);
-            if (value == null) {
-              builder.append(": NULL\n");
-            } else if (value instanceof GeoParquetGroup group) {
-              builder.append('\n');
-              group.appendToString(builder, indent + "  ");
-            } else {
-              builder.append(": ").append(value).append('\n');
-            }
-          }
-        } else {
-          builder.append(indent).append(name);
-          if (object instanceof GeoParquetGroup group) {
-            builder.append('\n');
-            group.appendToString(builder, indent + "  ");
-          } else {
-            builder.append(": ").append(object).append('\n');
-          }
-        }
-      }
-    }
-  }
-
   public GeoParquetSchema getGeoParquetSchema() {
     return geoParquetSchema;
   }
@@ -280,30 +238,10 @@ public class GeoParquetGroup {
   }
 
   // Getter methods for different data types
-  public String getString(int fieldIndex, int index) {
+  public String getStringValue(int fieldIndex, int index) {
     return getBinaryValue(fieldIndex, index).toStringUsingUTF8();
   }
 
-  public int getInteger(int fieldIndex, int index) {
-    return (int) getValue(fieldIndex, index);
-  }
-
-  public long getLong(int fieldIndex, int index) {
-    return (long) getValue(fieldIndex, index);
-  }
-
-  public double getDouble(int fieldIndex, int index) {
-    return (double) getValue(fieldIndex, index);
-  }
-
-  public float getFloat(int fieldIndex, int index) {
-    return (float) getValue(fieldIndex, index);
-  }
-
-  public boolean getBoolean(int fieldIndex, int index) {
-    return (boolean) getValue(fieldIndex, index);
-  }
-
   public Binary getBinaryValue(int fieldIndex, int index) {
     return (Binary) getValue(fieldIndex, index);
   }
@@ -343,7 +281,7 @@ public class GeoParquetGroup {
   }
 
   public String getStringValue(int fieldIndex) {
-    return getString(fieldIndex, 0);
+    return getStringValue(fieldIndex, 0);
   }
 
   public Geometry getGeometryValue(int fieldIndex) {
@@ -514,4 +452,55 @@ public class GeoParquetGroup {
     return getEnvelopeValues(parquetSchema.getFieldIndex(fieldName));
   }
 
+  public String toString() {
+    return toString("");
+  }
+
+  private String toString(String indent) {
+    StringBuilder builder = new StringBuilder();
+    int fieldCount = parquetSchema.getFields().size();
+
+    for (int i = 0; i < fieldCount; i++) {
+      String fieldName = parquetSchema.getFieldName(i);
+      Object fieldValue = data[i];
+      if (fieldValue != null) {
+        appendFieldToString(builder, indent, fieldName, fieldValue);
+      }
+    }
+
+    return builder.toString();
+  }
+
+  private void appendFieldToString(StringBuilder builder, String indent, String fieldName,
+      Object fieldValue) {
+    if (fieldValue instanceof List<?>values) {
+      for (Object value : values) {
+        appendValueToString(builder, indent, fieldName, value);
+      }
+    } else {
+      appendValueToString(builder, indent, fieldName, fieldValue);
+    }
+  }
+
+  private void appendValueToString(StringBuilder builder, String indent, String fieldName,
+      Object value) {
+    builder.append(indent).append(fieldName);
+    if (value == null) {
+      builder.append(": NULL\n");
+    } else if (value instanceof GeoParquetGroup group) {
+      builder.append("\n").append(group.toString(indent + "  "));
+    } else {
+      String valueString = getValueAsString(value);
+      builder.append(": ").append(valueString).append("\n");
+    }
+  }
+
+  private String getValueAsString(Object value) {
+    if (value instanceof Binary binary) {
+      return binary.toStringUsingUTF8();
+    } else {
+      return value.toString();
+    }
+  }
+
 }
diff --git a/baremaps-geoparquet/src/test/java/org/apache/baremaps/geoparquet/GeoParquetReaderTest.java b/baremaps-geoparquet/src/test/java/org/apache/baremaps/geoparquet/GeoParquetReaderTest.java
index 849720a3..efda0f7a 100644
--- a/baremaps-geoparquet/src/test/java/org/apache/baremaps/geoparquet/GeoParquetReaderTest.java
+++ b/baremaps-geoparquet/src/test/java/org/apache/baremaps/geoparquet/GeoParquetReaderTest.java
@@ -30,7 +30,7 @@ class GeoParquetReaderTest {
   void read() {
     URI geoParquet = TestFiles.GEOPARQUET.toUri();
     GeoParquetReader geoParquetReader = new GeoParquetReader(geoParquet);
-    assertEquals(5, geoParquetReader.read().count());
+    assertEquals(5, geoParquetReader.read().peek(System.out::println).count());
   }
 
   @Test