Skip to main content
Hint

This article is generated by AI translation.

Geospatial Type Handlers

Geospatial type handlers are located in the net.hasor.dbvisitor.types.handler.geo package. Add the JTS dependency before use:

<dependency>
<groupId>org.locationtech.jts</groupId>
<artifactId>jts-core</artifactId>
<version>1.19.0</version>
</dependency>

OpenGIS Standard Formats

The OpenGIS specification defines two geospatial data representation formats:

  • WKT (Well-Known Text) — string form, e.g. POINT (30 10)
  • WKB (Well-Known Binary) — byte array byte[] form

Built-in Handlers

Choose the appropriate handler based on the database storage format and application-level type:

HandlerDB FormatJava TypeDescription
JtsGeometryWktAsWkbTypeHandlerWKT (String)byte[]Read: WKT→WKB, Write: WKB→WKT
JtsGeometryWkbAsWktTypeHandlerWKB (byte[])StringRead: WKB→WKT, Write: WKT→WKB
JtsGeometryWkbHexAsWktTypeHandlerWKB HEX (String)StringRead: HEX→WKB→WKT, Write: WKT→WKB→HEX

Store as WKT

Database stores in WKT (String) format, application uses WKB (byte[]):

Database           Application
WKT (String) → WKB (byte[])
WKT (String) ← WKB (byte[])

Use JtsGeometryWktAsWkbTypeHandler

Store as WKB

Database stores in WKB (byte[]) format, application uses WKT (String):

Database          Application
WKB (byte[]) → WKT (String)
WKB (byte[]) ← WKT (String)

Use JtsGeometryWkbAsWktTypeHandler

Store as WKB HEX

Database stores in WKB HEX-encoded (String) format, application uses WKT (String):

Database              Application
WKB HEX (String) → WKT (String)
WKB HEX (String) ← WKT (String)

Use JtsGeometryWkbHexAsWktTypeHandler