use of org.neo4j.values.storable.PointValue in project neo4j by neo4j.
the class PointPropertiesRecordFormatIT method createPointArrayPropertyOnLatestDatabase.
@Test
void createPointArrayPropertyOnLatestDatabase() {
Path storeDir = testDirectory.homePath();
Label pointNode = Label.label("PointNode");
String propertyKey = "a";
PointValue pointValue = pointValue(Cartesian, 1.0, 2.0);
DatabaseManagementService managementService = startDatabaseService(storeDir);
GraphDatabaseService database = getDefaultDatabase(managementService);
try (Transaction transaction = database.beginTx()) {
Node node = transaction.createNode(pointNode);
node.setProperty(propertyKey, new PointValue[] { pointValue, pointValue });
transaction.commit();
}
managementService.shutdown();
managementService = startDatabaseService(storeDir);
GraphDatabaseService restartedDatabase = getDefaultDatabase(managementService);
try (Transaction tx = restartedDatabase.beginTx()) {
try (ResourceIterator<Node> nodes = tx.findNodes(pointNode)) {
Node node = nodes.next();
PointValue[] points = (PointValue[]) node.getProperty(propertyKey);
assertThat(points).hasSize(2);
}
}
managementService.shutdown();
}
use of org.neo4j.values.storable.PointValue in project neo4j by neo4j.
the class PointPropertiesRecordFormatIT method createPointPropertyOnLatestDatabase.
@Test
void createPointPropertyOnLatestDatabase() {
Path storeDir = testDirectory.homePath();
Label pointNode = Label.label("PointNode");
String propertyKey = "a";
PointValue pointValue = pointValue(Cartesian, 1.0, 2.0);
DatabaseManagementService managementService = startDatabaseService(storeDir);
GraphDatabaseService database = getDefaultDatabase(managementService);
try (Transaction transaction = database.beginTx()) {
Node node = transaction.createNode(pointNode);
node.setProperty(propertyKey, pointValue);
transaction.commit();
}
managementService.shutdown();
managementService = startDatabaseService(storeDir);
GraphDatabaseService restartedDatabase = getDefaultDatabase(managementService);
try (Transaction transaction = restartedDatabase.beginTx()) {
assertNotNull(transaction.findNode(pointNode, propertyKey, pointValue));
}
managementService.shutdown();
}
use of org.neo4j.values.storable.PointValue in project neo4j by neo4j.
the class PropertyIndexQuery method range.
public static <VALUE extends Value> RangePredicate<?> range(int propertyKeyId, VALUE from, boolean fromInclusive, VALUE to, boolean toInclusive) {
if (from == null && to == null) {
throw new IllegalArgumentException("Cannot create RangePredicate without at least one bound");
}
ValueGroup valueGroup = from != null ? from.valueGroup() : to.valueGroup();
switch(valueGroup) {
case NUMBER:
return NumberRangePredicate.create(propertyKeyId, (NumberValue) from, fromInclusive, (NumberValue) to, toInclusive);
case TEXT:
return new TextRangePredicate(propertyKeyId, (TextValue) from, fromInclusive, (TextValue) to, toInclusive);
case GEOMETRY:
PointValue pFrom = (PointValue) from;
PointValue pTo = (PointValue) to;
CoordinateReferenceSystem crs = pFrom != null ? pFrom.getCoordinateReferenceSystem() : pTo.getCoordinateReferenceSystem();
return new GeometryRangePredicate(propertyKeyId, crs, pFrom, fromInclusive, pTo, toInclusive);
default:
return new RangePredicate<>(propertyKeyId, valueGroup, from, fromInclusive, to, toInclusive);
}
}
use of org.neo4j.values.storable.PointValue in project neo4j by neo4j.
the class SchemaComplianceCheckerTest method shouldCheckIndexesWithLookupFiltering.
@Test
void shouldCheckIndexesWithLookupFiltering() throws Exception {
// given
LabelSchemaDescriptor descriptor = forLabel(label1, propertyKey1);
long indexId = uniqueIndex(descriptor);
long nodeId;
try (AutoCloseable ignored = tx()) {
PointValue value = pointValue(CoordinateReferenceSystem.WGS84, 2, 4);
// (N1) w/ property
{
long propId = propertyStore.nextId(CursorContext.NULL);
nodeId = node(nodeStore.nextId(CursorContext.NULL), propId, NULL, label1);
property(propId, NULL, NULL, propertyValue(propertyKey1, value));
indexValue(descriptor, indexId, nodeId, value);
}
// (N2) w/ property
{
long propId = propertyStore.nextId(CursorContext.NULL);
long nodeId2 = node(nodeStore.nextId(CursorContext.NULL), propId, NULL, label1);
property(propId, NULL, NULL, propertyValue(propertyKey1, value));
indexValue(descriptor, indexId, nodeId2, value);
}
}
// when
checkIndexed(nodeId);
// then it should be successful
expect(ConsistencyReport.NodeConsistencyReport.class, report -> report.uniqueIndexNotUnique(any(), any(), anyLong()));
}
use of org.neo4j.values.storable.PointValue in project neo4j by neo4j.
the class PrettyPrinterTest method shouldHandlePoints.
@Test
void shouldHandlePoints() {
// Given
PointValue pointValue = Values.pointValue(CoordinateReferenceSystem.Cartesian, 11d, 12d);
PrettyPrinter printer = new PrettyPrinter();
// When
pointValue.writeTo(printer);
// Then
assertThat(printer.value()).isEqualTo("{geometry: {type: \"Point\", coordinates: [11.0, 12.0], " + "crs: {type: link, properties: " + "{href: \"http://spatialreference.org/ref/sr-org/7203/\", code: " + "7203}}}}");
}
Aggregations