use of org.neo4j.graphdb.spatial.Point in project neo4j by neo4j.
the class TestPropertyTypes method testPointTypeWithOneOtherProperty.
@Test
void testPointTypeWithOneOtherProperty() {
Point point = Values.pointValue(Cartesian, 1, 1);
String key = "location";
try (Transaction transaction = getGraphDb().beginTx()) {
node1 = transaction.getNodeById(node1.getId());
node1.setProperty("prop1", 1);
node1.setProperty(key, point);
transaction.commit();
}
try (Transaction transaction = getGraphDb().beginTx()) {
Object property = transaction.getNodeById(node1.getId()).getProperty(key);
assertEquals(point, property);
transaction.commit();
}
}
use of org.neo4j.graphdb.spatial.Point in project neo4j by neo4j.
the class TestPropertyTypes method test3DPointType.
@Test
void test3DPointType() {
Point point = Values.pointValue(CoordinateReferenceSystem.Cartesian_3D, 1, 1, 1);
String key = "location";
try (Transaction transaction = getGraphDb().beginTx()) {
transaction.getNodeById(node1.getId()).setProperty(key, point);
transaction.commit();
}
try (Transaction transaction = getGraphDb().beginTx()) {
node1 = transaction.getNodeById(node1.getId());
Object property = node1.getProperty(key);
assertEquals(point, property);
transaction.commit();
}
}
use of org.neo4j.graphdb.spatial.Point in project neo4j by neo4j.
the class PointTypeIT method shouldWorkWithPoint2DArrays.
@Test
public void shouldWorkWithPoint2DArrays() throws Exception {
HTTP.Response response = runQuery("create (:Node {points: [point({x:1, y:1}), point({x:2, y:2}), point({x: 3.0, y: 3.0})]})");
assertEquals(200, response.status());
assertNoErrors(response);
var db = container().getDefaultDatabase();
try (Transaction tx = db.beginTx()) {
for (Node node : tx.getAllNodes()) {
if (node.hasLabel(label("Node")) && node.hasProperty("points")) {
Point[] points = (Point[]) node.getProperty("points");
verifyPoint(points[0], Cartesian, 1.0, 1.0);
verifyPoint(points[1], Cartesian, 2.0, 2.0);
verifyPoint(points[2], Cartesian, 3.0, 3.0);
}
}
tx.commit();
}
}
use of org.neo4j.graphdb.spatial.Point in project neo4j by neo4j.
the class GraphDatabaseServiceExecuteTest method shouldNotReturnInternalPointWhenInMap.
@SuppressWarnings("unchecked")
@Test
void shouldNotReturnInternalPointWhenInMap() {
try (Transaction transaction = db.beginTx()) {
// when
Result execute = transaction.execute("RETURN {p: point({longitude: 144.317718, latitude: -37.031738})} AS m");
// then
Map<String, Object> points = (Map<String, Object>) execute.next().get("m");
assertThat(points.get("p"), Matchers.instanceOf(Point.class));
transaction.commit();
}
}
use of org.neo4j.graphdb.spatial.Point in project neo4j by neo4j.
the class GraphDatabaseServiceExecuteTest method shouldNotReturnInternalCartesianPointType.
@Test
void shouldNotReturnInternalCartesianPointType() {
// when
try (Transaction transaction = db.beginTx()) {
Result execute = transaction.execute("RETURN point({x: 13.37, y: 13.37, crs:'cartesian'}) AS p");
// then
Object obj = execute.next().get("p");
assertThat(obj, Matchers.instanceOf(Point.class));
Point point = (Point) obj;
assertThat(point.getCoordinate(), equalTo(new Coordinate(13.37, 13.37)));
CRS crs = point.getCRS();
assertThat(crs.getCode(), equalTo(7203));
assertThat(crs.getType(), equalTo("cartesian"));
assertThat(crs.getHref(), equalTo("http://spatialreference.org/ref/sr-org/7203/"));
transaction.commit();
}
}
Aggregations