private static Geometry<?> parseWkt(String pgValue) { final WktDecoder decoder = Wkt.newDecoder( Wkt.Dialect.POSTGIS_EWKT_1 ); return decoder.decode( pgValue ); }
@Override public Geometry fromString(String string) { return Wkt.fromWkt( string ); }
@Test public void testWktWithoutSrid() throws SQLException { String wkt = Wkt.toWkt( geom ).split( ";" )[1]; testCase( wkt, geomNoSrid ); }
/** * Creates a <code>WktEncoder</code> for the default dialect (Postgis 1.x EWKT). * @return an <code>WktEncoder</code> that supports the default dialect */ public static WktEncoder newEncoder() { return newEncoder(DEFAULT_DIALECT); }
/** * Creates a <code>WktEncoder</code> for the specified WKT <code>Dialect</code>. * * @param dialect the WKT dialect * @return an <code>WktEncoder</code> that supports the specified dialect */ public static WktEncoder newEncoder(Dialect dialect) { Class<? extends WktEncoder> decoderClass = ENCODERS.get(dialect); assert (decoderClass != null) : "A variant declared, but no encoder/decoder registered."; return createInstance(decoderClass); }
@Override public String getLiteral(Geometry geometry) { return "'" + Wkt.newEncoder(Wkt.Dialect.POSTGIS_EWKT_1).encode(geometry) + "'"; } }
/** * Creates a <code>WktDecoder</code> for the specified WKT <code>Dialect</code>. * * @param dialect the WKT dialect * @return an <code>WktDecoder</code> that supports the specified dialect */ public static WktDecoder newDecoder(Dialect dialect) { Class<? extends WktDecoder> decoderClass = DECODERS.get(dialect); assert (decoderClass != null) : "A variant declared, but no encoder/decoder registered."; return createInstance(decoderClass); }
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; } }
/** * Encodes a <code>Geometry</code> to a WKT representation. * <p>This method uses the default WKT dialect (Postgis v1.5 EWKT)</p> * * @param geometry the <code>Geometry</code> to encode * @return the WKT representation of the given geometry */ public static String toWkt(Geometry<?> geometry) { WktEncoder encoder = newEncoder(); return encoder.encode(geometry); }
@Override public Geometry getNullableResult(ResultSet rs, String columnName) throws SQLException { String value = rs.getString(columnName); if(!StringUtils.isEmpty(value)){ return Wkt.fromWkt(value); } return null; }
@Test public void testWktWithSrid() throws SQLException { String ewkt = Wkt.toWkt( geom ); testCase( ewkt, geom ); }
WktDecoder decoder = Wkt.newDecoder(); for ( TestDataElement testDataElement : testData ) { if ( testDataElement.type.equalsIgnoreCase( type ) ) {
@Override public void setValue(PreparedStatement st, int startIndex, Geometry value) throws SQLException { String str = Wkt.newEncoder(Wkt.Dialect.POSTGIS_EWKT_1).encode(value); st.setString(startIndex, str); }
@Override public Geometry getNullableResult(ResultSet rs, int columnIndex) throws SQLException { String value = rs.getString(columnIndex); if(!StringUtils.isEmpty(value)){ return Wkt.fromWkt(value); } return null; }
/** * Returns the Well-Known Text (WKT) representation of this <code>Geometry</code>. * * @return the Well-Known Text (WKT) representation of this <code>Geometry</code>. */ public String toString() { return Wkt.toWkt(this); }
/** * 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 public void setValue(PreparedStatement st, int startIndex, Geometry value) throws SQLException { String str = Wkt.newEncoder(Wkt.Dialect.POSTGIS_EWKT_1).encode(value); st.setString(startIndex, str); }
@Override public Geometry getNullableResult(CallableStatement cs, int columnIndex) throws SQLException { String value = cs.getString(columnIndex); if(!StringUtils.isEmpty(value)){ return Wkt.fromWkt(value); } return null; }
@Override public String convertString(org.geolatte.geom.Geometry<?> value) { if (value==null){ return null; } return Wkt.toWkt(value); }
@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; } }