Class ShpGeometryEncoder

java.lang.Object
ch.so.agi.gretl.internal.shapefile.geom.ShpGeometryEncoder

public final class ShpGeometryEncoder extends Object
Encodes a com.vividsolutions.jts geometry into a single EncodedShape, i.e. the little-endian content of one Shapefile record (including the leading shape-type integer).

This is the symmetric counterpart of ShpGeometryDecoder. It keeps all JTS encoding logic out of the core package, exactly like the decoder keeps JTS decoding logic here.

MVP mapping:

  • null/empty geometry → NULL shape (type 0)
  • Point → Point (type 1)
  • LineString/MultiLineString → PolyLine (type 3)
  • Polygon/MultiPolygon → Polygon (type 5)

Polygon ring orientation is normalised so the result round-trips through ShpGeometryDecoder: shells are emitted clockwise (signed area < 0) and holes counter-clockwise.