use of org.neo4j.graphdb.spatial.Point in project neo4j by neo4j.
the class GraphDatabaseServiceExecuteTest method shouldNotReturnInternalGeographicPointType.
@Test
void shouldNotReturnInternalGeographicPointType() {
try (Transaction transaction = db.beginTx()) {
// when
Result execute = transaction.execute("RETURN point({longitude: 144.317718, latitude: -37.031738}) AS p");
// then
Object obj = execute.next().get("p");
assertThat(obj, Matchers.instanceOf(Point.class));
Point point = (Point) obj;
assertThat(point.getCoordinate().getCoordinate().get(0), equalTo(144.317718));
assertThat(point.getCoordinate().getCoordinate().get(1), equalTo(-37.031738));
CRS crs = point.getCRS();
assertThat(crs.getCode(), equalTo(4326));
assertThat(crs.getType(), equalTo("wgs-84"));
assertThat(crs.getHref(), equalTo("http://spatialreference.org/ref/epsg/4326/"));
transaction.commit();
}
}
use of org.neo4j.graphdb.spatial.Point in project neo4j by neo4j.
the class GraphDatabaseServiceExecuteTest method shouldBeAbleToUseExternalPointAsParameterToQuery.
@Test
void shouldBeAbleToUseExternalPointAsParameterToQuery() {
// given a point created from public interface
Point point = makeFakePoint(144.317718, -37.031738, makeWGS84());
try (Transaction transaction = db.beginTx()) {
// when passing as params to a distance function
Result result = transaction.execute("RETURN distance(point({longitude: 144.317718, latitude: -37.031738}),$previous) AS dist", map("previous", point));
// then
Double dist = (Double) result.next().get("dist");
assertThat(dist, equalTo(0.0));
transaction.commit();
}
}
use of org.neo4j.graphdb.spatial.Point in project neo4j by neo4j.
the class GraphDatabaseServiceExecuteTest method shouldBeAbleToUseExternalPointArrayAsParameterToQuery.
@Test
void shouldBeAbleToUseExternalPointArrayAsParameterToQuery() {
// given a point created from public interface
Point point = makeFakePoint(144.317718, -37.031738, makeWGS84());
Point[] points = new Point[] { point, point };
// when passing as params to a distance function
try (Transaction transaction = db.beginTx()) {
Result result = transaction.execute("RETURN distance($points[0],$points[1]) AS dist", map("points", points));
// then
Double dist = (Double) result.next().get("dist");
assertThat(dist, equalTo(0.0));
transaction.commit();
}
}
use of org.neo4j.graphdb.spatial.Point in project neo4j by neo4j.
the class GraphDatabaseServiceExecuteTest method shouldBeAbleToUseResultingPointFromOneQueryAsParameterToNext.
@Test
void shouldBeAbleToUseResultingPointFromOneQueryAsParameterToNext() {
try (Transaction transaction = db.beginTx()) {
// given a point create by one cypher query
Result execute = transaction.execute("RETURN point({longitude: 144.317718, latitude: -37.031738}) AS p");
Point point = (Point) execute.next().get("p");
// when passing as params to a distance function
Result result = transaction.execute("RETURN distance(point({longitude: 144.317718, latitude: -37.031738}),$previous) AS dist", map("previous", point));
// then
Double dist = (Double) result.next().get("dist");
assertThat(dist, equalTo(0.0));
transaction.commit();
}
}
use of org.neo4j.graphdb.spatial.Point in project neo4j by neo4j.
the class Neo4jJsonCodecTest method testCartesian3DPointWriting.
@Test
void testCartesian3DPointWriting() throws IOException {
// Given
Point value = SpatialMocks.mockPoint(123.0, 456.0, 789.0, mockCartesian_3D());
// When
jsonCodec.writeValue(jsonGenerator, value);
// Then
verify(jsonGenerator, times(3)).writeEndObject();
}
Aggregations