use of org.neo4j.values.storable.PointValue in project neo4j by neo4j.
the class GenericKeyStateTest method comparePointsMustOnlyReturnZeroForEqualPoints.
@Test
void comparePointsMustOnlyReturnZeroForEqualPoints() {
PointValue firstPoint = random.randomValues().nextPointValue();
PointValue equalPoint = Values.point(firstPoint);
CoordinateReferenceSystem crs = firstPoint.getCoordinateReferenceSystem();
SpaceFillingCurve curve = noSpecificIndexSettings.forCrs(crs);
Long spaceFillingCurveValue = curve.derivedValueFor(firstPoint.coordinate());
PointValue centerPoint = Values.pointValue(crs, curve.centerPointFor(spaceFillingCurveValue));
GenericKey firstKey = newKeyState();
firstKey.writeValue(firstPoint, NEUTRAL);
GenericKey equalKey = newKeyState();
equalKey.writeValue(equalPoint, NEUTRAL);
GenericKey centerKey = newKeyState();
centerKey.writeValue(centerPoint, NEUTRAL);
GenericKey noCoordsKey = newKeyState();
noCoordsKey.writeValue(equalPoint, NEUTRAL);
GeometryType.setNoCoordinates(noCoordsKey);
assertEquals(0, firstKey.compareValueTo(equalKey), "expected keys to be equal");
assertEquals(firstPoint.compareTo(centerPoint) != 0, firstKey.compareValueTo(centerKey) != 0, "expected keys to be equal if and only if source points are equal");
assertEquals(0, firstKey.compareValueTo(noCoordsKey), "expected keys to be equal");
}
use of org.neo4j.values.storable.PointValue in project neo4j by neo4j.
the class GenericAccessorPointsTest method shouldNotGetRoundingErrorsWithPointsJustWithinTheTileUpperBound.
/**
* The test mustHandlePointArraysWithinSameTile was flaky on random numbers that placed points just
* within the tile upper bound, and allocated points to adjacent tiles due to rounding errors.
* This test uses a specific point that triggers that exact failure in a non-flaky way.
*/
@Test
void shouldNotGetRoundingErrorsWithPointsJustWithinTheTileUpperBound() {
PointValue origin = Values.pointValue(WGS84, 0.0, 0.0);
long derivedValueForCenterPoint = curve.derivedValueFor(origin.coordinate());
// [1.6763806343078613E-7, 8.381903171539307E-8]
double[] centerPoint = curve.centerPointFor(derivedValueForCenterPoint);
// 1.6763806343078613E-7
double xWidthMultiplier = curve.getTileWidth(0, curve.getMaxLevel()) / 2;
// 8.381903171539307E-8
double yWidthMultiplier = curve.getTileWidth(1, curve.getMaxLevel()) / 2;
double[] faultyCoords = { 1.874410632171803E-8, 1.6763806281859016E-7 };
assertTrue(centerPoint[0] + xWidthMultiplier > faultyCoords[0], "inside upper x limit");
assertTrue(centerPoint[0] - xWidthMultiplier < faultyCoords[0], "inside lower x limit");
assertTrue(centerPoint[1] + yWidthMultiplier > faultyCoords[1], "inside upper y limit");
assertTrue(centerPoint[1] - yWidthMultiplier < faultyCoords[1], "inside lower y limit");
long derivedValueForFaultyCoords = curve.derivedValueFor(faultyCoords);
assertEquals(derivedValueForCenterPoint, derivedValueForFaultyCoords, "expected same derived value");
}
use of org.neo4j.values.storable.PointValue in project neo4j by neo4j.
the class GenericAccessorPointsTest method assertDerivedValue.
private static void assertDerivedValue(Long targetDerivedValue, PointValue... values) {
for (PointValue value : values) {
Long derivedValueForValue = curve.derivedValueFor(value.coordinate());
assertEquals(targetDerivedValue, derivedValueForValue, "expected random value to belong to same tile as center point");
}
}
use of org.neo4j.values.storable.PointValue in project neo4j by neo4j.
the class GenericAccessorPointsTest method addPointsToLists.
private long addPointsToLists(List<Value> pointValues, List<IndexEntryUpdate<?>> updates, long nodeId, PointValue... values) {
for (PointValue value : values) {
pointValues.add(value);
updates.add(IndexEntryUpdate.add(nodeId++, descriptor, value));
}
return nodeId;
}
use of org.neo4j.values.storable.PointValue in project neo4j by neo4j.
the class SimpleIndexAccessorCompatibility method testIndexRangeSeekWithSpatial.
@Test
public void testIndexRangeSeekWithSpatial() throws Exception {
Assume.assumeTrue(testSuite.supportsSpatial());
PointValue p1 = Values.pointValue(CoordinateReferenceSystem.WGS84, -180, -1);
PointValue p2 = Values.pointValue(CoordinateReferenceSystem.WGS84, -180, 1);
PointValue p3 = Values.pointValue(CoordinateReferenceSystem.WGS84, 0, 0);
updateAndCommit(asList(add(1L, descriptor.schema(), p1), add(2L, descriptor.schema(), p2), add(3L, descriptor.schema(), p3)));
assertThat(query(range(1, p1, true, p2, true))).containsExactly(1L, 2L);
}
Aggregations