@Override protected Point newPoint( CoordinateReferenceSystem crs, double[] coordinate ) { return Values.pointValue( crs, coordinate ); }
private PointValue cart( double... coords ) { CoordinateReferenceSystem crs = coords.length == 3 ? CoordinateReferenceSystem.Cartesian_3D : CoordinateReferenceSystem.Cartesian; return Values.pointValue( crs, coords ); }
public static PointValue minPointValue( PointValue reference ) { double[] coordinates = new double[reference.coordinate().length]; Arrays.fill( coordinates, -Double.MAX_VALUE ); return pointValue( reference.getCoordinateReferenceSystem(), coordinates ); }
private static PointValue toPoint( Geometry geometry ) { List<Double> coordinate = geometry.getCoordinates().get( 0 ).getCoordinate(); double[] primitiveCoordinate = new double[coordinate.size()]; for ( int i = 0; i < coordinate.size(); i++ ) { primitiveCoordinate[i] = coordinate.get( i ); } return Values.pointValue( CoordinateReferenceSystem.get( geometry.getCRS() ), primitiveCoordinate ); }
/** * @return the next pseudorandom two-dimensional cartesian {@link PointValue}. * @see RandomValues */ public PointValue nextCartesianPoint() { double x = randomCartesianCoordinate(); double y = randomCartesianCoordinate(); return Values.pointValue( CoordinateReferenceSystem.Cartesian, x, y ); }
/** * @return the next pseudorandom two-dimensional geographic {@link PointValue}. * @see RandomValues */ public PointValue nextGeographicPoint() { double longitude = randomLongitude(); double latitude = randomLatitude(); return Values.pointValue( CoordinateReferenceSystem.WGS84, longitude, latitude ); }
@Test void cartesianShouldEqualItself() { assertEqual( pointValue( Cartesian, 1.0, 2.0 ), pointValue( Cartesian, 1.0, 2.0 ) ); assertEqual( pointValue( Cartesian, -1.0, 2.0 ), pointValue( Cartesian, -1.0, 2.0 ) ); assertEqual( pointValue( Cartesian, -1.0, -2.0 ), pointValue( Cartesian, -1.0, -2.0 ) ); assertEqual( pointValue( Cartesian, 0.0, 0.0 ), pointValue( Cartesian, 0.0, 0.0 ) ); }
@Test public void testIndexSeekExactWithExistsBySpatialArray() throws Exception { testIndexSeekExactWithExists( pointArray( new PointValue[] {pointValue( Cartesian, 100D, 100D ), pointValue( Cartesian, 101D, 101D )} ), pointArray( new PointValue[] {pointValue( Cartesian, 0D, 0D ), pointValue( Cartesian, 1D, 1D )} ) ); }
/** * @return the next pseudorandom three-dimensional geographic {@link PointValue}. * @see RandomValues */ public PointValue nextGeographic3DPoint() { double longitude = randomLongitude(); double latitude = randomLatitude(); double z = randomCartesianCoordinate(); return Values.pointValue( CoordinateReferenceSystem.WGS84_3D, longitude, latitude, z ); }
@Test public void pointArraysOfWgs84() { PointValue[] array = new PointValue[]{ Values.pointValue( CoordinateReferenceSystem.WGS84, -45.0, -45.0 ), Values.pointValue( CoordinateReferenceSystem.WGS84, 12.8, 56.3 )}; int numberOfBitsUsedForDoubles = 64; assertPointArrayHasCorrectFormat( array, numberOfBitsUsedForDoubles ); }
@Test public void pointArraysOfCartesian() { PointValue[] array = new PointValue[]{ Values.pointValue( CoordinateReferenceSystem.Cartesian, -100.0, -100.0 ), Values.pointValue( CoordinateReferenceSystem.Cartesian, 25.0, 50.5 )}; int numberOfBitsUsedForDoubles = 64; assertPointArrayHasCorrectFormat( array, numberOfBitsUsedForDoubles ); }
@Test public void testIndexSeekExactWithExistsBySpatial() throws Exception { testIndexSeekExactWithExists( pointValue( WGS84, 100D, 100D ), pointValue( WGS84, 0D, 0D ) ); }
@Test void geographicShouldNotEqualCartesian() { assertNotEqual( pointValue( WGS84, 1.0, 2.0 ), pointValue( Cartesian, 1.0, 2.0 ) ); }
private PointValue unpackPoint2D() throws IOException { int crsCode = unpackInteger(); CoordinateReferenceSystem crs = CoordinateReferenceSystem.get( crsCode ); double[] coordinates = {unpackDouble(), unpackDouble()}; return pointValue( crs, coordinates ); }
@Test public void shouldReceivePoint2D() throws Exception { testReceivingOfBoltV2Value( "RETURN point({x: 40.7624, y: 73.9738})", pointValue( Cartesian, 40.7624, 73.9738 ) ); }
@Test public void shouldSendAndReceivePoint2D() throws Exception { testSendingAndReceivingOfBoltV2Value( pointValue( WGS84, 38.8719, 77.0563 ) ); }
private PointValue unpackPoint3D() throws IOException { int crsCode = unpackInteger(); CoordinateReferenceSystem crs = CoordinateReferenceSystem.get( crsCode ); double[] coordinates = {unpackDouble(), unpackDouble(), unpackDouble()}; return pointValue( crs, coordinates ); }
@Test void shouldBeAbleToParseWeirdlyFormattedPoints() { assertEqual( pointValue( WGS84, 1.0, 2.0 ), PointValue.parse( " \t\n { latitude : 2.0 ,longitude :1.0 } \t" ) ); // TODO: Should some/all of these fail? assertEqual( pointValue( WGS84, 1.0, 2.0 ), PointValue.parse( " \t\n { latitude : 2.0 ,longitude :1.0 , } \t" ) ); assertEqual( pointValue( Cartesian, 2.0E-8, -1.0E7 ), PointValue.parse( " \t\n { x :+.2e-7,y: -1.0E07 , } \t" ) ); assertEqual( pointValue( Cartesian, 2.0E-8, -1.0E7 ), PointValue.parse( " \t\n { x :+.2e-7,y: -1.0E07 , garbage} \t" ) ); assertEqual( pointValue( Cartesian, 2.0E-8, -1.0E7 ), PointValue.parse( " \t\n { gar ba ge,x :+.2e-7,y: -1.0E07} \t" ) ); }
@Test public void test3DPointType() { Point point = Values.pointValue( CoordinateReferenceSystem.Cartesian_3D, 1, 1, 1 ); String key = "location"; node1.setProperty( key, point ); newTransaction(); Object property = node1.getProperty( key ); assertEquals( point, property ); }
@Test public void testExists() { ExistsPredicate p = IndexQuery.exists( propId ); assertTrue( test( p, "string" ) ); assertTrue( test( p, 1 ) ); 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 ) ); }