You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
query.withinMiles() will not work while query.near() works fine #2075
I've been trying, to no avail, to get the withinMiles query method to work. From what I can tell, withinMiles calls withinRadians calls near, and the only difference is the $maxDistance property is applied to the query. Below are the methods I'm using for both the withinMiles method and the near method:
query.withinMiles('currentLocation',
new Parse.GeoPoint(-73.96939568075399, 40.83514669005315),
maxDistance
);
query.near('currentLocation',
new Parse.GeoPoint(-73.96939568075399, 40.83514669005315));
Near runs and returns many objects from the database. withinMiles runs and returns an empty array. As you can see, at face value, it's the exact same method call, with the exact same properties, other than the maxDistance argument for withinMiles. maxDistance, for reference, is a Number value as required by the API.
I find it hard to believe that this is a bug, but from everything I can tell, it is. Any help would be appreciated.
We have lots of passing test cases that cover these features. Can you post some code that reliably reproduces your issue, including the code that creates the data? Ideally as a test case we can add to our test suite.
This is the exact code that I'm using. Do you see something wrong that I'm doing?
Parse.Cloud.define("minimumUsersForAccess", function(request, response){
if (!request.user) {
response.error("Must be signed in to call this Cloud Function.")
return;
}
// Max Distance to search should either be set by request, or default to 20 miles
var maxDistance = (request.params.maxDistance)
? request.params.maxDistance : 20,
query = new Parse.Query(Parse.User);
// THIS DOES NOT WORK
query.withinMiles('currentLocation',
new Parse.GeoPoint(-73.96939568075399, 40.83514669005315),
maxDistance
);
// THIS WORKS
query.near('currentLocation',
new Parse.GeoPoint(-73.96939568075399, 40.83514669005315));
query.find({
success: function(users) {
// return true if more than 50 users returned, otherwise not enough
// users for access
console.log(users);
response.success((users.length >= 50) ? true : false);
}
});
});
I don't have access to the code that creates the data unfortunately. Regardless, this is the shape of the location data in mongo:
We have multiple tests for the withinMiles feature in the ParseGeoPoint.spec.js file that all pass. Without a complete set of steps to reproduce this issue, it's very difficult for us to help.
If you aren't using mongodb version 3.0.8, try switching to that version, as other versions have had some issues with geo queries.
Activity
drew-gross commentedon Jun 16, 2016
We have lots of passing test cases that cover these features. Can you post some code that reliably reproduces your issue, including the code that creates the data? Ideally as a test case we can add to our test suite.
Siraris commentedon Jun 16, 2016
This is the exact code that I'm using. Do you see something wrong that I'm doing?
I don't have access to the code that creates the data unfortunately. Regardless, this is the shape of the location data in mongo:
"currentLocation": [
-71.1670245290879,
42.33827739107621
]
drew-gross commentedon Jun 16, 2016
We have multiple tests for the
withinMilesfeature in theParseGeoPoint.spec.jsfile that all pass. Without a complete set of steps to reproduce this issue, it's very difficult for us to help.If you aren't using mongodb version 3.0.8, try switching to that version, as other versions have had some issues with geo queries.
hramos commentedon Jun 24, 2016
We are closing this issue due to a lack of sufficient information.
Please refer to this issue for an example of a great bug report.
You may use Server Fault for questions about managing Parse Server.
For code-level and/or implementation-related questions or technical support, please refer to Stack Overflow.