use of org.neo4j.gis.spatial.index.curves.SpaceFillingCurve in project neo4j by neo4j.
the class GenericKeyStateTest method comparePointArraysMustOnlyReturnZeroForEqualArrays.
@Test
void comparePointArraysMustOnlyReturnZeroForEqualArrays() {
PointArray firstArray = random.randomValues().nextPointArray();
PointValue[] sourcePointValues = firstArray.asObjectCopy();
PointArray equalArray = Values.pointArray(sourcePointValues);
PointValue[] centerPointValues = new PointValue[sourcePointValues.length];
for (int i = 0; i < sourcePointValues.length; i++) {
PointValue sourcePointValue = sourcePointValues[i];
CoordinateReferenceSystem crs = sourcePointValue.getCoordinateReferenceSystem();
SpaceFillingCurve curve = noSpecificIndexSettings.forCrs(crs);
Long spaceFillingCurveValue = curve.derivedValueFor(sourcePointValue.coordinate());
centerPointValues[i] = Values.pointValue(crs, curve.centerPointFor(spaceFillingCurveValue));
}
PointArray centerArray = Values.pointArray(centerPointValues);
GenericKey firstKey = newKeyState();
firstKey.writeValue(firstArray, NEUTRAL);
GenericKey equalKey = newKeyState();
equalKey.writeValue(equalArray, NEUTRAL);
GenericKey centerKey = newKeyState();
centerKey.writeValue(centerArray, NEUTRAL);
GenericKey noCoordsKey = newKeyState();
noCoordsKey.writeValue(equalArray, NEUTRAL);
GeometryType.setNoCoordinates(noCoordsKey);
assertEquals(0, firstKey.compareValueTo(equalKey), "expected keys to be equal");
assertEquals(firstArray.compareToSequence(centerArray, AnyValues.COMPARATOR) != 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");
}
Aggregations