Titanium JIRA Archive
Appcelerator Community (AC)

[AC-147] Clouds.Users.query's $nearSphere has reversed Lat/Long requirements

GitHub Issuen/a
TypeBug
Priorityn/a
StatusResolved
ResolutionInvalid
Resolution Date2015-06-12T06:28:37.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsArrowDB
Labelsn/a
ReporterKeylo E.
AssigneeRadamantis Torres-Lechuga
Created2015-06-02T02:35:29.000+0000
Updated2015-06-12T06:28:37.000+0000

Description

Following http://docs.appcelerator.com/arrowdb/latest/#!/guide/search_query for $nearSphere and $maxDistance, fails to find users coordinates 4 miles from current position at even greater maxDistances until reversing Long/Lat to Lat/Long. Since API calls return Users' Coordinates objects reversed from what is seen in ArrowDB's Dashboard I was unsure if this was a bug all around or a documentation issue.
Titanium.Geolocation.getCurrentPosition(function(e)
	{
	    if (e.error) {
	        alert('cannot get your current location');
	        return;
	    }
		Cloud.Users.query({
			response_json_depth: 2,
		        page: 1,
		        per_page: 100,
		        where: { 
	    		"coordinates":{"$nearSphere":[Number(e.coords.longitude), Number(e.coords.latitude)], "$maxDistance" : 0.025}
	        } 
		}, function (e) {
		    if (e.success) {
		        alert('Success: ' + e.users.length);
		    } else {
		        alert('Error:\n' + ((e.error && e.message) || JSON.stringify(e)));
		    }
		});
	});

Comments

  1. Keylo E. 2015-06-11

    $nearSphere is working as it should be. The confusion was from mistakes I'd made changing Lat/Lon in ArrowDB's Users coordinates, thinking I'd entered them incorrectly because the coordinates object returned by Cloud.users.query was reversed and had no (apparent) way to access individual lat or lon. My appologies. A means of accessing the returned event.users[0].custom_fields.coordinates.LATITUDE by name would help. ArrowDB's User Lat/Lon (correct/popular order) !http://ibin.co/24t0r8VU5rvI! returned coordinates object using Cloud.Users.query method (reversed order) !http://ibin.co/24t1k5QjI8yc!
  2. Fokke Zandbergen 2015-06-12

    User error.

JSON Source