Class WKTConverter
- java.lang.Object
-
- com.databricks.jdbc.api.impl.converters.WKTConverter
-
public class WKTConverter extends Object
Utility class for converting between WKT (Well-Known Text) and WKB (Well-Known Binary) formats.This class uses the JTS (Java Topology Suite) library to provide robust WKT/WKB conversion functionality for geospatial data. JTS is a widely-used, well-tested library that implements the OpenGIS Consortium's Simple Features Specification for SQL.
-
-
Constructor Summary
Constructors Constructor Description WKTConverter()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intextractSRIDFromEWKT(String ewkt)Extracts the SRID from an EWKT (Extended Well-Known Text) string.static StringremoveSRIDFromEWKT(String ewkt)Removes the SRID prefix from an EWKT string to get clean WKT.static byte[]toWKB(String wkt)Converts WKT (Well-Known Text) to WKB (Well-Known Binary) format.static StringtoWKT(byte[] wkb)Converts WKB (Well-Known Binary) to WKT (Well-Known Text) format.
-
-
-
Method Detail
-
toWKB
public static byte[] toWKB(String wkt) throws DatabricksValidationException
Converts WKT (Well-Known Text) to WKB (Well-Known Binary) format.This implementation uses the JTS library to parse the WKT string into a Geometry object and then converts it to WKB format. This provides robust, standards-compliant conversion.
- Parameters:
wkt- the WKT string to convert- Returns:
- the WKB representation as a byte array
- Throws:
DatabricksValidationException- if the WKT is invalid
-
toWKT
public static String toWKT(byte[] wkb) throws DatabricksValidationException
Converts WKB (Well-Known Binary) to WKT (Well-Known Text) format.This implementation uses the JTS library to parse the WKB bytes into a Geometry object and then converts it to WKT format.
- Parameters:
wkb- the WKB bytes to convert- Returns:
- the WKT representation as a string
- Throws:
DatabricksValidationException- if the WKB is invalid
-
extractSRIDFromEWKT
public static int extractSRIDFromEWKT(String ewkt)
Extracts the SRID from an EWKT (Extended Well-Known Text) string.EWKT format includes SRID prefix: "SRID=4326;POINT(1 2)"
- Parameters:
ewkt- the EWKT string- Returns:
- the SRID value, or 0 if no SRID is specified
-
-