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

wenchen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/master by this push:
     new 317773a5fdd5 [SPARK-54033][GEO][SQL] Introduce Catalyst server-side 
geospatial execution classes
317773a5fdd5 is described below

commit 317773a5fdd5b528dcb48c6ebcbe4a997cda66a2
Author: Uros Bojanic <[email protected]>
AuthorDate: Tue Oct 28 23:45:26 2025 +0800

    [SPARK-54033][GEO][SQL] Introduce Catalyst server-side geospatial execution 
classes
    
    ### What changes were proposed in this pull request?
    Introduce internal server-side `Geography` and `Geometry` execution classes 
in catalyst.
    
    Note that the corresponding low-level physical holders (`GeographyVal` and 
`GeometryVal`) for geospatial types have been previously added as part of 
https://github.com/apache/spark/pull/52629.
    
    ### Why are the changes needed?
    Establishing a clear internal execution layer for geospatial operations in 
catalyst and unblocking downstream work for implementing built-in ST functions 
and geospatial storage support.
    
    ### Does this PR introduce _any_ user-facing change?
    No. This PR does not introduce any new public API, catalyst expressions, 
nor user-facing SQL functions. Those will be added in the future.
    
    ### How was this patch tested?
    Added new Java test suites for the execution classes:
    - `GeographyExecutionSuite`
    - `GeometryExecutionSuite`
    
    ### Was this patch authored or co-authored using generative AI tooling?
    No.
    
    Closes #52737 from uros-db/geo-server-classes.
    
    Authored-by: Uros Bojanic <[email protected]>
    Signed-off-by: Wenchen Fan <[email protected]>
---
 .../org/apache/spark/sql/catalyst/util/Geo.java    |  43 +++++
 .../apache/spark/sql/catalyst/util/Geography.java  | 147 +++++++++++++++
 .../apache/spark/sql/catalyst/util/Geometry.java   | 147 +++++++++++++++
 .../sql/catalyst/util/GeographyExecutionSuite.java | 201 +++++++++++++++++++++
 .../sql/catalyst/util/GeometryExecutionSuite.java  | 201 +++++++++++++++++++++
 5 files changed, 739 insertions(+)

diff --git 
a/sql/catalyst/src/main/java/org/apache/spark/sql/catalyst/util/Geo.java 
b/sql/catalyst/src/main/java/org/apache/spark/sql/catalyst/util/Geo.java
new file mode 100644
index 000000000000..7c9b9ec29b41
--- /dev/null
+++ b/sql/catalyst/src/main/java/org/apache/spark/sql/catalyst/util/Geo.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.spark.sql.catalyst.util;
+
+// Helper interface for the APIs expected from top-level GEOMETRY and 
GEOGRAPHY classes.
+interface Geo {
+
+  /** Binary converters. */
+
+  // Returns the Well-Known Binary (WKB) representation of the geo object.
+  byte[] toWkb();
+
+  // Returns the Extended Well-Known Binary (EWKB) representation of the geo 
object.
+  byte[] toEwkb();
+
+  /** Textual converters. */
+
+  // Returns the Well-Known Text (WKT) representation of the geo object.
+  byte[] toWkt();
+
+  // Returns the Extended Well-Known Text (EWKT) representation of the geo 
object.
+  byte[] toEwkt();
+
+  /** Other methods. */
+
+  // Returns the Spatial Reference Identifier (SRID) value of the geo object.
+  int srid();
+
+}
diff --git 
a/sql/catalyst/src/main/java/org/apache/spark/sql/catalyst/util/Geography.java 
b/sql/catalyst/src/main/java/org/apache/spark/sql/catalyst/util/Geography.java
new file mode 100644
index 000000000000..882143c4b3dd
--- /dev/null
+++ 
b/sql/catalyst/src/main/java/org/apache/spark/sql/catalyst/util/Geography.java
@@ -0,0 +1,147 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.spark.sql.catalyst.util;
+
+import org.apache.spark.unsafe.types.GeographyVal;
+
+import java.util.Arrays;
+
+// Catalyst-internal server-side execution wrapper for GEOGRAPHY.
+public final class Geography implements Geo {
+
+  /** Geography internal implementation. */
+
+  // The Geography type is implemented as an array of bytes stored inside a 
`GeographyVal` object.
+  protected final GeographyVal value;
+
+  /** Geography constants. */
+
+  // The default SRID value for GEOGRAPHY values.
+  public static int DEFAULT_SRID = 4326;
+
+  /** Geography constructors and factory methods. */
+
+  // We make the constructors private. Use `fromBytes` or `fromValue` to 
create new instances.
+  private Geography(byte[] bytes) {
+    this.value = GeographyVal.fromBytes(bytes);
+  }
+
+  private Geography(GeographyVal value) {
+    this.value = value;
+  }
+
+  // Factory methods to create new Geography instances from a byte array or a 
`GeographyVal`.
+  public static Geography fromBytes(byte[] bytes) {
+    return new Geography(bytes);
+  }
+
+  public static Geography fromValue(GeographyVal value) {
+    return new Geography(value);
+  }
+
+  /** Geography getters and instance methods. */
+
+  // Returns the underlying physical type value of this Geography instance.
+  public GeographyVal getValue() {
+    return value;
+  }
+
+  // Returns the byte array containing the GEOGRAPHY representation/encoding.
+  public byte[] getBytes() {
+    return value.getBytes();
+  }
+
+  // Returns a copy of this geography.
+  public Geography copy() {
+    byte[] bytes = getBytes();
+    return Geography.fromBytes(Arrays.copyOf(bytes, bytes.length));
+  }
+
+  /** Geography WKB parsing. */
+
+  // Returns a Geography object with the specified SRID value by parsing the 
input WKB.
+  public static Geography fromWkb(byte[] wkb, int srid) {
+    throw new UnsupportedOperationException("Geography WKB parsing is not yet 
supported.");
+  }
+
+  // Overload for the WKB reader where we use the default SRID for Geography.
+  public static Geography fromWkb(byte[] wkb) {
+    return fromWkb(wkb, DEFAULT_SRID);
+  }
+
+  /** Geography EWKB parsing. */
+
+  // Returns a Geography object by parsing the input EWKB.
+  public static Geography fromEwkb(byte[] ewkb) {
+    throw new UnsupportedOperationException("Geography EWKB parsing is not yet 
supported.");
+  }
+
+  /** Geography WKT parsing. */
+
+  // Returns a Geography object with the specified SRID value by parsing the 
input WKT.
+  public static Geography fromWkt(byte[] wkt, int srid) {
+    throw new UnsupportedOperationException("Geography WKT parsing is not yet 
supported.");
+  }
+
+  // Overload for the WKT reader where we use the default SRID for Geography.
+  public static Geography fromWkt(byte[] wkt) {
+    return fromWkt(wkt, DEFAULT_SRID);
+  }
+
+  /** Geography EWKT parsing. */
+
+  // Returns a Geography object by parsing the input EWKT.
+  public static Geography fromEwkt(byte[] ewkt) {
+    throw new UnsupportedOperationException("Geography EWKT parsing is not yet 
supported.");
+  }
+
+  /** Geography binary standard format converters: WKB and EWKB. */
+
+  @Override
+  public byte[] toWkb() {
+    // Once WKB conversion is implemented, it should support NDR and XDR 
endianness.
+    throw new UnsupportedOperationException("Geography WKB conversion is not 
yet supported.");
+  }
+
+  @Override
+  public byte[] toEwkb() {
+    // Once EWKB conversion is implemented, it should support NDR and XDR 
endianness.
+    throw new UnsupportedOperationException("Geography EWKB conversion is not 
yet supported.");
+  }
+
+  /** Geography textual standard format converters: WKT and EWKT. */
+
+  @Override
+  public byte[] toWkt() {
+    // Once WKT conversion is implemented, it should support various 
precisions.
+    throw new UnsupportedOperationException("Geography WKT conversion is not 
yet supported.");
+  }
+
+  @Override
+  public byte[] toEwkt() {
+    // Once EWKT conversion is implemented, it should support various 
precisions.
+    throw new UnsupportedOperationException("Geography EWKT conversion is not 
yet supported.");
+  }
+
+  /** Other instance methods, inherited from the `Geo` interface. */
+
+  @Override
+  public int srid() {
+    throw new UnsupportedOperationException("Geography SRID is not yet 
supported.");
+  }
+
+}
diff --git 
a/sql/catalyst/src/main/java/org/apache/spark/sql/catalyst/util/Geometry.java 
b/sql/catalyst/src/main/java/org/apache/spark/sql/catalyst/util/Geometry.java
new file mode 100644
index 000000000000..9d82b27df250
--- /dev/null
+++ 
b/sql/catalyst/src/main/java/org/apache/spark/sql/catalyst/util/Geometry.java
@@ -0,0 +1,147 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.spark.sql.catalyst.util;
+
+import org.apache.spark.unsafe.types.GeometryVal;
+
+import java.util.Arrays;
+
+// Catalyst-internal server-side execution wrapper for GEOMETRY.
+public final class Geometry implements Geo {
+
+  /** Geometry internal implementation. */
+
+  // The Geometry type is implemented as an array of bytes stored inside a 
`GeometryVal` object.
+  protected final GeometryVal value;
+
+  /** Geometry constants. */
+
+  // The default SRID value for GEOMETRY values.
+  public static int DEFAULT_SRID = 0;
+
+  /** Geometry constructors and factory methods. */
+
+  // We make the constructors private. Use `fromBytes` or `fromValue` to 
create new instances.
+  private Geometry(byte[] bytes) {
+    this.value = GeometryVal.fromBytes(bytes);
+  }
+
+  private Geometry(GeometryVal value) {
+    this.value = value;
+  }
+
+  // Factory methods to create new Geometry instances from a byte array or a 
`GeometryVal`.
+  public static Geometry fromBytes(byte[] bytes) {
+    return new Geometry(bytes);
+  }
+
+  public static Geometry fromValue(GeometryVal value) {
+    return new Geometry(value);
+  }
+
+  /** Geometry getters and instance methods. */
+
+  // Returns the underlying physical type value of this Geometry instance.
+  public GeometryVal getValue() {
+    return value;
+  }
+
+  // Returns the byte array containing the GEOMETRY representation/encoding.
+  public byte[] getBytes() {
+    return value.getBytes();
+  }
+
+  // Returns a copy of this geometry.
+  public Geometry copy() {
+    byte[] bytes = getBytes();
+    return Geometry.fromBytes(Arrays.copyOf(bytes, bytes.length));
+  }
+
+  /** Geometry WKB parsing. */
+
+  // Returns a Geometry object with the specified SRID value by parsing the 
input WKB.
+  public static Geometry fromWkb(byte[] wkb, int srid) {
+    throw new UnsupportedOperationException("Geometry WKB parsing is not yet 
supported.");
+  }
+
+  // Overload for the WKB reader where we use the default SRID for Geometry.
+  public static Geometry fromWkb(byte[] wkb) {
+    return fromWkb(wkb, DEFAULT_SRID);
+  }
+
+  /** Geometry EWKB parsing. */
+
+  // Returns a Geometry object by parsing the input EWKB.
+  public static Geometry fromEwkb(byte[] ewkb) {
+    throw new UnsupportedOperationException("Geometry EWKB parsing is not yet 
supported.");
+  }
+
+  /** Geometry WKT parsing. */
+
+  // Returns a Geometry object with the specified SRID value by parsing the 
input WKT.
+  public static Geometry fromWkt(byte[] wkt, int srid) {
+    throw new UnsupportedOperationException("Geometry WKT parsing is not yet 
supported.");
+  }
+
+  // Overload for the WKT reader where we use the default SRID for Geometry.
+  public static Geometry fromWkt(byte[] wkt) {
+    return fromWkt(wkt, DEFAULT_SRID);
+  }
+
+  /** Geometry EWKT parsing. */
+
+  // Returns a Geometry object by parsing the input EWKT.
+  public static Geometry fromEwkt(byte[] ewkt) {
+    throw new UnsupportedOperationException("Geometry EWKT parsing is not yet 
supported.");
+  }
+
+  /** Geometry binary standard format converters: WKB and EWKB. */
+
+  @Override
+  public byte[] toWkb() {
+    // Once WKB conversion is implemented, it should support NDR and XDR 
endianness.
+    throw new UnsupportedOperationException("Geometry WKB conversion is not 
yet supported.");
+  }
+
+  @Override
+  public byte[] toEwkb() {
+    // Once EWKB conversion is implemented, it should support NDR and XDR 
endianness.
+    throw new UnsupportedOperationException("Geometry EWKB conversion is not 
yet supported.");
+  }
+
+  /** Geometry textual standard format converters: WKT and EWKT. */
+
+  @Override
+  public byte[] toWkt() {
+    // Once WKT conversion is implemented, it should support various 
precisions.
+    throw new UnsupportedOperationException("Geometry WKT conversion is not 
yet supported.");
+  }
+
+  @Override
+  public byte[] toEwkt() {
+    // Once EWKT conversion is implemented, it should support various 
precisions.
+    throw new UnsupportedOperationException("Geometry EWKT conversion is not 
yet supported.");
+  }
+
+  /** Other instance methods, inherited from the `Geo` interface. */
+
+  @Override
+  public int srid() {
+    throw new UnsupportedOperationException("Geometry SRID is not yet 
supported.");
+  }
+
+}
diff --git 
a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/util/GeographyExecutionSuite.java
 
b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/util/GeographyExecutionSuite.java
new file mode 100644
index 000000000000..f53d66edfa40
--- /dev/null
+++ 
b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/util/GeographyExecutionSuite.java
@@ -0,0 +1,201 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.sql.catalyst.util;
+
+import org.apache.spark.unsafe.types.GeographyVal;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+
+/**
+ * Test suite for the Geography server-side execution class.
+ */
+class GeographyExecutionTest {
+
+  // A sample Geography byte array for testing purposes.
+  private final byte[] testGeographyVal = new byte[] {
+    0x01, 0x01, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, (byte)0xF0,
+    0x3F, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x40
+  };
+
+  /** Tests for Geography factory methods and getters. */
+
+  @Test
+  void testFromBytes() {
+    Geography geography = Geography.fromBytes(testGeographyVal);
+    assertNotNull(geography);
+    assertArrayEquals(testGeographyVal, geography.getBytes());
+  }
+
+  @Test
+  void testFromValue() {
+    GeographyVal value = GeographyVal.fromBytes(testGeographyVal);
+    Geography geography = Geography.fromValue(value);
+    assertNotNull(geography);
+    assertEquals(value, geography.getValue());
+  }
+
+  @Test
+  void testGetBytes() {
+    Geography geography = Geography.fromBytes(testGeographyVal);
+    assertArrayEquals(testGeographyVal, geography.getBytes());
+  }
+
+  @Test
+  void testCopy() {
+    Geography geography = Geography.fromBytes(testGeographyVal);
+    Geography geographyCopy = geography.copy();
+    assertNotNull(geographyCopy);
+    assertArrayEquals(geography.getBytes(), geographyCopy.getBytes());
+  }
+
+  /** Tests for Geography constants. */
+
+  @Test
+  void testDefaultSrid() {
+    assertEquals(4326, Geography.DEFAULT_SRID);
+  }
+
+  /** Tests for Geography WKB parsing. */
+
+  @Test
+  void testFromWkbWithSridUnsupported() {
+    byte[] wkb = new byte[]{1, 2, 3};
+    UnsupportedOperationException exception = assertThrows(
+      UnsupportedOperationException.class,
+      () -> Geography.fromWkb(wkb, 0)
+    );
+    assertEquals("Geography WKB parsing is not yet supported.", 
exception.getMessage());
+  }
+
+  @Test
+  void testFromWkbNoSridUnsupported() {
+    byte[] wkb = new byte[]{1, 2, 3};
+    UnsupportedOperationException exception = assertThrows(
+      UnsupportedOperationException.class,
+      () -> Geography.fromWkb(wkb)
+    );
+    assertEquals("Geography WKB parsing is not yet supported.", 
exception.getMessage());
+  }
+
+  /** Tests for Geography EWKB parsing. */
+
+  @Test
+  void testFromEwkbUnsupported() {
+    byte[] ewkb = new byte[]{1, 2, 3};
+    UnsupportedOperationException exception = assertThrows(
+      UnsupportedOperationException.class,
+      () -> Geography.fromEwkb(ewkb)
+    );
+    assertEquals("Geography EWKB parsing is not yet supported.", 
exception.getMessage());
+  }
+
+  /** Tests for Geography WKT parsing. */
+
+  @Test
+  void testFromWktWithSridUnsupported() {
+    byte[] wkt = new byte[]{4, 5, 5};
+    UnsupportedOperationException exception = assertThrows(
+      UnsupportedOperationException.class,
+      () -> Geography.fromWkt(wkt, 0)
+    );
+    assertEquals("Geography WKT parsing is not yet supported.", 
exception.getMessage());
+  }
+
+  @Test
+  void testFromWktNoSridUnsupported() {
+    byte[] wkt = new byte[]{4, 5, 5};
+    UnsupportedOperationException exception = assertThrows(
+      UnsupportedOperationException.class,
+      () -> Geography.fromWkt(wkt)
+    );
+    assertEquals("Geography WKT parsing is not yet supported.", 
exception.getMessage());
+  }
+
+  /** Tests for Geography EWKT parsing. */
+
+  @Test
+  void testFromEwktUnsupported() {
+    byte[] ewkt = new byte[]{4, 5, 5};
+    UnsupportedOperationException exception = assertThrows(
+      UnsupportedOperationException.class,
+      () -> Geography.fromEwkt(ewkt)
+    );
+    assertEquals("Geography EWKT parsing is not yet supported.", 
exception.getMessage());
+  }
+
+  /** Tests for Geography WKB and EWKB converters. */
+
+  @Test
+  void testToWkbUnsupported() {
+    Geography geography = Geography.fromBytes(testGeographyVal);
+    UnsupportedOperationException exception = assertThrows(
+      UnsupportedOperationException.class,
+      geography::toWkb
+    );
+    assertEquals("Geography WKB conversion is not yet supported.", 
exception.getMessage());
+  }
+
+  @Test
+  void testToEwkbUnsupported() {
+    Geography geography = Geography.fromBytes(testGeographyVal);
+    UnsupportedOperationException exception = assertThrows(
+      UnsupportedOperationException.class,
+      geography::toEwkb
+    );
+    assertEquals("Geography EWKB conversion is not yet supported.", 
exception.getMessage());
+  }
+
+  /** Tests for Geography WKT and EWKT converters. */
+
+  @Test
+  void testToWktUnsupported() {
+    Geography geography = Geography.fromBytes(testGeographyVal);
+    UnsupportedOperationException exception = assertThrows(
+      UnsupportedOperationException.class,
+      geography::toWkt
+    );
+    assertEquals("Geography WKT conversion is not yet supported.", 
exception.getMessage());
+  }
+
+  @Test
+  void testToEwktUnsupported() {
+    Geography geography = Geography.fromBytes(testGeographyVal);
+    UnsupportedOperationException exception = assertThrows(
+      UnsupportedOperationException.class,
+      geography::toEwkt
+    );
+    assertEquals("Geography EWKT conversion is not yet supported.", 
exception.getMessage());
+  }
+
+  /** Tests for other Geography methods. */
+
+  @Test
+  void testSridUnsupported() {
+    Geography geography = Geography.fromBytes(testGeographyVal);
+    UnsupportedOperationException exception = assertThrows(
+      UnsupportedOperationException.class,
+      geography::srid
+    );
+    assertEquals("Geography SRID is not yet supported.", 
exception.getMessage());
+  }
+}
diff --git 
a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/util/GeometryExecutionSuite.java
 
b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/util/GeometryExecutionSuite.java
new file mode 100644
index 000000000000..13e6618f833f
--- /dev/null
+++ 
b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/util/GeometryExecutionSuite.java
@@ -0,0 +1,201 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.sql.catalyst.util;
+
+import org.apache.spark.unsafe.types.GeometryVal;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+
+/**
+ * Test suite for the Geometry server-side execution class.
+ */
+class GeometryExecutionTest {
+
+  // A sample Geometry byte array for testing purposes.
+  private final byte[] testGeometryVal = new byte[] {
+    0x01, 0x01, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, (byte)0xF0,
+    0x3F, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x40
+  };
+
+  /** Tests for Geometry factory methods and getters. */
+
+  @Test
+  void testFromBytes() {
+    Geometry geometry = Geometry.fromBytes(testGeometryVal);
+    assertNotNull(geometry);
+    assertArrayEquals(testGeometryVal, geometry.getBytes());
+  }
+
+  @Test
+  void testFromValue() {
+    GeometryVal value = GeometryVal.fromBytes(testGeometryVal);
+    Geometry geometry = Geometry.fromValue(value);
+    assertNotNull(geometry);
+    assertEquals(value, geometry.getValue());
+  }
+
+  @Test
+  void testGetBytes() {
+    Geometry geometry = Geometry.fromBytes(testGeometryVal);
+    assertArrayEquals(testGeometryVal, geometry.getBytes());
+  }
+
+  @Test
+  void testCopy() {
+    Geometry geometry = Geometry.fromBytes(testGeometryVal);
+    Geometry geometryCopy = geometry.copy();
+    assertNotNull(geometryCopy);
+    assertArrayEquals(geometry.getBytes(), geometryCopy.getBytes());
+  }
+
+  /** Tests for Geometry constants. */
+
+  @Test
+  void testDefaultSrid() {
+    assertEquals(0, Geometry.DEFAULT_SRID);
+  }
+
+  /** Tests for Geometry WKB parsing. */
+
+  @Test
+  void testFromWkbWithSridUnsupported() {
+    byte[] wkb = new byte[]{1, 2, 3};
+    UnsupportedOperationException exception = assertThrows(
+      UnsupportedOperationException.class,
+      () -> Geometry.fromWkb(wkb, 0)
+    );
+    assertEquals("Geometry WKB parsing is not yet supported.", 
exception.getMessage());
+  }
+
+  @Test
+  void testFromWkbNoSridUnsupported() {
+    byte[] wkb = new byte[]{1, 2, 3};
+    UnsupportedOperationException exception = assertThrows(
+      UnsupportedOperationException.class,
+      () -> Geometry.fromWkb(wkb)
+    );
+    assertEquals("Geometry WKB parsing is not yet supported.", 
exception.getMessage());
+  }
+
+  /** Tests for Geometry EWKB parsing. */
+
+  @Test
+  void testFromEwkbUnsupported() {
+    byte[] ewkb = new byte[]{1, 2, 3};
+    UnsupportedOperationException exception = assertThrows(
+      UnsupportedOperationException.class,
+      () -> Geometry.fromEwkb(ewkb)
+    );
+    assertEquals("Geometry EWKB parsing is not yet supported.", 
exception.getMessage());
+  }
+
+  /** Tests for Geometry WKT parsing. */
+
+  @Test
+  void testFromWktWithSridUnsupported() {
+    byte[] wkt = new byte[]{4, 5, 5};
+    UnsupportedOperationException exception = assertThrows(
+      UnsupportedOperationException.class,
+      () -> Geometry.fromWkt(wkt, 0)
+    );
+    assertEquals("Geometry WKT parsing is not yet supported.", 
exception.getMessage());
+  }
+
+  @Test
+  void testFromWktNoSridUnsupported() {
+    byte[] wkt = new byte[]{4, 5, 5};
+    UnsupportedOperationException exception = assertThrows(
+      UnsupportedOperationException.class,
+      () -> Geometry.fromWkt(wkt)
+    );
+    assertEquals("Geometry WKT parsing is not yet supported.", 
exception.getMessage());
+  }
+
+  /** Tests for Geometry EWKT parsing. */
+
+  @Test
+  void testFromEwktUnsupported() {
+    byte[] ewkt = new byte[]{4, 5, 5};
+    UnsupportedOperationException exception = assertThrows(
+      UnsupportedOperationException.class,
+      () -> Geometry.fromEwkt(ewkt)
+    );
+    assertEquals("Geometry EWKT parsing is not yet supported.", 
exception.getMessage());
+  }
+
+  /** Tests for Geometry WKB and EWKB converters. */
+
+  @Test
+  void testToWkbUnsupported() {
+    Geometry geometry = Geometry.fromBytes(testGeometryVal);
+    UnsupportedOperationException exception = assertThrows(
+      UnsupportedOperationException.class,
+      geometry::toWkb
+    );
+    assertEquals("Geometry WKB conversion is not yet supported.", 
exception.getMessage());
+  }
+
+  @Test
+  void testToEwkbUnsupported() {
+    Geometry geometry = Geometry.fromBytes(testGeometryVal);
+    UnsupportedOperationException exception = assertThrows(
+      UnsupportedOperationException.class,
+      geometry::toEwkb
+    );
+    assertEquals("Geometry EWKB conversion is not yet supported.", 
exception.getMessage());
+  }
+
+  /** Tests for Geometry WKT and EWKT converters. */
+
+  @Test
+  void testToWktUnsupported() {
+    Geometry geometry = Geometry.fromBytes(testGeometryVal);
+    UnsupportedOperationException exception = assertThrows(
+      UnsupportedOperationException.class,
+      geometry::toWkt
+    );
+    assertEquals("Geometry WKT conversion is not yet supported.", 
exception.getMessage());
+  }
+
+  @Test
+  void testToEwktUnsupported() {
+    Geometry geometry = Geometry.fromBytes(testGeometryVal);
+    UnsupportedOperationException exception = assertThrows(
+      UnsupportedOperationException.class,
+      geometry::toEwkt
+    );
+    assertEquals("Geometry EWKT conversion is not yet supported.", 
exception.getMessage());
+  }
+
+  /** Tests for other Geometry methods. */
+
+  @Test
+  void testSridUnsupported() {
+    Geometry geometry = Geometry.fromBytes(testGeometryVal);
+    UnsupportedOperationException exception = assertThrows(
+      UnsupportedOperationException.class,
+      geometry::srid
+    );
+    assertEquals("Geometry SRID is not yet supported.", 
exception.getMessage());
+  }
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to