Using a Geo Scalar Value Variabe in a Geo "near" function doesn't work


(Simdi Jinkins) #1

Here user.location is indexed “geo”

{
 var(func(uid(0x1))){
location as user.location
}
  matches(func:near(user.location,location,100000)){
    user.userName
  }
}

Tried storing longitude and latitude as seperate values and then using them in the function, doesn’t work too:

{
   var(func(uid(0x1))){
longitude as math(user.longitude)
latitude as math(user.latitude)
}

  matches(func:near(user.location,[longitude,latitude],100000)) {
  userId:uid
  longitude:user.longitude
  latitude:user.latitude
  }
}

Is there any way to avoid passing longitude and latitude values directly:

{

  matches(func:near(user.location,[7,9.0765],100000)) {
	userId:uid
  longitude:user.longitude
  latitude:user.latitude
  }
}

(Michel Conrado) #2

The correct syntax would be [val(longitude),val(latitude)], but as far I know geo func doesn’t supports this.


(Simdi Jinkins) #3

So I have to first grab the users location on the client then send another query using that location.

Could this be added as a feature request ?


(Michel Conrado) #4

Could, but I can’t see this being supported in short or medium term.


(Simdi Jinkins) #5

Technical challenges ?. I could contribute if possible.


(Michel Conrado) #6

It’s a matter of demand, the team is focused on more punctual things. Features like Geo is rarely used, so you can even request an enhancement. But it will take a while until the priority of it changes.

But PRs are welcome tho.


(Simdi Jinkins) #7

Okay, thanks will look over the repo once I can