public static WktDecoder getWktDecoder(Dialect dialect) { WktDecoder decoder = null; if ( dialect instanceof AbstractHANADialect ) { decoder = Wkt.newDecoder( Wkt.Dialect.HANA_EWKT ); } else if ( dialect instanceof DB2SpatialDialect ) { decoder = Wkt.newDecoder( Wkt.Dialect.DB2_WKT ); } else { decoder = Wkt.newDecoder( Wkt.Dialect.POSTGIS_EWKT_1 ); } return decoder; } }
private static Geometry<?> parseWkt(String pgValue) { final WktDecoder decoder = Wkt.newDecoder( Wkt.Dialect.POSTGIS_EWKT_1 ); return decoder.decode( pgValue ); }
WktDecoder decoder = Wkt.newDecoder(); for ( TestDataElement testDataElement : testData ) { if ( testDataElement.type.equalsIgnoreCase( type ) ) {
/** * Creates a <code>WktDecoder</code> for the default dialect (Postgis 1.x EWKT). * @return an <code>WktDecoder</code> that supports the default dialect * @return */ public static WktDecoder newDecoder() { return newDecoder(DEFAULT_DIALECT); }
@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); }
public static Geometry<?> fromWkt(String wkt) { WktDecoder decoder = newDecoder(); return decoder.decode(wkt); }
@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 ) ); } }
@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)); }