WKTDatatype extends GeometryDatatype { @Override public String unparse(Object geometry) { if (geometry instanceof GeometryWrapper) { GeometryWrapper geometryWrapper = (GeometryWrapper) geometry; return WKTWriter.write(geometryWrapper); } else { throw new DatatypeFormatException("Object to unparse WKTDatatype is not a GeometryWrapper: " + geometry); } } private  WKTDatatype(); @Override String unparse(Object geometry); @Override GeometryWrapper read(String geometryLiteral); @Override String toString(); static final String URI; static final WKTDatatype INSTANCE; }
@Test public void testUnparse() { String expResult = "POINT(-83.38 33.95)"; Coordinate coord = new Coordinate(-83.38, 33.95); Point point = GEOMETRY_FACTORY.createPoint(coord); String srsURI = "http: DimensionInfo dimensionInfo = new DimensionInfo(2, 2, 0); GeometryWrapper geometry = new GeometryWrapper(point, srsURI, WKTDatatype.URI, dimensionInfo); String result = WKT_DATATYPE.unparse(geometry); assertEquals(expResult, result); }
@Test public void testUnparse_srs() { String expResult = "<http: Coordinate coord = new Coordinate(-83.38, 33.95); Point point = GEOMETRY_FACTORY.createPoint(coord); String srsURI = "http: DimensionInfo dimensionInfo = new DimensionInfo(2, 2, 0); GeometryWrapper geometry = new GeometryWrapper(point, srsURI, WKTDatatype.URI, dimensionInfo); String result = WKT_DATATYPE.unparse(geometry); assertEquals(expResult, result); }