Skip to content

Commit 4856b72

Browse files
author
Zhen Li
committed
Fix after cypher validate WGS-84 input Y coordinates.
Server side cypher chagnes: WGS-84 points will now properly validate their input coordinates. Values for latitude should always lie in the interval [-90, 90], any other value outside this range will throw an exception. Values for longitude should always lie in the interval [-180, 180], any other value outside this range will now be wrapped around to fit in this range.
1 parent ea91773 commit 4856b72

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

driver/src/test/java/org/neo4j/driver/integration/SpatialTypesIT.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,7 @@ void shouldSendAndReceiveRandom2DPoints()
9090
{
9191
Stream<Value> randomPoints = ThreadLocalRandom.current()
9292
.ints( 1_000, 0, 2 )
93-
.mapToObj( idx -> idx % 2 == 0
94-
? point( WGS_84_CRS_CODE, randomDouble(), randomDouble() )
95-
: point( CARTESIAN_CRS_CODE, randomDouble(), randomDouble() ) );
93+
.mapToObj( SpatialTypesIT::createPoint );
9694

9795
randomPoints.forEach( this::testPointSendAndReceive );
9896
}
@@ -132,16 +130,26 @@ private void testPointListSendAndReceive( List<Value> points )
132130
private static List<Value> randomPointList( int index )
133131
{
134132
int size = ThreadLocalRandom.current().nextInt( 1, 100 );
135-
int srid = index % 2 == 0 ? CARTESIAN_CRS_CODE : WGS_84_CRS_CODE;
136133
return IntStream.range( 0, size )
137-
.mapToObj( i -> point( srid, randomDouble(), randomDouble() ) )
134+
.mapToObj( ignored -> createPoint( index ) )
138135
.collect( toList() );
139136
}
140137

138+
private static Value createPoint( int idx )
139+
{
140+
return idx % 2 == 0
141+
? point( CARTESIAN_CRS_CODE, randomDouble(), randomDouble() )
142+
: point( WGS_84_CRS_CODE, randomDouble(), randomDoubleWGS_84_Y() );
143+
}
144+
141145
private static double randomDouble()
142146
{
143147
return ThreadLocalRandom.current().nextDouble( -180.0, 180 );
144148
}
149+
private static double randomDoubleWGS_84_Y()
150+
{
151+
return ThreadLocalRandom.current().nextDouble( -90.0, 90 );
152+
}
145153

146154
private static void assertPoints2DEqual( Point expected, Point actual )
147155
{

0 commit comments

Comments
 (0)