Search in sources :

Example 16 with GeometryType

use of org.teiid.core.types.GeometryType in project teiid by teiid.

the class TestGeometry method testGmlParseSrid.

@Test
public void testGmlParseSrid() throws Exception {
    String gml = "<gml:Polygon srsName=\"SDO:8307\" xmlns:gml=\"http://www.opengis.net/gml\"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates decimal=\".\" cs=\",\" ts=\" \">5,1 8,1 8,6 5,7 5,1 </gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon>";
    GeometryType gt = GeometryUtils.geometryFromGml(new ClobType(ClobImpl.createClob(gml.toCharArray())), null);
    assertEquals(8307, gt.getSrid());
    // oracle will leave of the int with unknown
    gml = "<gml:Polygon srsName=\"SDO:\" xmlns:gml=\"http://www.opengis.net/gml\"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates decimal=\".\" cs=\",\" ts=\" \">5,1 8,1 8,6 5,7 5,1 </gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon>";
    gt = GeometryUtils.geometryFromGml(new ClobType(ClobImpl.createClob(gml.toCharArray())), null);
    assertEquals(GeometryType.UNKNOWN_SRID, gt.getSrid());
}
Also used : ClobType(org.teiid.core.types.ClobType) GeometryType(org.teiid.core.types.GeometryType) Test(org.junit.Test)

Example 17 with GeometryType

use of org.teiid.core.types.GeometryType in project teiid by teiid.

the class TestJDBCSocketTransport method testGeometryStreaming.

@Test
public void testGeometryStreaming() throws Exception {
    StringBuilder geomString = new StringBuilder();
    for (int i = 0; i < 600; i++) {
        geomString.append("100 100,");
    }
    geomString.append("100 100");
    final GeometryType geo = GeometryUtils.geometryFromClob(new ClobType(new ClobImpl("POLYGON ((" + geomString + "))")));
    long length = geo.length();
    PreparedStatement s = conn.prepareStatement("select st_geomfrombinary(?)");
    s.setBlob(1, new BlobImpl(new InputStreamFactory() {

        @Override
        public InputStream getInputStream() throws IOException {
            try {
                return geo.getBinaryStream();
            } catch (SQLException e) {
                throw new IOException(e);
            }
        }
    }));
    ResultSet rs = s.executeQuery();
    rs.next();
    Blob b = rs.getBlob(1);
    assertEquals(length, b.length());
    b.getBytes(1, (int) b.length());
    toggleInline(false);
    rs = s.executeQuery();
    rs.next();
    b = rs.getBlob(1);
    assertEquals(length, b.length());
    b.getBytes(1, (int) b.length());
}
Also used : Blob(java.sql.Blob) TeiidSQLException(org.teiid.jdbc.TeiidSQLException) SQLException(java.sql.SQLException) PreparedStatement(java.sql.PreparedStatement) IOException(java.io.IOException) InputStreamFactory(org.teiid.core.types.InputStreamFactory) ClobType(org.teiid.core.types.ClobType) GeometryType(org.teiid.core.types.GeometryType) ResultSet(java.sql.ResultSet) ClobImpl(org.teiid.core.types.ClobImpl) BlobImpl(org.teiid.core.types.BlobImpl) Test(org.junit.Test)

Aggregations

GeometryType (org.teiid.core.types.GeometryType)17 Test (org.junit.Test)8 Blob (java.sql.Blob)4 BinaryType (org.teiid.core.types.BinaryType)4 BasicDBList (com.mongodb.BasicDBList)3 BasicDBObject (com.mongodb.BasicDBObject)3 IOException (java.io.IOException)3 BigInteger (java.math.BigInteger)3 SQLException (java.sql.SQLException)3 BlobImpl (org.teiid.core.types.BlobImpl)3 ClobImpl (org.teiid.core.types.ClobImpl)3 ClobType (org.teiid.core.types.ClobType)3 InputStreamFactory (org.teiid.core.types.InputStreamFactory)3 BasicDBObjectBuilder (com.mongodb.BasicDBObjectBuilder)2 DBObject (com.mongodb.DBObject)2 InputStream (java.io.InputStream)2 BigDecimal (java.math.BigDecimal)2 PreparedStatement (java.sql.PreparedStatement)2 GridFS (com.mongodb.gridfs.GridFS)1 GridFSInputFile (com.mongodb.gridfs.GridFSInputFile)1