Takis
Posts: 0
Joined: Wed Oct 22, 2014 5:10 pm

Determine if two geolocation cycles intersect

So what is the most advisable way?

  • run 1st pass query and store in local variable array

  • based on this array re-run the query, so to make the 2nd pass and filter the records

    or else?

    Is there a way to avoid running the query two times?

    What is an array limit, how many data can store ?

    Thanks.

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Determine if two geolocation cycles intersect

Hi Panagiotis,

Why don't you want to use "and" logic to combine two queries?

For example:

precode

{
"$and": [

Code: Select all

     { 
         "Location": { 
             "$nearSphere": [23.791376, 38.002788], 
             "$maxDistanceInKilometers": 0.5 
         } 
     }, 

     { 
         "Location": { 
             "$nearSphere": [24.791376, 37.002788], 
             "$maxDistanceInKilometers": 0.5 
         } 
     } 

 ] 

}

/code/pre

Regards.

Takis
Posts: 0
Joined: Wed Oct 22, 2014 5:10 pm

Determine if two geolocation cycles intersect

Thanks.

Finally what I want is to :

  1. find points within the cycle of mobile user

  2. these points have a radius where there are "visible"

  3. then I calculate the distance between the mobile and each point

  4. if the distance - radius the records returned with the function and create final list.

    Is there a way not to run the query twice, in order to achieve the above?

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Determine if two geolocation cycles intersect

Hi Panagiotis,

in this case you can not use DB query event with two requests.

So brief plan is:

1 Get mobile point.

2 Get all goal points from DB with "nearSphere" request to DB.

3 Iterate all points from 2nd step and make condition calculation for each of these points and add to new Array.

4 Use new Array from 3rd step as you need.

Regards.

Takis
Posts: 0
Joined: Wed Oct 22, 2014 5:10 pm

Determine if two geolocation cycles intersect

Thanks Yurii

This is what I finally did.
I could not find another way to do it in one step.

Return to “Issues”