示例#1
0
 public static GeomEntity createFrom(TestDataElement element) throws WktDecodeException {
   WktDecoder decoder = Wkt.newDecoder(Wkt.Dialect.POSTGIS_EWKT_1);
   Geometry geom = decoder.decode(element.wkt);
   GeomEntity result = new GeomEntity();
   result.setId(element.id);
   result.setGeom(geom);
   result.setType(element.type);
   return result;
 }
 public static Geometry toGeometry(Object object) {
   if (object == null) {
     return null;
   }
   ByteBuffer buffer = null;
   if (object instanceof PGobject) {
     String pgValue = ((PGobject) object).getValue();
     if (pgValue.charAt(0) == 'S') { // /we have a Wkt value
       final WktDecoder decoder = Wkt.newDecoder(Wkt.Dialect.POSTGIS_EWKT_1);
       return decoder.decode(pgValue);
     } else {
       buffer = ByteBuffer.from(pgValue);
       final WkbDecoder decoder = Wkb.newDecoder(Wkb.Dialect.POSTGIS_EWKB_1);
       return decoder.decode(buffer);
     }
   }
   throw new IllegalStateException(
       "Received object of type " + object.getClass().getCanonicalName());
 }