private static Geometry<?> parseWkt(String pgValue) { final WktDecoder decoder = Wkt.newDecoder( Wkt.Dialect.POSTGIS_EWKT_1 ); return decoder.decode( pgValue ); }
if ( testDataElement.type.equalsIgnoreCase( type ) ) { try { result.put( testDataElement.id, decoder.decode( testDataElement.wkt ) );
static GeomEntity createFrom(TestDataElement element, Dialect dialect) throws WktDecodeException { WktDecoder decoder = getWktDecoder( dialect ); 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 JtsGeomEntity createFrom(TestDataElement element, Dialect dialect) throws ParseException { WktDecoder decoder = getWktDecoder( dialect ); Geometry geom = JTS.to( decoder.decode( element.wkt ) ); JtsGeomEntity result = new JtsGeomEntity(); result.setId( element.id ); result.setGeom( geom ); result.setType( element.type ); return result; }
@Override @Nullable public Geometry getValue(ResultSet rs, int startIndex) throws SQLException { Clob clob = rs.getClob(startIndex); String str = clob != null ? clob.getSubString(1, (int) clob.length()) : null; if (str != null) { return Wkt.newDecoder(Wkt.Dialect.POSTGIS_EWKT_1).decode(str); } else { return null; } }
@Override @Nullable public Geometry getValue(ResultSet rs, int startIndex) throws SQLException { Clob clob = rs.getClob(startIndex); String str = clob != null ? clob.getSubString(1, (int) clob.length()) : null; if (str != null) { return Wkt.newDecoder(Wkt.Dialect.POSTGIS_EWKT_1).decode(str); } else { return null; } }
@Override @Nullable public Geometry getValue(ResultSet rs, int startIndex) throws SQLException { String str = rs.getString(startIndex); if (str != null) { return Wkt.newDecoder(Wkt.Dialect.POSTGIS_EWKT_1).decode(str); } else { return null; } }
@Override @Nullable public Geometry getValue(ResultSet rs, int startIndex) throws SQLException { String str = rs.getString(startIndex); if (str != null) { return Wkt.newDecoder(Wkt.Dialect.POSTGIS_EWKT_1).decode(str); } else { return null; } }
/** * Decodes the specified WKT String to a <code>Geometry</code>. * <p>This method uses the default WKT dialect (Postgis v1.5 EWKT)</p> * * @param wkt the WKT string to decode * @return The decoded Geometry */ public static <P extends Position> Geometry<P> fromWkt(String wkt, CoordinateReferenceSystem<P> crs) { WktDecoder decoder = newDecoder(); return decoder.decode(wkt,crs); }
@Override public Geometry<?> decode(Clob clob) { String wkt = clobToString( clob ); WktDecoder decoder = Wkt.newDecoder( Wkt.Dialect.DB2_WKT ); if ( wkt.substring( 0, 4 ).toUpperCase().startsWith( "SRID" ) ) { return decoder.decode( wkt ); } else { return decoder.decode( String.format( "SRID=%d;%s", srid, wkt ) ); } }
public static Geometry<?> fromWkt(String wkt) { WktDecoder decoder = newDecoder(); return decoder.decode(wkt); }
@Test public void valid_wkt() { for (String wkt : Connections.getSpatialData().values()) { assertNotNull(Wkt.newDecoder(Wkt.Dialect.POSTGIS_EWKT_1).decode(wkt)); } }
private Object convertInternal(Object obj){ if (obj instanceof PGobject){ String pgValue = ((PGobject)obj).getValue(); if (pgValue.charAt(0) == 'S') { WktDecoder decoder = Wkt.newDecoder(Wkt.Dialect.POSTGIS_EWKT_1); return decoder.decode(pgValue); } ByteBuffer buffer = ByteBuffer.from(pgValue); WkbDecoder decoder = Wkb.newDecoder(Wkb.Dialect.POSTGIS_EWKB_1); return decoder.decode(buffer); } byte[] bytes=Converters.getDefault().convertObject(obj, byte[].class); WkbDecoder decoder = Wkb.newDecoder(Wkb.Dialect.POSTGIS_EWKB_1); return decoder.decode(ByteBuffer.from(bytes)); }