Titanium JIRA Archive
Appcelerator Community (AC)

[AC-2334] Cloud API doc incorrect

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionInvalid
Resolution Date2014-02-24T22:47:25.000+0000
Affected Version/sn/a
Fix Version/sn/a
Componentsn/a
Labelsn/a
ReporterMichael Stelly
AssigneeRitu Agrawal
Created2014-02-22T23:10:03.000+0000
Updated2016-03-08T07:41:21.000+0000

Description

Steps to Reproduce

I spent hours trying to follow the documentation to use the Cloud query api. it is incorrect. To query based on $maxDistance, doc says convert miles to radians. See example here http://docs.appcelerator.com/cloud/latest/#!/guide/search_query. That is wrong. The conversion occurs within the API itself, so all one needs is the $maxDistance in miles. Change the document so that no one else has to pull out their hair trying to figure it out.

Actual Result

Query using $maxDistance value in radians producing zero records

Expected Result

Query using $maxDistance value in radians producing correct number of records

Attachments

FileDateSize
.log2014-02-22T23:10:05.000+0000732554
diagnostic392057494765325755.log2014-02-22T23:10:08.000+000015305

Comments

  1. Wei Kong 2014-02-24

    [~ragrawal] can you please clarify the actaul and expected result what you used? right now it says both in radians?
  2. Wei Kong 2014-02-24

    http://docs.mongodb.org/manual/reference/command/geoNear/ should be radians
  3. Michael Stelly 2014-02-24

    As an example, I'm using this query:
       Cloud.Users.query({
       			page : 1,
       			per_page : 10,
       			where : {
       				"role" : "vendor",
       				"cuisine" : e.source.text,
       				"coordinates" : {
       					"$exists" : true,
       					"$nearSphere" : userCoords,
       					"$maxDistance" : Alloy.Globals.MAX_MILES
       				}
       			}
       
    *Alloy.Globals.MAX_MILES* is set in alloy.js as Alloy.Globals.MAX_MILES = 10; No radians used. If I were to set MAX_MILES to 10/3959 - the miles-to-radians conversion formula as noted in the API doc - the query returns no records.
  4. Michael Stelly 2014-02-24

    I think I see where the problem is now. Haven't tested it yet. I think I made an incorrect assumption. I assumed that the ios simulator used valid geo-location coordinates. Apparently, it does not. They point to 1 Stockton St, SF, CA. So, of course, if I calculated miles between points A and B, restricting results to 10 miles, I would get no results because the Point A is in CA and B is in OK. /facepalm. That's what I get for assuming. Please close the ticket.

JSON Source