Search in sources :

Example 1 with SampleGeometry3D

use of org.datanucleus.samples.jgeometry.SampleGeometry3D in project tests by datanucleus.

the class JGeometry3dMMappingTest method testPointMMapping.

public void testPointMMapping() throws SQLException {
    if (!runTestsForDatastore()) {
        return;
    }
    // point with measure in third dimension
    int gtype = 3301;
    int srid = 4326;
    int[] elemInfo = { 1, 1, 1 };
    double[] ordinates = { 10.0, 10.0, 100.0 };
    JGeometry point = new JGeometry(gtype, srid, elemInfo, ordinates);
    SampleGeometry3D samplePoint;
    SampleGeometry3D samplePoint_read;
    PersistenceManager pm = pmf.getPersistenceManager();
    Transaction tx = pm.currentTransaction();
    Object id = null;
    try {
        tx.begin();
        samplePoint = new SampleGeometry3D(1101, "Point with measure", point);
        pm.makePersistent(samplePoint);
        id = JDOHelper.getObjectId(samplePoint);
        samplePoint = (SampleGeometry3D) pm.detachCopy(samplePoint);
        tx.commit();
    } finally {
        if (tx.isActive()) {
            tx.rollback();
        }
        pm.close();
    }
    pm = pmf.getPersistenceManager();
    tx = pm.currentTransaction();
    try {
        tx.begin();
        samplePoint_read = (SampleGeometry3D) pm.getObjectById(id, true);
        assertEquals(samplePoint, samplePoint_read);
        tx.commit();
    } finally {
        if (tx.isActive()) {
            tx.rollback();
        }
        pm.close();
    }
}
Also used : Transaction(javax.jdo.Transaction) PersistenceManager(javax.jdo.PersistenceManager) JGeometry(oracle.spatial.geometry.JGeometry) SampleGeometry3D(org.datanucleus.samples.jgeometry.SampleGeometry3D)

Aggregations

PersistenceManager (javax.jdo.PersistenceManager)1 Transaction (javax.jdo.Transaction)1 JGeometry (oracle.spatial.geometry.JGeometry)1 SampleGeometry3D (org.datanucleus.samples.jgeometry.SampleGeometry3D)1