GeoData: Confusing tutorial (longitude, latitude)

I think there is a mistake in the documentation / tutorial.

On this tutorial page it says the coordinate pairs are

an array of location tuples of format [(latitude, longitude), (latitude, longitude), ...]

However, in other parts of the documentation its in the reverse order:

Syntax Example: near(predicate, [long, lat], distance)

Thanks for bringing this up @mrwunderbar666. You right, something is not right somewhere.

c/c @vvbalaji

@hardik I think we have an issue here. As I remember from geo lessons on school, we start from Latitude to longitude, right? But in Dgraph is the opposite. It is not just the docs, it is the core code that is the opposite.

The near doc is correct if you compare the core code for geo, but technically it is wrong. The right, I think, is latitude, longitude and not the opposite.

More examples

Let’s take this coordinates.

Latitude: min -90º mid 0º max 90º
Longitude: min -180º mid 0º max 180º

{
  tourist(func: near(loc, [-122.469829, 37.771935], 1000) ) {
    name
  }
}

Let’s use google maps

The Right direction:

https://www.google.com/maps/place/37°46’19.0"N+122°28’11.4"W/@37.7686927,-122.5222511,11.21z/data=!4m5!3m4!1s0x0:0x0!8m2!3d37.771935!4d-122.469829

The wrong:

Google Maps .

Can we change this issue to bug? But we need someone to confirm this first.

Cheers.

ISO 6709 says latitude first, then longitude. But there are no real set standards.

Funnily enough, all the postgis functions that use WSG84 and EPSG:4326 uses longitude first then latitude. So your POINT(x,y) have to be inverted.

1 Like