/** * Converts a byte array to a hexadecimal string. * * @param bytes * @return a string of hexadecimal digits * * @deprecated */ public static String bytesToHex(byte[] bytes) { return toHex(bytes); }
private String getWKTorWKB(Geometry g, boolean useWKT) { if (useWKT) return wktWriter.writeFormatted(g); return WKBWriter.toHex(wkbWriter.write(g)); }
public static String writeWKB(Geometry g) { if (g == null) return ""; return WKBWriter.toHex((new WKBWriter().write(g))); }
private String convertToWKB(Geometry g) { if (g == null) return ""; return WKBWriter.toHex((new WKBWriter().write(g))); }
void runGeometry(Geometry g, int dimension, int byteOrder, boolean toHex, int srid) throws IOException, ParseException { boolean includeSRID = false; if (srid >= 0) { includeSRID = true; g.setSRID(srid); } WKBWriter wkbWriter = new WKBWriter(dimension, byteOrder, includeSRID); byte[] wkb = wkbWriter.write(g); String wkbHex = null; if (toHex) wkbHex = WKBWriter.toHex(wkb); if (toHex) wkb = WKBReader.hexToBytes(wkbHex); Geometry g2 = wkbReader.read(wkb); CoordinateSequenceComparator comp = (dimension == 2) ? comp2 : comp3; boolean isEqual = (g.compareTo(g2, comp) == 0); assertTrue(isEqual); if (includeSRID) { boolean isSRIDEqual = g.getSRID() == g2.getSRID(); assertTrue(isSRIDEqual); } } }