rdblue commented on code in PR #12346:
URL: https://github.com/apache/iceberg/pull/12346#discussion_r1994434710


##########
api/src/main/java/org/apache/iceberg/types/Types.java:
##########
@@ -543,6 +563,122 @@ public int hashCode() {
     }
   }
 
+  public static class GeometryType extends PrimitiveType {
+
+    private final String crs;
+
+    private GeometryType(String crs) {
+      Preconditions.checkNotNull(crs, "CRS cannot be null");
+      this.crs = crs;
+    }
+
+    public static GeometryType get() {
+      return new GeometryType("");
+    }
+
+    public static GeometryType of(String crs) {
+      return new GeometryType(crs == null ? "" : crs);
+    }
+
+    @Override
+    public TypeID typeId() {
+      return TypeID.GEOMETRY;
+    }
+
+    public String crs() {
+      return crs;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+      if (this == o) {
+        return true;
+      } else if (!(o instanceof GeometryType)) {
+        return false;
+      }
+
+      GeometryType that = (GeometryType) o;
+      return crs.equals(that.crs);
+    }
+
+    @Override
+    public int hashCode() {
+      return Objects.hash(GeometryType.class, crs);
+    }
+
+    @Override
+    public String toString() {
+      return String.format("geometry(%s)", crs);
+    }
+  }
+
+  public static class GeographyType extends PrimitiveType {
+
+    private final String crs;
+    private final EdgeInterpolationAlgorithm algorithm;
+
+    private GeographyType(String crs, EdgeInterpolationAlgorithm algorithm) {
+      Preconditions.checkNotNull(crs, "CRS cannot be null");
+      this.crs = crs;
+      this.algorithm = algorithm;
+    }
+
+    public static GeographyType get() {
+      return new GeographyType("", null);
+    }
+
+    public static GeographyType of(String crs) {
+      return new GeographyType(crs, null);
+    }
+
+    public static GeographyType of(String crs, EdgeInterpolationAlgorithm 
algorithm) {
+      return new GeographyType(crs, algorithm);
+    }
+
+    public static GeographyType of(String crs, String algorithmName) {
+      EdgeInterpolationAlgorithm algorithm =
+          ((algorithmName == null || algorithmName.isEmpty())
+              ? null
+              : EdgeInterpolationAlgorithm.fromName(algorithmName));
+      return new GeographyType(crs == null ? "" : crs, algorithm);
+    }
+
+    @Override
+    public TypeID typeId() {
+      return TypeID.GEOGRAPHY;
+    }
+
+    public String crs() {
+      return crs;
+    }
+
+    public EdgeInterpolationAlgorithm algorithm() {
+      return algorithm;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+      if (this == o) {
+        return true;
+      } else if (!(o instanceof GeographyType)) {
+        return false;
+      }
+
+      GeographyType that = (GeographyType) o;
+      return Objects.equals(crs, that.crs) && Objects.equals(algorithm, 
that.algorithm);
+    }
+
+    @Override
+    public int hashCode() {
+      return Objects.hash(GeographyType.class, crs, algorithm);
+    }
+
+    @Override
+    public String toString() {
+      return String.format("geography(%s, %s)", crs, algorithm != null ? 
algorithm.value() : "");

Review Comment:
   Looks like this will produce `"geography(, )"` for the default type. When 
the type is the default, it should produce just `geography`. When algorithm is 
not set, it should produce `geography(crs)` and when algorithm is set it should 
produce `geography(crs, algorithm)`. When the CRS is defaulted and algorithm is 
not, it should use whatever standard name we decide on for CRS84.



-- 
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: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to