use of org.neo4j.values.storable.CoordinateReferenceSystem in project neo4j by neo4j.
the class Neo4jPackV2Test method randomPoint.
private PointValue randomPoint(int index, int dimension) {
CoordinateReferenceSystem crs;
if (index % 2 == 0) {
double[] coordinates;
double x = random.doubles(1, -180, 180).sum();
double y = random.doubles(1, -90, 90).sum();
crs = WGS84_3D;
if (dimension == 2) {
crs = WGS84;
coordinates = new double[] { x, y };
return unsafePointValue(crs, coordinates);
}
if (dimension == 3) {
double z = random.doubles(1, Double.MIN_VALUE, Double.MAX_VALUE).sum();
coordinates = new double[] { x, y, z };
return unsafePointValue(crs, coordinates);
}
} else {
crs = dimension == 2 ? Cartesian : Cartesian_3D;
}
return unsafePointValue(crs, random.doubles(dimension, Double.MIN_VALUE, Double.MAX_VALUE).toArray());
}
use of org.neo4j.values.storable.CoordinateReferenceSystem 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.CoordinateReferenceSystem in project neo4j by neo4j.
the class CompositeIndexAccessorCompatibility method testIndexSeekExactWithRange.
private void testIndexSeekExactWithRange(Value base1, Value base2, Value obj1, Value obj2, Value obj3, Value obj4, Value obj5) throws Exception {
Assume.assumeTrue("Assume support for granular composite queries", testSuite.supportsGranularCompositeQueries());
updateAndCommit(asList(add(1L, descriptor.schema(), base1, obj1), add(2L, descriptor.schema(), base1, obj2), add(3L, descriptor.schema(), base1, obj3), add(4L, descriptor.schema(), base1, obj4), add(5L, descriptor.schema(), base1, obj5), add(6L, descriptor.schema(), base2, obj1), add(7L, descriptor.schema(), base2, obj2), add(8L, descriptor.schema(), base2, obj3), add(9L, descriptor.schema(), base2, obj4), add(10L, descriptor.schema(), base2, obj5)));
assertThat(query(exact(0, base1), range(1, obj2, true, obj4, false))).isEqualTo(asList(2L, 3L));
assertThat(query(exact(0, base1), range(1, obj4, true, null, false))).isEqualTo(asList(4L, 5L));
assertThat(query(exact(0, base1), range(1, obj4, false, null, true))).isEqualTo(singletonList(5L));
assertThat(query(exact(0, base1), range(1, obj5, false, obj2, true))).isEqualTo(EMPTY_LIST);
assertThat(query(exact(0, base1), range(1, null, false, obj3, false))).isEqualTo(asList(1L, 2L));
assertThat(query(exact(0, base1), range(1, null, true, obj3, true))).isEqualTo(asList(1L, 2L, 3L));
assertThat(query(exact(0, base1), range(1, obj1, false, obj2, true))).isEqualTo(singletonList(2L));
assertThat(query(exact(0, base1), range(1, obj1, false, obj3, false))).isEqualTo(singletonList(2L));
assertThat(query(exact(0, base2), range(1, obj2, true, obj4, false))).isEqualTo(asList(7L, 8L));
assertThat(query(exact(0, base2), range(1, obj4, true, null, false))).isEqualTo(asList(9L, 10L));
assertThat(query(exact(0, base2), range(1, obj4, false, null, true))).isEqualTo(singletonList(10L));
assertThat(query(exact(0, base2), range(1, obj5, false, obj2, true))).isEqualTo(EMPTY_LIST);
assertThat(query(exact(0, base2), range(1, null, false, obj3, false))).isEqualTo(asList(6L, 7L));
assertThat(query(exact(0, base2), range(1, null, true, obj3, true))).isEqualTo(asList(6L, 7L, 8L));
assertThat(query(exact(0, base2), range(1, obj1, false, obj2, true))).isEqualTo(singletonList(7L));
assertThat(query(exact(0, base2), range(1, obj1, false, obj3, false))).isEqualTo(singletonList(7L));
ValueGroup valueGroup = obj1.valueGroup();
if (valueGroup != GEOMETRY && valueGroup != GEOMETRY_ARRAY) {
assertThat(query(exact(0, base1), range(1, valueGroup))).isEqualTo(asList(1L, 2L, 3L, 4L, 5L));
assertThat(query(exact(0, base2), range(1, valueGroup))).isEqualTo(asList(6L, 7L, 8L, 9L, 10L));
} else {
CoordinateReferenceSystem crs = getCrs(obj1);
assertThat(query(exact(0, base1), range(1, crs))).isEqualTo(asList(1L, 2L, 3L, 4L, 5L));
assertThat(query(exact(0, base2), range(1, crs))).isEqualTo(asList(6L, 7L, 8L, 9L, 10L));
}
}
use of org.neo4j.values.storable.CoordinateReferenceSystem in project neo4j by neo4j.
the class AppendOnlyValuesContainer method readPoint.
private static PointValue readPoint(ByteBuffer chunk, int offset) {
final int crsCode = chunk.getInt(offset);
offset += Integer.BYTES;
final CoordinateReferenceSystem crs = CoordinateReferenceSystem.get(crsCode);
final double[] coordinate = new double[crs.getDimension()];
for (int i = 0; i < coordinate.length; i++) {
coordinate[i] = chunk.getDouble(offset);
offset += Double.BYTES;
}
return pointValue(crs, coordinate);
}
use of org.neo4j.values.storable.CoordinateReferenceSystem in project neo4j by neo4j.
the class SpatialIndexConfigTest method mustAddSpatialConfigToMap.
@Test
void mustAddSpatialConfigToMap() {
Map<String, Value> map = new HashMap<>();
for (CoordinateReferenceSystem crs : CoordinateReferenceSystem.all()) {
Config config = Config.defaults();
SpaceFillingCurveSettings spaceFillingCurveSettings = new ConfiguredSpaceFillingCurveSettingsCache(config).forCRS(crs);
SpatialIndexConfig.addSpatialConfig(map, crs, spaceFillingCurveSettings);
assertNotNull(map.remove(IndexSettingUtil.spatialMinSettingForCrs(crs).getSettingName()));
assertNotNull(map.remove(IndexSettingUtil.spatialMaxSettingForCrs(crs).getSettingName()));
assertTrue(map.isEmpty());
}
}
Aggregations