Cannot create WGS84 point with invalid coordinate

I have used spatial functions successfully in earlier versions of neo4j but now gives error when I run on 4.0

match (g1:gps), (g2:gps)
return
distance(point({latitude:g1.latitude,longitude:g1.longitude}),point({latitude:g2.latitude,longitude:g2.longitude}))

No I get an error like this:

Cannot create WGS84 point with invalid coordinate: [37.09, -95.713]. Valid range for Y coordinate is [-90, 90].

Looks like your query might be blending 2D and 3D spatial logic.

When you plot the geographic coordinates on a two-dimensional map you apply a map projection. So when you plot the geographic locations in WGS84 on a map where you the horizontal axis represents longitude between -180° and +180° then the vertical axis represents latitude between -90° and +90° then you get a world map in the Plate Carree projection. - What is WGS84 | Virtual Surveyor : Support Portal

Your longitude value -95.713 is invalid according to 2D. Have you tried specifying a CRS value like some of the examples here?

Hi @idrismunir check that g1 or g2 does not have latitudes outside the [-90, 90] range. I had a dataset that had >90 values and that gave me the same error.

When it says "invalid coordinate: [37.09, -95.713]" it is showing [longitude, latitude].

Hope this helps.