deyles-zz / sculejs

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

geo-locational proximity operator doubt #31

Closed TomatoNinja closed 11 years ago

TomatoNinja commented 11 years ago

Hi Dan,

I have a doubt, how can you query a geo-location proximity? I have been trying to do it as you do in your examples, but i couldn't make it work... I have a JSON node, with the lat and lng parameters as floats ( i have duplicated them so i have the Latitude and Longitude parameters as string)

//Example node node: { title:"node test", lat:30, // (this value is between 28 and 34) lng:30,// (this value is between 28 and 34) Latitude:"30", Longitude:"30" }

so when i try to search for nodes within an area

var scollection = scule.factoryCollection('scule+titanium://'+table); scollection.find({$within:{lat:30, lng:30, distance:10}},{},function(results) { Ti.API.info("length: " + results.length); Ti.API.info("data: " + results); });

this always return an empty array, (i have tried to change the distance, the latitude and longitude parameters to a node that exists, but no result was returned... i have tried with float and int values). I have also tried with the operator $near, but i got the same result...

Thank you for your effort! Roman

deyles-zz commented 11 years ago

Hey ninja,

Check out the code included in the attached the commit. The way you're structuring your queries (and data) is what's causing issues. I've also updated the documentation to reflect how geospatial queries should be written:

https://github.com/dan-eyles/sculejs/wiki/Writing-Queries