use of org.neo4j.graphdb.spatial.Point in project neo4j by neo4j.
the class TestPropertyTypes method testPointTypeWithTwoOtherProperties.
@Test
void testPointTypeWithTwoOtherProperties() {
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("prop2", 2);
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 testPointArray.
@Test
void testPointArray() {
Point[] array = { Values.pointValue(CoordinateReferenceSystem.Cartesian_3D, 1, 1, 1), Values.pointValue(CoordinateReferenceSystem.Cartesian_3D, 2, 1, 3) };
String key = "testpointarray";
try (Transaction transaction = getGraphDb().beginTx()) {
transaction.getNodeById(node1.getId()).setProperty(key, array);
transaction.commit();
}
try (Transaction transaction = getGraphDb().beginTx()) {
node1 = transaction.getNodeById(node1.getId());
Point[] propertyValue = (Point[]) node1.getProperty(key);
assertEquals(array.length, propertyValue.length);
for (int i = 0; i < array.length; i++) {
assertEquals(array[i], propertyValue[i]);
}
node1.removeProperty(key);
transaction.commit();
}
try (Transaction transaction = getGraphDb().beginTx()) {
assertFalse(transaction.getNodeById(node1.getId()).hasProperty(key));
transaction.commit();
}
}
use of org.neo4j.graphdb.spatial.Point in project neo4j by neo4j.
the class GeometryArrayType method asValue.
@Override
Value asValue(GenericKey state) {
Point[] points = new Point[state.arrayLength];
if (points.length > 0) {
assertHasCoordinates(state);
CoordinateReferenceSystem crs = CoordinateReferenceSystem.get((int) state.long1, (int) state.long2);
int dimensions = dimensions(state);
for (int i = 0; i < points.length; i++) {
points[i] = GeometryType.asValue(state, crs, dimensions * i);
}
}
return Values.pointArray(points);
}
use of org.neo4j.graphdb.spatial.Point in project neo4j by neo4j.
the class ValueMapperTest method parameters.
private static Stream<AnyValue> parameters() {
NodeValue node1 = nodeValue(1, stringArray(), EMPTY_MAP);
NodeValue node2 = nodeValue(2, stringArray(), EMPTY_MAP);
NodeValue node3 = nodeValue(3, stringArray(), EMPTY_MAP);
RelationshipValue relationship1 = relationshipValue(100, node1, node2, stringValue("ONE"), EMPTY_MAP);
RelationshipValue relationship2 = relationshipValue(200, node2, node2, stringValue("TWO"), EMPTY_MAP);
return Stream.of(node1, relationship1, path(new NodeValue[] { node1, node2, node3 }, new RelationshipValue[] { relationship1, relationship2 }), map(new String[] { "alpha", "beta" }, new AnyValue[] { stringValue("one"), numberValue(2) }), NO_VALUE, list(numberValue(1), stringValue("fine"), node2), stringValue("hello world"), stringArray("hello", "brave", "new", "world"), booleanValue(false), booleanArray(new boolean[] { true, false, true }), charValue('\n'), charArray(new char[] { 'h', 'e', 'l', 'l', 'o' }), byteValue((byte) 3), byteArray(new byte[] { 0x00, (byte) 0x99, (byte) 0xcc }), shortValue((short) 42), shortArray(new short[] { 1337, (short) 0xcafe, (short) 0xbabe }), intValue(987654321), intArray(new int[] { 42, 11 }), longValue(9876543210L), longArray(new long[] { 0xcafebabe, 0x1ee7 }), floatValue(Float.MAX_VALUE), floatArray(new float[] { Float.NEGATIVE_INFINITY, Float.MIN_VALUE }), doubleValue(Double.MIN_NORMAL), doubleArray(new double[] { Double.POSITIVE_INFINITY, Double.MAX_VALUE }), datetime(2018, 1, 16, 10, 36, 43, 123456788, ZoneId.of("Europe/Stockholm")), localDateTime(2018, 1, 16, 10, 36, 43, 123456788), date(2018, 1, 16), time(10, 36, 43, 123456788, ZoneOffset.ofHours(1)), localTime(10, 36, 43, 123456788), duration(399, 4, 48424, 133701337), pointValue(Cartesian, 11, 32), pointArray(new Point[] { pointValue(Cartesian, 11, 32), pointValue(WGS84, 13, 56) }));
}
use of org.neo4j.graphdb.spatial.Point in project neo4j by neo4j.
the class GraphDatabaseServiceExecuteTest method shouldNotReturnInternalPointWhenInArray.
@SuppressWarnings("unchecked")
@Test
void shouldNotReturnInternalPointWhenInArray() {
// when
try (Transaction transaction = db.beginTx()) {
Result execute = transaction.execute("RETURN [point({longitude: 144.317718, latitude: -37.031738})] AS ps");
// then
List<Point> points = (List<Point>) execute.next().get("ps");
assertThat(points.get(0), Matchers.instanceOf(Point.class));
transaction.commit();
}
}
Aggregations