Search in sources :

Example 11 with Geometry

use of org.geolatte.geom.Geometry in project querydsl by querydsl.

the class SQLServerGeometryWriterTest method roundTrip.

@Test
public void roundTrip() throws IOException {
    for (Geometry geometry : getGeometries()) {
        byte[] bytes = new SQLServerGeometryWriter().write(geometry);
        Geometry geometry2 = new SQLServerGeometryReader().read(bytes);
        assertEquals(geometry, geometry2);
    }
}
Also used : Geometry(org.geolatte.geom.Geometry) Test(org.junit.Test)

Example 12 with Geometry

use of org.geolatte.geom.Geometry in project hibernate-orm by hibernate.

the class DataSourceUtils method expectedGeoms.

/**
 * Returns the JTS geometries that are expected of a decoding of the testsuite-suite object's geometry.
 * <p/>
 * <p>This method reads the WKT of the testsuite-suite objects and returns the result.</p>
 *
 * @param type type of geometry
 *
 * @return map of identifier and JTS geometry
 */
public Map<Integer, Geometry> expectedGeoms(String type, TestData testData) {
    Map<Integer, Geometry> result = new HashMap<Integer, Geometry>();
    WktDecoder decoder = Wkt.newDecoder();
    for (TestDataElement testDataElement : testData) {
        if (testDataElement.type.equalsIgnoreCase(type)) {
            try {
                result.put(testDataElement.id, decoder.decode(testDataElement.wkt));
            } catch (WktDecodeException e) {
                System.out.println(String.format("Parsing WKT fails for case %d : %s", testDataElement.id, testDataElement.wkt));
                throw new RuntimeException(e);
            }
        }
    }
    return result;
}
Also used : Geometry(org.geolatte.geom.Geometry) WktDecoder(org.geolatte.geom.codec.WktDecoder) HashMap(java.util.HashMap) WktDecodeException(org.geolatte.geom.codec.WktDecodeException)

Aggregations

Geometry (org.geolatte.geom.Geometry)12 CallableStatement (java.sql.CallableStatement)4 PreparedStatement (java.sql.PreparedStatement)4 WrapperOptions (org.hibernate.type.descriptor.WrapperOptions)4 BasicBinder (org.hibernate.type.descriptor.sql.BasicBinder)4 WktDecoder (org.geolatte.geom.codec.WktDecoder)3 Test (org.junit.Test)3 WkbEncoder (org.geolatte.geom.codec.WkbEncoder)2 SDOGeometry (org.geolatte.geom.codec.db.oracle.SDOGeometry)2 HashMap (java.util.HashMap)1 ByteBuffer (org.geolatte.geom.ByteBuffer)1 WktDecodeException (org.geolatte.geom.codec.WktDecodeException)1 MetadataSources (org.hibernate.boot.MetadataSources)1 StandardServiceRegistry (org.hibernate.boot.registry.StandardServiceRegistry)1 StandardServiceRegistryBuilder (org.hibernate.boot.registry.StandardServiceRegistryBuilder)1 MetadataBuilderImplementor (org.hibernate.boot.spi.MetadataBuilderImplementor)1 SessionFactoryImplementor (org.hibernate.engine.spi.SessionFactoryImplementor)1 JpaAttributeConverter (org.hibernate.metamodel.model.convert.spi.JpaAttributeConverter)1 EntityPersister (org.hibernate.persister.entity.EntityPersister)1 DecodeUtil.getWktDecoder (org.hibernate.spatial.integration.DecodeUtil.getWktDecoder)1