use of org.postgis.Point in project tests by datanucleus.
the class PgGeometrySpatialTest method testPointFromWKB.
public void testPointFromWKB() throws SQLException {
PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();
try {
tx.begin();
Point geom = new Point("SRID=4326;POINT(75 75)");
Query query = pm.newQuery(SamplePoint.class, "geom != null && Spatial.equals(geom, Spatial.pointFromWKB(Spatial.asBinary(:geom), Spatial.srid(:geom)))");
List list = (List) query.execute(geom);
assertEquals("Wrong number of geometries with a given wkb returned", 1, list.size());
assertTrue("Point 2 should be in the list of geometries with a given wkb", list.contains(getSamplePoint(2)));
} finally {
tx.commit();
}
}
use of org.postgis.Point in project tests by datanucleus.
the class PgGeometrySpatialTest method testStartPoint.
public void testStartPoint() throws SQLException {
PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();
try {
tx.begin();
Point point = new Point("SRID=4326;POINT(50 0)");
Query query = pm.newQuery(SampleLineString.class, "geom != null && Spatial.equals(Spatial.startPoint(geom), :point)");
List list = (List) query.execute(point);
assertEquals("Wrong number of geometries with a given start point returned", 1, list.size());
assertTrue("LineString 2 should be in the list of geometries with a given start point", list.contains(getSampleLineString(2)));
query = pm.newQuery(SampleLineString.class, "id == :id");
query.setResult("Spatial.startPoint(geom)");
query.setUnique(true);
Geometry point_read = (Geometry) query.execute(new Long(getSampleLineString(2).getId()));
assertEquals("Returned start point should be equal to the given point", point, point_read);
} finally {
tx.commit();
}
}
use of org.postgis.Point in project tests by datanucleus.
the class PgGeometrySpatialTest method testGeomFromWKB.
public void testGeomFromWKB() throws SQLException {
PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();
try {
tx.begin();
Point geom = new Point("SRID=4326;POINT(10 10)");
Query query = pm.newQuery(SamplePoint.class, "geom != null && Spatial.equals(geom, Spatial.geomFromWKB(Spatial.asBinary(:geom), Spatial.srid(:geom)))");
List list = (List) query.execute(geom);
assertEquals("Wrong number of geometries with a given wkb returned", 1, list.size());
assertTrue("Point 1 should be in the list of geometries with a given wkb", list.contains(getSamplePoint(1)));
} finally {
tx.commit();
}
}
use of org.postgis.Point in project sqlg by pietermartin.
the class TestGis method testPoint.
@Test
public void testPoint() {
Point johannesburgPoint = new Point(26.2044, 28.0456);
Vertex johannesburg = this.sqlgGraph.addVertex(T.label, "Gis", "point", johannesburgPoint);
Point pretoriaPoint = new Point(25.7461, 28.1881);
Vertex pretoria = this.sqlgGraph.addVertex(T.label, "Gis", "point", pretoriaPoint);
this.sqlgGraph.tx().commit();
Assert.assertEquals(johannesburgPoint, this.sqlgGraph.traversal().V(johannesburg.id()).next().value("point"));
Assert.assertEquals(pretoriaPoint, this.sqlgGraph.traversal().V(pretoria.id()).next().value("point"));
Gis gis = this.sqlgGraph.gis();
System.out.println(gis.distanceBetween(johannesburgPoint, pretoriaPoint));
johannesburgPoint = new Point(26.2055, 28.0477);
johannesburg.property("point", johannesburgPoint);
this.sqlgGraph.tx().commit();
Assert.assertEquals(johannesburgPoint, this.sqlgGraph.traversal().V(johannesburg.id()).next().value("point"));
}
use of org.postgis.Point in project sqlg by pietermartin.
the class TestGisBulkWithin method testBulkWithinLineString.
@Test
public void testBulkWithinLineString() {
Point point1 = new Point(26.2044, 28.0456);
Point point2 = new Point(26.2045, 28.0457);
LineString lineString1 = new LineString(new Point[] { point1, point2 });
Point point3 = new Point(26.2046, 28.0458);
LineString lineString2 = new LineString(new Point[] { point1, point3 });
LineString lineString3 = new LineString(new Point[] { point2, point3 });
Point point4 = new Point(26.2047, 28.0459);
LineString lineString4 = new LineString(new Point[] { point1, point4 });
Vertex v1 = this.sqlgGraph.addVertex(T.label, "Gis", "line", lineString1);
Vertex v2 = this.sqlgGraph.addVertex(T.label, "Gis", "line", lineString2);
Vertex v3 = this.sqlgGraph.addVertex(T.label, "Gis", "line", lineString3);
Vertex v4 = this.sqlgGraph.addVertex(T.label, "Gis", "line", lineString4);
this.sqlgGraph.tx().commit();
List<Vertex> vertices = this.sqlgGraph.traversal().V().hasLabel("Gis").has("line", P.within(lineString1, lineString3, lineString4)).toList();
Assert.assertEquals(3, vertices.size());
Assert.assertTrue(Arrays.asList(v1, v3, v4).containsAll(vertices));
}
Aggregations