Search in sources :

Example 1 with WKBWriter

use of com.vividsolutions.jts.io.WKBWriter in project hibernate-orm by hibernate.

the class TestHANASpatialFunctions method geomfromewkb.

public void geomfromewkb(String pckg) throws SQLException {
    WKBWriter writer = new WKBWriter(2, true);
    byte[] ewkb = writer.write(expectationsFactory.getTestPolygon());
    Map<Integer, Geometry> dbexpected = hanaExpectationsFactory.getGeomFromEWKB(ewkb);
    String hql = format("SELECT 1, cast(geomfromewkb(:param) as %s) FROM org.hibernate.spatial.integration.%s.GeomEntity g", getGeometryTypeFromPackage(pckg), pckg);
    Map<String, Object> params = createQueryParams("param", ewkb);
    retrieveHQLResultsAndCompare(dbexpected, hql, params, pckg);
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) WKBWriter(com.vividsolutions.jts.io.WKBWriter)

Example 2 with WKBWriter

use of com.vividsolutions.jts.io.WKBWriter in project teiid by teiid.

the class TestGeometry method testEwkb.

@Test(expected = ExpressionEvaluationException.class)
public void testEwkb() throws Exception {
    WKBWriter writer = new WKBWriter(3, true);
    GeometryFactory gf = new GeometryFactory();
    Point point = gf.createPoint(new Coordinate(0, 0, 0));
    point.setSRID(100);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    writer.write(point, new OutputStreamOutStream(baos));
    Expression ex1 = TestFunctionResolving.getExpression("ST_GeomFromBinary(X'" + new BinaryType(baos.toByteArray()) + "', 8307)");
    Evaluator.evaluate(ex1);
}
Also used : WKBWriter(com.vividsolutions.jts.io.WKBWriter) GeometryFactory(com.vividsolutions.jts.geom.GeometryFactory) BinaryType(org.teiid.core.types.BinaryType) Coordinate(com.vividsolutions.jts.geom.Coordinate) Expression(org.teiid.query.sql.symbol.Expression) Point(com.vividsolutions.jts.geom.Point) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OutputStreamOutStream(com.vividsolutions.jts.io.OutputStreamOutStream) Test(org.junit.Test)

Example 3 with WKBWriter

use of com.vividsolutions.jts.io.WKBWriter in project activityinfo by bedatadriven.

the class SimpleTableStorage method toBinary.

private byte[] toBinary(Geometry geometry) {
    WKBWriter writer = new WKBWriter();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    try {
        writer.write(fixUpGeometry(geometry), new OutputStreamOutStream(baos));
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    return baos.toByteArray();
}
Also used : WKBWriter(com.vividsolutions.jts.io.WKBWriter) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) OutputStreamOutStream(com.vividsolutions.jts.io.OutputStreamOutStream)

Example 4 with WKBWriter

use of com.vividsolutions.jts.io.WKBWriter in project activityinfo by bedatadriven.

the class GeoAdminClient method toWkbBinary.

private Object toWkbBinary(Geometry value) {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    WKBWriter writer = new WKBWriter();
    try {
        writer.write(value, new OutputStreamOutStream(baos));
    } catch (IOException e) {
        throw new RuntimeException("Failed to encode geometry as WKB", e);
    }
    return baos.toByteArray();
}
Also used : WKBWriter(com.vividsolutions.jts.io.WKBWriter) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) OutputStreamOutStream(com.vividsolutions.jts.io.OutputStreamOutStream)

Example 5 with WKBWriter

use of com.vividsolutions.jts.io.WKBWriter in project teiid by teiid.

the class TestGeometry method testEwkbZCooridinate.

@Test(expected = ExpressionEvaluationException.class)
public void testEwkbZCooridinate() throws Exception {
    WKBWriter writer = new WKBWriter(3, true);
    GeometryFactory gf = new GeometryFactory();
    Point point = gf.createPoint(new Coordinate(0, 0, 0));
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    writer.write(point, new OutputStreamOutStream(baos));
    Expression ex1 = TestFunctionResolving.getExpression("ST_GeomFromBinary(X'" + new BinaryType(baos.toByteArray()) + "', 8307)");
    Evaluator.evaluate(ex1);
}
Also used : WKBWriter(com.vividsolutions.jts.io.WKBWriter) GeometryFactory(com.vividsolutions.jts.geom.GeometryFactory) BinaryType(org.teiid.core.types.BinaryType) Coordinate(com.vividsolutions.jts.geom.Coordinate) Expression(org.teiid.query.sql.symbol.Expression) Point(com.vividsolutions.jts.geom.Point) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OutputStreamOutStream(com.vividsolutions.jts.io.OutputStreamOutStream) Test(org.junit.Test)

Aggregations

WKBWriter (com.vividsolutions.jts.io.WKBWriter)6 OutputStreamOutStream (com.vividsolutions.jts.io.OutputStreamOutStream)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 Coordinate (com.vividsolutions.jts.geom.Coordinate)2 Geometry (com.vividsolutions.jts.geom.Geometry)2 GeometryFactory (com.vividsolutions.jts.geom.GeometryFactory)2 Point (com.vividsolutions.jts.geom.Point)2 IOException (java.io.IOException)2 Test (org.junit.Test)2 BinaryType (org.teiid.core.types.BinaryType)2 Expression (org.teiid.query.sql.symbol.Expression)2