Geo Eval - Filtering

Options
Thanks to the great documentation and tutorials I've been able to follow along and:
• create an API that queries all records
• use geo distance to calculate distance between two points - returned as integer
• use geo within to calculate if the points are within a certain distance (radius) - returned as boolean
• return the full list of records by distance in ascending order


Where I'm having trouble is in limiting the output response only to the records where the boolean response is true.

Where would be the best place to add that last bit of filtering so the response only includes the items that fall within the preferred radius?

Comments

  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Options
    Hey  - I would actually use the By Custom Query filter to limit the response. You can chain the distance and between filters on the db field that you are using in here

    [CleanShot 2021-12-09 at 11.39.53.png]
  • Josh Nelson
    Options
     thanks for the suggestion. I had attempted that method once before, but must have gotten something wrong.

    I moved the within function to the custom query and left the distance in the eval, and this is giving me everything I was looking for.

    Thanks!
  • dmenciot
    dmenciot Member
    Options
    Hi  ,

    I am trying to do exactly the same but I am stuck at the same point you were. 
    How did you get out of it? If I use the "within" function in custom query, I am not able to extract the "distance" EVAL just created.
    [image.png][image.png]
    PS: in my case the value of the radius to compare is stored in a "Radius" variable I called previously in my stack.

    thank you,
    David
  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Options
     Evals won't be able to be used in your By Custom Query. You would use your Restaurant.location and user_location to in the within filter with how ever many meters you want to search it to be within
  • dmenciot
    dmenciot Member
    Options
    Thanks Michael,

    is this what you mean?

    [image.png]I am getting this error:
    [image.png]One more thing: but if the "within" does the job, why do we need to do the EVALS "distance"?

    Thanks a lot
  • dmenciot
    dmenciot Member
    Options
    Update for  

    It's seems to work if i input and integer directly in the "distance" field of the WITHIN function, while it output the error above if I try to retrieve the Radius from a variable I created (which is connected to another table).

    How can I link the radius value of the within function to a value present in another DB table? 
  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Options
     Can you please elaborate more some more on what you're trying to return for clarity?

    Or if you can come to office hours, it will probably be best to help you there.