diff --git a/community/kernel-api/src/test/java/org/neo4j/internal/kernel/api/IndexQueryTest.java b/community/kernel-api/src/test/java/org/neo4j/internal/kernel/api/IndexQueryTest.java
index 58470041889ad..8f4e53382e68f 100644
--- a/community/kernel-api/src/test/java/org/neo4j/internal/kernel/api/IndexQueryTest.java
+++ b/community/kernel-api/src/test/java/org/neo4j/internal/kernel/api/IndexQueryTest.java
@@ -27,7 +27,10 @@
import org.neo4j.internal.kernel.api.IndexQuery.StringContainsPredicate;
import org.neo4j.internal.kernel.api.IndexQuery.StringPrefixPredicate;
import org.neo4j.internal.kernel.api.IndexQuery.StringRangePredicate;
+import org.neo4j.internal.kernel.api.IndexQuery.GeometryRangePredicate;
import org.neo4j.internal.kernel.api.IndexQuery.StringSuffixPredicate;
+import org.neo4j.values.storable.CoordinateReferenceSystem;
+import org.neo4j.values.storable.PointValue;
import org.neo4j.values.storable.Values;
import static org.junit.Assert.assertFalse;
@@ -49,6 +52,7 @@ public void testExists()
assertTrue( test( p, 1.0 ) );
assertTrue( test( p, true ) );
assertTrue( test( p, new long[]{1L} ) );
+ assertTrue( test( p, Values.pointValue( CoordinateReferenceSystem.WGS84, 12.3, 45.6 ) ) );
assertFalse( test( p, null ) );
}
@@ -63,6 +67,7 @@ public void testExact()
assertExactPredicate( 1.0 );
assertExactPredicate( true );
assertExactPredicate( new long[]{1L} );
+ assertExactPredicate( Values.pointValue( CoordinateReferenceSystem.WGS84, 12.3, 45.6 ) );
}
private void assertExactPredicate( Object value )
@@ -243,6 +248,91 @@ public void testStringRange_LowerUnbounded()
assertFalse( test( p, "bee" ) );
}
+ // GEOMETRY RANGE
+
+ private PointValue gps1 = Values.pointValue( CoordinateReferenceSystem.WGS84, -12.6, -56.7 );
+ private PointValue gps2 = Values.pointValue( CoordinateReferenceSystem.WGS84, -11.6, -55.7 );
+ private PointValue gps3 = Values.pointValue( CoordinateReferenceSystem.WGS84, -11.0, -55 );
+ private PointValue gps4 = Values.pointValue( CoordinateReferenceSystem.WGS84, 0, 0 );
+ private PointValue gps5 = Values.pointValue( CoordinateReferenceSystem.WGS84, 12.6, 56.7 );
+ private PointValue gps6 = Values.pointValue( CoordinateReferenceSystem.WGS84, 14.6, 58.7 );
+ private PointValue gps7 = Values.pointValue( CoordinateReferenceSystem.WGS84, 15.6, 59.7 );
+
+ //TODO: Also insert points which can't be compared e.g. Cartesian and (-100, 100)
+
+ @Test
+ public void testGeometryRange_FalseForIrrelevant()
+ {
+ GeometryRangePredicate p = IndexQuery.range( propId, gps2, true, gps5, true );
+
+ assertFalseForOtherThings( p );
+ }
+
+ @Test
+ public void testGeometryRange_InclusiveLowerInclusiveUpper()
+ {
+ GeometryRangePredicate p = IndexQuery.range( propId, gps2, true, gps5, true );
+
+ assertFalse( test( p, gps1 ) );
+ assertTrue( test( p, gps2 ) );
+ assertTrue( test( p, gps5 ) );
+ assertFalse( test( p, gps6 ) );
+ assertFalse( test( p, gps7 ) );
+ }
+
+ @Test
+ public void testGeometryRange_ExclusiveLowerInclusiveUpper()
+ {
+ GeometryRangePredicate p = IndexQuery.range( propId, gps2, false, gps5, true );
+
+ assertFalse( test( p, gps2 ) );
+ assertTrue( test( p, gps3 ) );
+ assertTrue( test( p, gps5 ) );
+ assertFalse( test( p, gps6 ) );
+ }
+
+ @Test
+ public void testGeometryRange_InclusiveLowerExclusiveUpper()
+ {
+ GeometryRangePredicate p = IndexQuery.range( propId, gps2, true, gps5, false );
+
+ assertFalse( test( p, gps1 ) );
+ assertTrue( test( p, gps2 ) );
+ assertTrue( test( p, gps3 ) );
+ assertFalse( test( p, gps5 ) );
+ }
+
+ @Test
+ public void testGeometryRange_ExclusiveLowerExclusiveUpper()
+ {
+ GeometryRangePredicate p = IndexQuery.range( propId, gps2, false, gps5, false );
+
+ assertFalse( test( p, gps2 ) );
+ assertTrue( test( p, gps3 ) );
+ assertTrue( test( p, gps4 ) );
+ assertFalse( test( p, gps5 ) );
+ }
+
+ @Test
+ public void testGeometryRange_UpperUnbounded()
+ {
+ GeometryRangePredicate p = IndexQuery.range( propId, gps2, false, null, false );
+
+ assertFalse( test( p, gps2 ) );
+ assertTrue( test( p, gps3 ) );
+ assertTrue( test( p, gps7 ) );
+ }
+
+ @Test
+ public void testGeometryRange_LowerUnbounded()
+ {
+ GeometryRangePredicate p = IndexQuery.range( propId, null, false, gps5, false );
+
+ assertTrue( test( p, gps1 ) );
+ assertTrue( test( p, gps3 ) );
+ assertFalse( test( p, gps5 ) );
+ }
+
// STRING PREFIX
@Test
diff --git a/community/kernel/src/test/java/org/neo4j/graphdb/IndexingAcceptanceTest.java b/community/kernel/src/test/java/org/neo4j/graphdb/IndexingAcceptanceTest.java
index 07dbee18a3952..8d270cfe2b8fe 100644
--- a/community/kernel/src/test/java/org/neo4j/graphdb/IndexingAcceptanceTest.java
+++ b/community/kernel/src/test/java/org/neo4j/graphdb/IndexingAcceptanceTest.java
@@ -31,6 +31,7 @@
import org.neo4j.collection.primitive.PrimitiveLongIterator;
import org.neo4j.collection.primitive.PrimitiveLongSet;
import org.neo4j.graphdb.schema.IndexDefinition;
+import org.neo4j.graphdb.spatial.Point;
import org.neo4j.helpers.collection.Iterators;
import org.neo4j.internal.kernel.api.schema.LabelSchemaDescriptor;
import org.neo4j.kernel.api.ReadOperations;
@@ -44,12 +45,17 @@
import org.neo4j.kernel.internal.GraphDatabaseAPI;
import org.neo4j.test.mockito.matcher.Neo4jMatchers;
import org.neo4j.test.rule.ImpermanentDatabaseRule;
+import org.neo4j.values.storable.CoordinateReferenceSystem;
+import org.neo4j.values.storable.PointValue;
+import org.neo4j.values.storable.Values;
import static java.lang.String.format;
import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
+import static org.neo4j.graphdb.SpatialMocks.mockCartesian;
+import static org.neo4j.graphdb.SpatialMocks.mockWGS84;
import static org.neo4j.helpers.collection.Iterators.asSet;
import static org.neo4j.helpers.collection.Iterators.count;
import static org.neo4j.helpers.collection.MapUtil.map;
@@ -353,6 +359,10 @@ public void shouldBeAbleToQuerySupportedPropertyTypes()
assertCanCreateAndFind( db, LABEL1, property, 12L );
assertCanCreateAndFind( db, LABEL1, property, (float)12. );
assertCanCreateAndFind( db, LABEL1, property, 12. );
+ assertCanCreateAndFind( db, LABEL1, property, new SpatialMocks.MockPoint( 12.3, 45.6, mockWGS84() ) );
+ assertCanCreateAndFind( db, LABEL1, property, new SpatialMocks.MockPoint( 123, 456, mockCartesian() ) );
+ assertCanCreateAndFind( db, LABEL1, property, Values.pointValue( CoordinateReferenceSystem.WGS84, 12.3, 45.6 ) );
+ assertCanCreateAndFind( db, LABEL1, property, Values.pointValue( CoordinateReferenceSystem.Cartesian, 123, 456 ) );
assertCanCreateAndFind( db, LABEL1, property, new String[]{"A String"} );
assertCanCreateAndFind( db, LABEL1, property, new boolean[]{true} );
@@ -371,6 +381,10 @@ public void shouldBeAbleToQuerySupportedPropertyTypes()
assertCanCreateAndFind( db, LABEL1, property, new Float[]{(float)19.} );
assertCanCreateAndFind( db, LABEL1, property, new double[]{20.} );
assertCanCreateAndFind( db, LABEL1, property, new Double[]{21.} );
+ assertCanCreateAndFind( db, LABEL1, property, new Point[]{new SpatialMocks.MockPoint( 12.3, 45.6, mockWGS84() )} );
+ assertCanCreateAndFind( db, LABEL1, property, new Point[]{new SpatialMocks.MockPoint( 123, 456, mockCartesian() )} );
+ assertCanCreateAndFind( db, LABEL1, property, new PointValue[]{Values.pointValue( CoordinateReferenceSystem.WGS84, 12.3, 45.6 )} );
+ assertCanCreateAndFind( db, LABEL1, property, new PointValue[]{Values.pointValue( CoordinateReferenceSystem.Cartesian, 123, 456 )} );
}
@Test
diff --git a/community/kernel/src/test/java/org/neo4j/graphdb/SpatialMocks.java b/community/kernel/src/test/java/org/neo4j/graphdb/SpatialMocks.java
new file mode 100644
index 0000000000000..4fc4c41399a7d
--- /dev/null
+++ b/community/kernel/src/test/java/org/neo4j/graphdb/SpatialMocks.java
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2002-2018 "Neo Technology,"
+ * Network Engine for Objects in Lund AB [http://neotechnology.com]
+ *
+ * This file is part of Neo4j.
+ *
+ * Neo4j is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+package org.neo4j.graphdb;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.neo4j.graphdb.spatial.CRS;
+import org.neo4j.graphdb.spatial.Coordinate;
+import org.neo4j.graphdb.spatial.Geometry;
+import org.neo4j.graphdb.spatial.Point;
+
+public class SpatialMocks
+{
+
+ public static CRS mockWGS84()
+ {
+ return mockCRS( 4326, "WGS-84", "http://spatialreference.org/ref/epsg/4326/" );
+ }
+
+ public static CRS mockCartesian()
+ {
+ return mockCRS( 7203, "cartesian", "http://spatialreference.org/ref/sr-org/7203/" );
+ }
+
+ public static CRS mockCRS( final int code, final String type, final String href )
+ {
+ return new CRS()
+ {
+ public int getCode()
+ {
+ return code;
+ }
+
+ public String getType()
+ {
+ return type;
+ }
+
+ public String getHref()
+ {
+ return href;
+ }
+ };
+ }
+
+ public static class MockPoint extends MockGeometry implements Point
+ {
+ private final Coordinate coordinate;
+
+ public MockPoint( final double x, final double y, final CRS crs )
+ {
+ super( "Point", new ArrayList<>(), crs );
+ this.coordinate = new Coordinate( x, y );
+ this.coordinates.add( this.coordinate );
+ }
+ }
+
+ public static class MockGeometry implements Geometry
+ {
+ protected final String geometryType;
+ protected final CRS crs;
+ protected final List coordinates;
+
+ public MockGeometry( String geometryType, final List coordinates, final CRS crs )
+ {
+ this.geometryType = geometryType;
+ this.coordinates = coordinates;
+ this.crs = crs;
+ }
+
+ @Override
+ public String getGeometryType()
+ {
+ return geometryType;
+ }
+
+ @Override
+ public List getCoordinates()
+ {
+ return coordinates;
+ }
+
+ @Override
+ public CRS getCRS()
+ {
+ return crs;
+ }
+ }
+}
diff --git a/community/kernel/src/test/java/org/neo4j/kernel/api/index/CompositeIndexAccessorCompatibility.java b/community/kernel/src/test/java/org/neo4j/kernel/api/index/CompositeIndexAccessorCompatibility.java
index ee449cb9586ea..7c90af44e9c9c 100644
--- a/community/kernel/src/test/java/org/neo4j/kernel/api/index/CompositeIndexAccessorCompatibility.java
+++ b/community/kernel/src/test/java/org/neo4j/kernel/api/index/CompositeIndexAccessorCompatibility.java
@@ -25,6 +25,8 @@
import org.neo4j.internal.kernel.api.schema.LabelSchemaDescriptor;
import org.neo4j.kernel.api.schema.index.IndexDescriptor;
import org.neo4j.kernel.api.schema.index.IndexDescriptorFactory;
+import org.neo4j.values.storable.CoordinateReferenceSystem;
+import org.neo4j.values.storable.PointValue;
import org.neo4j.values.storable.Values;
import static java.util.Arrays.asList;
@@ -75,6 +77,23 @@ public void testIndexSeekAndScanByNumber() throws Exception
assertThat( query( exists( 1 ) ), equalTo( asList( 1L, 2L, 3L ) ) );
}
+ @Test
+ public void testIndexSeekAndScanByPoint() throws Exception
+ {
+ PointValue gps = Values.pointValue( CoordinateReferenceSystem.WGS84, 12.6, 56.7 );
+ PointValue car = Values.pointValue( CoordinateReferenceSystem.Cartesian, 12.6, 56.7 );
+
+ updateAndCommit( asList(
+ add( 1L, descriptor.schema(), gps, gps ),
+ add( 2L, descriptor.schema(), car, car ),
+ add( 3L, descriptor.schema(), gps, car ) ) );
+
+ assertThat( query( exact( 0, gps ), exact( 1, gps ) ), equalTo( singletonList( 1L ) ) );
+ assertThat( query( exact( 0, car ), exact( 1, car ) ), equalTo( singletonList( 2L ) ) );
+ assertThat( query( exact( 0, gps ), exact( 1, car ) ), equalTo( singletonList( 3L ) ) );
+ assertThat( query( exists( 1 ) ), equalTo( asList( 1L, 2L, 3L ) ) );
+ }
+
// This behaviour is expected by General indexes
@Ignore( "Not a test. This is a compatibility suite" )
@@ -104,6 +123,17 @@ public void testDuplicatesInIndexSeekByNumber() throws Exception
assertThat( query( exact( 0, 333 ), exact( 1, 333 ) ), equalTo( asList( 1L, 2L ) ) );
}
+
+ @Test
+ public void testDuplicatesInIndexSeekByPoint() throws Exception
+ {
+ PointValue gps = Values.pointValue( CoordinateReferenceSystem.WGS84, 12.6, 56.7 );
+ updateAndCommit( asList(
+ add( 1L, descriptor.schema(), gps, gps ),
+ add( 2L, descriptor.schema(), gps, gps ) ) );
+
+ assertThat( query( exact( 0, gps ), exact( 1, gps ) ), equalTo( asList( 1L, 2L ) ) );
+ }
}
// This behaviour is expected by Unique indexes
diff --git a/community/kernel/src/test/java/org/neo4j/kernel/api/index/NodeUpdatesTest.java b/community/kernel/src/test/java/org/neo4j/kernel/api/index/NodeUpdatesTest.java
index c4da3b8754343..d7d9b4d44e5aa 100644
--- a/community/kernel/src/test/java/org/neo4j/kernel/api/index/NodeUpdatesTest.java
+++ b/community/kernel/src/test/java/org/neo4j/kernel/api/index/NodeUpdatesTest.java
@@ -34,6 +34,7 @@
import org.neo4j.kernel.impl.api.index.NodeUpdates;
import org.neo4j.kernel.impl.api.index.PropertyLoader;
import org.neo4j.storageengine.api.StorageProperty;
+import org.neo4j.values.storable.CoordinateReferenceSystem;
import org.neo4j.values.storable.Value;
import org.neo4j.values.storable.Values;
@@ -49,17 +50,21 @@ public class NodeUpdatesTest
private static final int labelId = 0;
private static final int propertyKeyId1 = 0;
private static final int propertyKeyId2 = 1;
+ private static final int propertyKeyId3 = 2;
private static final long[] labels = new long[]{labelId};
private static final long[] empty = new long[]{};
private static final LabelSchemaDescriptor index1 = SchemaDescriptorFactory.forLabel( labelId, propertyKeyId1 );
private static final LabelSchemaDescriptor index2 = SchemaDescriptorFactory.forLabel( labelId, propertyKeyId2 );
- private static final LabelSchemaDescriptor index12 = SchemaDescriptorFactory.forLabel( labelId, propertyKeyId1, propertyKeyId2 );
- private static final List indexes = Arrays.asList( index1, index2, index12 );
+ private static final LabelSchemaDescriptor index3 = SchemaDescriptorFactory.forLabel( labelId, propertyKeyId3 );
+ private static final LabelSchemaDescriptor index123
+ = SchemaDescriptorFactory.forLabel( labelId, propertyKeyId1, propertyKeyId2, propertyKeyId3 );
+ private static final List indexes = Arrays.asList( index1, index2, index3, index123 );
private static final StorageProperty property1 = new PropertyKeyValue( propertyKeyId1, Values.of( "Neo" ) );
private static final StorageProperty property2 = new PropertyKeyValue( propertyKeyId2, Values.of( 100L ) );
- private static final Value[] values12 = new Value[]{property1.value(), property2.value()};
+ private static final StorageProperty property3 = new PropertyKeyValue( propertyKeyId3, Values.pointValue( CoordinateReferenceSystem.WGS84, 12.3, 45.6 ) );
+ private static final Value[] values123 = new Value[]{property1.value(), property2.value(), property3.value()};
@Test
public void shouldNotGenerateUpdatesForEmptyNodeUpdates()
@@ -78,6 +83,7 @@ public void shouldNotGenerateUpdateForMultipleExistingPropertiesAndLabels()
NodeUpdates updates = NodeUpdates.forNode( nodeId, labels )
.existing( propertyKeyId1, Values.of( "Neo" ) )
.existing( propertyKeyId2, Values.of( 100L ) )
+ .existing( propertyKeyId3, Values.of( Values.pointValue( CoordinateReferenceSystem.WGS84, 12.3, 45.6 ) ) )
.build();
// Then
@@ -116,15 +122,17 @@ public void shouldGenerateUpdatesForLabelAdditionWithExistingProperties()
NodeUpdates.forNode( nodeId, empty, labels )
.existing( propertyKeyId1, Values.of( "Neo" ) )
.existing( propertyKeyId2, Values.of( 100L ) )
+ .existing( propertyKeyId3, Values.of( Values.pointValue( CoordinateReferenceSystem.WGS84, 12.3, 45.6 ) ) )
.build();
// Then
assertThat(
- updates.forIndexKeys( indexes, propertyLoader( property1, property2 ) ),
+ updates.forIndexKeys( indexes, propertyLoader( property1, property2, property3 ) ),
containsInAnyOrder(
IndexEntryUpdate.add( nodeId, index1, property1.value() ),
IndexEntryUpdate.add( nodeId, index2, property2.value() ),
- IndexEntryUpdate.add( nodeId, index12, values12 )
+ IndexEntryUpdate.add( nodeId, index3, property3.value() ),
+ IndexEntryUpdate.add( nodeId, index123, values123 )
) );
}
@@ -162,11 +170,12 @@ public void shouldGenerateUpdatesForLabelRemovalWithExistingProperties()
// Then
assertThat(
- updates.forIndexKeys( indexes, propertyLoader( property1, property2 ) ),
+ updates.forIndexKeys( indexes, propertyLoader( property1, property2, property3 ) ),
containsInAnyOrder(
IndexEntryUpdate.remove( nodeId, index1, property1.value() ),
IndexEntryUpdate.remove( nodeId, index2, property2.value() ),
- IndexEntryUpdate.remove( nodeId, index12, values12 )
+ IndexEntryUpdate.remove( nodeId, index3, property3.value() ),
+ IndexEntryUpdate.remove( nodeId, index123, values123 )
) );
}
@@ -205,15 +214,17 @@ public void shouldGenerateUpdatesForMultiplePropertyAdditionWithLabels()
NodeUpdates updates = NodeUpdates.forNode( nodeId, labels )
.added( property1.propertyKeyId(), property1.value() )
.added( property2.propertyKeyId(), property2.value() )
+ .added( property3.propertyKeyId(), property3.value() )
.build();
// Then
assertThat(
- updates.forIndexKeys( indexes, propertyLoader( property1, property2 ) ),
+ updates.forIndexKeys( indexes, propertyLoader( property1, property2, property3 ) ),
containsInAnyOrder(
IndexEntryUpdate.add( nodeId, index1, property1.value() ),
IndexEntryUpdate.add( nodeId, index2, property2.value() ),
- IndexEntryUpdate.add( nodeId, index12, values12 )
+ IndexEntryUpdate.add( nodeId, index3, property3.value() ),
+ IndexEntryUpdate.add( nodeId, index123, values123 )
) );
}
@@ -224,6 +235,7 @@ public void shouldNotGenerateUpdatesForLabelAddAndPropertyRemove()
NodeUpdates updates = NodeUpdates.forNode( nodeId, empty, labels )
.removed( property1.propertyKeyId(), property1.value() )
.removed( property2.propertyKeyId(), property2.value() )
+ .removed( property3.propertyKeyId(), property3.value() )
.build();
// Then
@@ -237,6 +249,7 @@ public void shouldNotGenerateUpdatesForLabelRemoveAndPropertyAdd()
NodeUpdates updates = NodeUpdates.forNode( nodeId, labels, empty )
.added( property1.propertyKeyId(), property1.value() )
.added( property2.propertyKeyId(), property2.value() )
+ .added( property3.propertyKeyId(), property3.value() )
.build();
// Then
diff --git a/community/kernel/src/test/java/org/neo4j/kernel/api/index/SchemaConstraintProviderApprovalTest.java b/community/kernel/src/test/java/org/neo4j/kernel/api/index/SchemaConstraintProviderApprovalTest.java
index 2660712588447..92b04b4919d0a 100644
--- a/community/kernel/src/test/java/org/neo4j/kernel/api/index/SchemaConstraintProviderApprovalTest.java
+++ b/community/kernel/src/test/java/org/neo4j/kernel/api/index/SchemaConstraintProviderApprovalTest.java
@@ -41,6 +41,9 @@
import org.neo4j.helpers.collection.Iterables;
import org.neo4j.helpers.collection.Iterators;
import org.neo4j.test.TestGraphDatabaseFactory;
+import org.neo4j.values.storable.CoordinateReferenceSystem;
+import org.neo4j.values.storable.PointValue;
+import org.neo4j.values.storable.Values;
import static org.junit.Assert.assertEquals;
import static org.neo4j.graphdb.Label.label;
@@ -77,6 +80,8 @@ public enum TestValue
SHORT_42( (short) 45 ),
FLOAT_42( (float) 46 ),
FLOAT_42andAHalf( 41.5f ),
+ POINT_123456_GPS( Values.pointValue( CoordinateReferenceSystem.WGS84, 12.3, 45.6 ) ),
+ POINT_123456_CAR( Values.pointValue( CoordinateReferenceSystem.Cartesian, 123, 456 ) ),
ARRAY_OF_INTS( new int[]{1, 2, 3} ),
ARRAY_OF_LONGS( new long[]{4, 5, 6} ),
ARRAY_OF_LARGE_LONGS_1( new long[] { 4611686018427387905L } ),
@@ -91,7 +96,9 @@ public enum TestValue
ONE( new String[]{"", "||"} ),
OTHER( new String[]{"||", ""} ),
ANOTHER_ARRAY_OF_STRING( new String[]{"1|2|3"} ),
- ARRAY_OF_CHAR( new char[]{'d', 'e', 'f'} );
+ ARRAY_OF_CHAR( new char[]{'d', 'e', 'f'} ),
+ ARRAY_OF_POINTS_GPS( new PointValue[]{Values.pointValue( CoordinateReferenceSystem.WGS84, 12.3, 45.6 )} ),
+ ARRAY_OF_POINTS_CAR( new PointValue[]{Values.pointValue( CoordinateReferenceSystem.Cartesian, 123, 456 )} );
private final Object value;
diff --git a/community/kernel/src/test/java/org/neo4j/kernel/api/index/SchemaIndexProviderApprovalTest.java b/community/kernel/src/test/java/org/neo4j/kernel/api/index/SchemaIndexProviderApprovalTest.java
index 05b1e16469ed3..e044fc68e93fa 100644
--- a/community/kernel/src/test/java/org/neo4j/kernel/api/index/SchemaIndexProviderApprovalTest.java
+++ b/community/kernel/src/test/java/org/neo4j/kernel/api/index/SchemaIndexProviderApprovalTest.java
@@ -41,6 +41,9 @@
import org.neo4j.helpers.collection.Iterables;
import org.neo4j.helpers.collection.Iterators;
import org.neo4j.test.TestGraphDatabaseFactory;
+import org.neo4j.values.storable.CoordinateReferenceSystem;
+import org.neo4j.values.storable.PointValue;
+import org.neo4j.values.storable.Values;
import static org.junit.Assert.assertEquals;
import static org.neo4j.graphdb.Label.label;
@@ -77,6 +80,8 @@ public enum TestValue
SHORT_42( (short) 42 ),
FLOAT_42( (float) 42 ),
FLOAT_42andAHalf( 42.5f ),
+ POINT_123456_GPS( Values.pointValue( CoordinateReferenceSystem.WGS84, 12.3, 45.6 ) ),
+ POINT_123456_CAR( Values.pointValue( CoordinateReferenceSystem.Cartesian, 123, 456 ) ),
ARRAY_OF_INTS( new int[]{1, 2, 3} ),
ARRAY_OF_LONGS( new long[]{1, 2, 3} ),
ARRAY_OF_LARGE_LONGS_1( new long[] { 4611686018427387905L } ),
@@ -95,7 +100,9 @@ public enum TestValue
ONE( new String[]{"", "||"} ),
OTHER( new String[]{"||", ""} ),
ANOTHER_ARRAY_OF_STRING( new String[]{"1|2|3"} ),
- ARRAY_OF_CHAR( new char[]{'1', '2', '3'} );
+ ARRAY_OF_CHAR( new char[]{'1', '2', '3'} ),
+ ARRAY_OF_POINTS_GPS( new PointValue[]{Values.pointValue( CoordinateReferenceSystem.WGS84, 12.3, 45.6 )} ),
+ ARRAY_OF_POINTS_CAR( new PointValue[]{Values.pointValue( CoordinateReferenceSystem.Cartesian, 123, 456 )} );
private final Object value;
diff --git a/community/kernel/src/test/java/org/neo4j/kernel/api/index/SimpleIndexAccessorCompatibility.java b/community/kernel/src/test/java/org/neo4j/kernel/api/index/SimpleIndexAccessorCompatibility.java
index 22d007b7f0752..eefb0f3cd0c40 100644
--- a/community/kernel/src/test/java/org/neo4j/kernel/api/index/SimpleIndexAccessorCompatibility.java
+++ b/community/kernel/src/test/java/org/neo4j/kernel/api/index/SimpleIndexAccessorCompatibility.java
@@ -27,6 +27,9 @@
import org.neo4j.internal.kernel.api.IndexQuery;
import org.neo4j.kernel.api.schema.index.IndexDescriptor;
import org.neo4j.kernel.api.schema.index.IndexDescriptorFactory;
+import org.neo4j.values.storable.CoordinateReferenceSystem;
+import org.neo4j.values.storable.PointValue;
+import org.neo4j.values.storable.Values;
import static java.util.Arrays.asList;
import static java.util.Collections.EMPTY_LIST;
@@ -96,6 +99,42 @@ public void testIndexSeekByString() throws Exception
assertThat( query( range( 1, "Anabelle", false, "Bob", false ) ), equalTo( singletonList( 2L ) ) );
}
+ @Ignore
+ public void testIndexSeekByPoint() throws Exception
+ {
+ PointValue gpsPP = Values.pointValue( CoordinateReferenceSystem.WGS84, 12.6, 56.7 );
+ PointValue gpsNP = Values.pointValue( CoordinateReferenceSystem.WGS84, -12.6, 56.7 );
+ PointValue gpsPN = Values.pointValue( CoordinateReferenceSystem.WGS84, 12.6, -56.7 );
+ PointValue gpsNN = Values.pointValue( CoordinateReferenceSystem.WGS84, -12.6, -56.7 );
+ PointValue gps00 = Values.pointValue( CoordinateReferenceSystem.WGS84, 0.0, 0.0 );
+ PointValue car2D = Values.pointValue( CoordinateReferenceSystem.Cartesian, 123, 456 );
+ PointValue car3D = Values.pointValue( CoordinateReferenceSystem.Cartesian, 12, 34, 56 );
+ updateAndCommit( asList(
+ add( 1L, descriptor.schema(), gpsPP ),
+ add( 2L, descriptor.schema(), gpsNP ),
+ add( 3L, descriptor.schema(), gpsPN ),
+ add( 4L, descriptor.schema(), gpsNN ),
+ add( 5L, descriptor.schema(), car2D ),
+ add( 6L, descriptor.schema(), car3D ) ) );
+
+ assertThat( query( range( 1, gpsNN, true, gpsPP, true ) ), equalTo( asList( 1L, 2L, 3L, 4L ) ) );
+ assertThat( query( range( 1, gpsNN, true, null, true ) ), equalTo( asList( 1L, 2L, 3L, 4L ) ) );
+ assertThat( query( range( 1, gpsNN, true, null, false ) ), equalTo( asList( 1L, 2L, 3L, 4L ) ) );
+ assertThat( query( range( 1, gpsNN, true, gpsPP, false ) ), equalTo( singletonList( 4L ) ) );
+ assertThat( query( range( 1, gpsPP, true, null, false ) ), equalTo( singletonList( 1L ) ) );
+ assertThat( query( range( 1, gpsPP, false, null, false ) ), equalTo( EMPTY_LIST ) );
+ assertThat( query( range( 1, gpsNP, true, gpsPP, true ) ), equalTo( asList( 1L, 2L ) ) );
+ assertThat( query( range( 1, gpsNP, true, gpsPP, false ) ), equalTo( singletonList( 2L ) ) );
+ assertThat( query( range( 1, null, true, gpsPP, false ) ), equalTo( singletonList( 4L ) ) );
+ assertThat( query( range( 1, null, false, gpsPP, true ) ), equalTo( asList( 1L, 2L, 3L, 4L ) ) );
+ assertThat( query( range( 1, gps00, false, null, true ) ), equalTo( singletonList( 1L ) ) );
+ assertThat( query( range( 1, null, false, gps00, false ) ), equalTo( singletonList( 4L ) ) );
+ assertThat( query( range( 1, car2D, true, null, true ) ), equalTo( singletonList( 5L ) ) );
+ assertThat( query( range( 1, car3D, true, null, true ) ), equalTo( singletonList( 6L ) ) );
+ assertThat( query( range( 1, null, true, car2D, true ) ), equalTo( singletonList( 5L ) ) );
+ assertThat( query( range( 1, null, true, car3D, true ) ), equalTo( singletonList( 6L ) ) );
+ }
+
@Test
public void testIndexSeekByPrefix() throws Exception
{
diff --git a/community/server/src/test/java/org/neo4j/server/rest/transactional/Neo4jJsonCodecTest.java b/community/server/src/test/java/org/neo4j/server/rest/transactional/Neo4jJsonCodecTest.java
index 581f17eb6b79e..333a3deda4eca 100644
--- a/community/server/src/test/java/org/neo4j/server/rest/transactional/Neo4jJsonCodecTest.java
+++ b/community/server/src/test/java/org/neo4j/server/rest/transactional/Neo4jJsonCodecTest.java
@@ -34,7 +34,7 @@
import org.neo4j.graphdb.Path;
import org.neo4j.graphdb.PropertyContainer;
import org.neo4j.graphdb.Relationship;
-import org.neo4j.graphdb.spatial.CRS;
+import org.neo4j.graphdb.SpatialMocks;
import org.neo4j.graphdb.spatial.Coordinate;
import org.neo4j.graphdb.spatial.Geometry;
import org.neo4j.graphdb.spatial.Point;
@@ -47,6 +47,8 @@
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import static org.neo4j.graphdb.SpatialMocks.mockCartesian;
+import static org.neo4j.graphdb.SpatialMocks.mockWGS84;
public class Neo4jJsonCodecTest extends TxStateCheckerTestSupport
{
@@ -229,7 +231,7 @@ public void shouldWriteAMapContainingNullAsKeysAndValues() throws IOException
public void testGeographicPointWriting() throws IOException
{
//Given
- Point value = new MockPoint( 12.3, 45.6, mockWGS84() );
+ Point value = new SpatialMocks.MockPoint( 12.3, 45.6, mockWGS84() );
//When
jsonCodec.writeValue( jsonGenerator, value );
@@ -242,7 +244,7 @@ public void testGeographicPointWriting() throws IOException
public void testCartesianPointWriting() throws IOException
{
//Given
- Point value = new MockPoint( 123.0, 456.0, mockCartesian() );
+ Point value = new SpatialMocks.MockPoint( 123.0, 456.0, mockCartesian() );
//When
jsonCodec.writeValue( jsonGenerator, value );
@@ -258,7 +260,7 @@ public void testGeometryWriting() throws IOException
List points = new ArrayList<>();
points.add( new Coordinate( 1, 2 ) );
points.add( new Coordinate( 2, 3 ) );
- Geometry value = new MockGeometry( "LineString", points, mockCartesian() );
+ Geometry value = new SpatialMocks.MockGeometry( "LineString", points, mockCartesian() );
//When
jsonCodec.writeValue( jsonGenerator, value );
@@ -266,80 +268,4 @@ public void testGeometryWriting() throws IOException
//Then
verify( jsonGenerator, times( 3 ) ).writeEndObject();
}
-
- public static CRS mockWGS84()
- {
- return mockCRS( 4326, "WGS-84", "http://spatialreference.org/ref/epsg/4326/" );
- }
-
- public static CRS mockCartesian()
- {
- return mockCRS( 7203, "cartesian", "http://spatialreference.org/ref/sr-org/7203/" );
- }
-
- public static CRS mockCRS( final int code, final String type, final String href )
- {
- return new CRS()
- {
- public int getCode()
- {
- return code;
- }
-
- public String getType()
- {
- return type;
- }
-
- public String getHref()
- {
- return href;
- }
- };
- }
-
- public static class MockPoint extends MockGeometry implements Point
- {
- private final Coordinate coordinate;
-
- public MockPoint( final double x, final double y, final CRS crs )
- {
- super( "Point", new ArrayList<>(), crs );
- this.coordinate = new Coordinate( x, y );
- this.coordinates.add( this.coordinate );
- }
- }
-
- public static class MockGeometry implements Geometry
- {
- protected final String geometryType;
- protected final CRS crs;
- protected final List coordinates;
-
- public MockGeometry( String geometryType, final List coordinates, final CRS crs )
- {
- this.geometryType = geometryType;
- this.coordinates = coordinates;
- this.crs = crs;
- }
-
- @Override
- public String getGeometryType()
- {
- return geometryType;
- }
-
- @Override
- public List getCoordinates()
- {
- return coordinates;
- }
-
- @Override
- public CRS getCRS()
- {
- return crs;
- }
- }
-
}