deyles-zz / sculejs

SculeJS - data structures for the web
165 stars 24 forks source link

Geoquery sorting #42

Open paomosca opened 10 years ago

paomosca commented 10 years ago

Great stuff man, only one question, how to sort geo results from $near or $within for distance?

deyles-zz commented 10 years ago

Hey Pablo,

Right now it isn't possible to sort based on distance from a point. I'm flat out with work at the moment and don't have time to devote to SculeJS, however I'm happy for you to submit a pull request adding this feature. Thanks for using SculeJS!

Cheers, Dan

john-dalsgaard commented 10 years ago

I have the exact same requirement ;-)

Do you have any thoughts on what would be the best approach to implement this?

As I see it the $limit actually conflicts with sorting the order - in case you stop looking for matches after having found x hits you may "loose" some points nearer to the location you are searching for. So using limit really only makes sense if the results are sorted by distance....

I am definitely a newbee when it comes to geo searches - but I would be happy to try and help on this. I have decided to use this library instead of e.g. mongloDb because of the highter maturity - and geo location searches ;-)