use of org.datanucleus.samples.jgeometry.SampleGeometry in project tests by datanucleus.
the class JGeometrySpatialTest method getSampleGeometryCollection.
private SampleGeometry getSampleGeometryCollection(int num) throws SQLException {
int gtype = JGeometry.GTYPE_COLLECTION;
int srid = 4326;
int[] elemInfo;
double[] ordinates;
switch(num) {
case 0:
return new SampleGeometry(7100, "Collection 0", null);
case 1:
elemInfo = new int[] { 1, 1, 1, 3, 2, 1, 7, 1003, 1 };
ordinates = new double[] { 10.0, 10.0, 0.0, 50.0, 100.0, 50.0, 25.0, 25.0, 75.0, 25.0, 75.0, 75.0, 25.0, 75.0, 25.0, 25.0 };
return new SampleGeometry(7001, "Collection 1", new JGeometry(gtype, srid, elemInfo, ordinates));
case 2:
elemInfo = new int[] { 1, 1, 1, 3, 2, 1, 7, 1003, 1 };
ordinates = new double[] { 75.0, 75.0, 50.0, 0.0, 50.0, 100.0, 75.0, 75.0, 100.0, 75.0, 100.0, 100.0, 75.0, 75.0 };
return new SampleGeometry(7002, "Collection 2", new JGeometry(gtype, srid, elemInfo, ordinates));
case 3:
elemInfo = new int[] { 1, 2, 1 };
ordinates = new double[] { 100.0, 25.0, 120.0, 25.0, 110.0, 10.0, 110.0, 45.0 };
return new SampleGeometry(7003, "Collection 3", new JGeometry(gtype, srid, elemInfo, ordinates));
}
return null;
}
use of org.datanucleus.samples.jgeometry.SampleGeometry in project tests by datanucleus.
the class JGeometryMappingTest method testMultiPointMapping.
public void testMultiPointMapping() throws SQLException {
if (!runTestsForDatastore()) {
return;
}
JGeometry multipoint = JGeometry.createMultiPoint(new Object[] { new double[] { 10, 10 }, new double[] { 75, 75 } }, 2, 4326);
SampleGeometry sampleMultiPoint;
SampleGeometry sampleMultiPoint_read;
PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();
Object id = null;
try {
tx.begin();
sampleMultiPoint = new SampleGeometry(4001, "MultiPoint", multipoint);
pm.makePersistent(sampleMultiPoint);
id = JDOHelper.getObjectId(sampleMultiPoint);
sampleMultiPoint = (SampleGeometry) pm.detachCopy(sampleMultiPoint);
tx.commit();
} finally {
if (tx.isActive()) {
tx.rollback();
}
pm.close();
}
pm = pmf.getPersistenceManager();
tx = pm.currentTransaction();
try {
tx.begin();
sampleMultiPoint_read = (SampleGeometry) pm.getObjectById(id, true);
assertEquals(sampleMultiPoint, sampleMultiPoint_read);
tx.commit();
} finally {
if (tx.isActive()) {
tx.rollback();
}
pm.close();
}
}
use of org.datanucleus.samples.jgeometry.SampleGeometry in project tests by datanucleus.
the class JGeometryMappingTest method testPolygonMapping.
public void testPolygonMapping() throws SQLException {
if (!runTestsForDatastore()) {
return;
}
JGeometry polygon = JGeometry.createLinearPolygon(new Object[] { new double[] { 25, 25, 75, 25, 75, 75, 25, 75, 25, 25 }, new double[] { 45, 45, 55, 45, 55, 55, 45, 55, 45, 45 } }, 2, 4326);
SampleGeometry samplePolygon;
SampleGeometry samplePolygon_read;
PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();
Object id = null;
try {
tx.begin();
samplePolygon = new SampleGeometry(3001, "Polygon 1", polygon);
pm.makePersistent(samplePolygon);
id = JDOHelper.getObjectId(samplePolygon);
samplePolygon = (SampleGeometry) pm.detachCopy(samplePolygon);
tx.commit();
} finally {
if (tx.isActive()) {
tx.rollback();
}
pm.close();
}
pm = pmf.getPersistenceManager();
tx = pm.currentTransaction();
try {
tx.begin();
samplePolygon_read = (SampleGeometry) pm.getObjectById(id, true);
assertEquals(samplePolygon, samplePolygon_read);
tx.commit();
} finally {
if (tx.isActive()) {
tx.rollback();
}
pm.close();
}
}
use of org.datanucleus.samples.jgeometry.SampleGeometry in project tests by datanucleus.
the class JGeometryMappingTest method testLineStringMapping.
public void testLineStringMapping() throws SQLException {
if (!runTestsForDatastore()) {
return;
}
JGeometry lineString = JGeometry.createLinearLineString(new double[] { 0, 50, 100, 50 }, 2, 4326);
SampleGeometry sampleLineString;
SampleGeometry sampleLineString_read;
PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();
Object id = null;
try {
tx.begin();
sampleLineString = new SampleGeometry(2001, "LineString 1", lineString);
pm.makePersistent(sampleLineString);
id = JDOHelper.getObjectId(sampleLineString);
sampleLineString = (SampleGeometry) pm.detachCopy(sampleLineString);
tx.commit();
} finally {
if (tx.isActive()) {
tx.rollback();
}
pm.close();
}
pm = pmf.getPersistenceManager();
tx = pm.currentTransaction();
try {
tx.begin();
sampleLineString_read = (SampleGeometry) pm.getObjectById(id, true);
assertEquals(sampleLineString, sampleLineString_read);
tx.commit();
} finally {
if (tx.isActive()) {
tx.rollback();
}
pm.close();
}
}
use of org.datanucleus.samples.jgeometry.SampleGeometry in project tests by datanucleus.
the class JGeometryMappingTest method testMultiPolygonMapping.
public void testMultiPolygonMapping() throws SQLException {
if (!runTestsForDatastore()) {
return;
}
int gtype = JGeometry.GTYPE_MULTIPOLYGON;
int srid = 4326;
int[] elemInfo = { 1, 1003, 1, 11, 2003, 1, 21, 1003, 1 };
double[] ordinates = { 25, 25, 75, 25, 75, 75, 25, 75, 25, 25, 45, 45, 45, 55, 55, 55, 55, 45, 45, 45, 75, 75, 100, 75, 100, 100, 75, 75 };
JGeometry multiPolygon = new JGeometry(gtype, srid, elemInfo, ordinates);
SampleGeometry sampleMultiPolygon;
SampleGeometry sampleMultiPolygon_read;
PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();
Object id = null;
try {
tx.begin();
sampleMultiPolygon = new SampleGeometry(6001, "MultiPolygon", multiPolygon);
pm.makePersistent(sampleMultiPolygon);
id = JDOHelper.getObjectId(sampleMultiPolygon);
sampleMultiPolygon = (SampleGeometry) pm.detachCopy(sampleMultiPolygon);
tx.commit();
} finally {
if (tx.isActive()) {
tx.rollback();
}
pm.close();
}
pm = pmf.getPersistenceManager();
tx = pm.currentTransaction();
try {
tx.begin();
sampleMultiPolygon_read = (SampleGeometry) pm.getObjectById(id, true);
assertEquals(sampleMultiPolygon, sampleMultiPolygon_read);
tx.commit();
} finally {
if (tx.isActive()) {
tx.rollback();
}
pm.close();
}
}
Aggregations