Package org.geotools.data.duckdb
Class HexWKBEncoder
Object
HexWKBEncoder
Utility class for encoding JTS geometries as hexadecimal WKB (Well-Known Binary) strings for use with DuckDB's
spatial functions.
This encoder provides locale-independent geometry encoding that avoids issues with decimal separator parsing in
different system locales. Instead of using WKT (Well-Known Text) which can be misinterpreted in locales that use
comma as decimal separator, this class generates binary WKB data encoded as hexadecimal strings for use with DuckDB's
ST_GeomFromHEXEWKB
function.
Usage:
Geometry geom = ...;
StringBuffer sql = new StringBuffer("ST_GeomFromHEXEWKB('");
HexWKBEncoder.encode(geom, sql);
sql.append("')");
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
encode
(Geometry g, Appendable writer) Encodes a JTS geometry as hexadecimal WKB and appends it to the provided writer.
-
Constructor Details
-
HexWKBEncoder
public HexWKBEncoder()
-
-
Method Details
-
encode
Encodes a JTS geometry as hexadecimal WKB and appends it to the provided writer.LinearRing geometries are automatically converted to LineString since DuckDB doesn't support the LinearRing type.
- Parameters:
g
- the geometry to encodewriter
- the target to append the hexadecimal WKB representation to- Throws:
IOException
- if there's an error writing to the appendable
-