2016-08-08 24 views
0

我试图得到距离一个位置20公里内最接近的解析对象。withinkilometers geoquery在解析云失败,并与MongoDB错误

var testPoint = new Parse.GeoPoint({latitude: fromLatLng.lat, longitude: fromLatLng.lng}); 
    var BKcity = Parse.Object.extend("BKcity"); 
    var cityQuery = new Parse.Query(BKcity); 
    //Throws mongo error 
    cityQuery.withinKilometers("location", testPoint, 20); 
    cityQuery.find({ 
    ... 

与然而查询失败:

�[31merror�[39m: Uncaught internal server error. { [MongoError: Can't canonicalize query: BadValue geo near accepts just one argument when querying for a GeoJSON point. Extra field found: $maxDistance: 0.003139224611520954] 
     name: 'MongoError', 
     message: 'Can\'t canonicalize query: BadValue geo near accepts just one argument when querying for a GeoJSON point. Extra field found: $maxDistance: 0.003139224611520954', 
     '$err': 'Can\'t canonicalize query: BadValue geo near accepts just one argument when querying for a GeoJSON point. Extra field found: $maxDistance: 0.003139224611520954', 
     code: 17287 } MongoError: Can't canonicalize query: BadValue geo near accepts just one argument when querying for a GeoJSON point. Extra field found: $maxDistance: 0.003139224611520954 
     at Function.MongoError.create (D:\home\site\wwwroot\node_modules\mongodb-core\lib\error.js:31:11) 
     at queryCallback (D:\home\site\wwwroot\node_modules\mongodb-core\lib\cursor.js:182:34) 
     at Callbacks.emit (D:\home\site\wwwroot\node_modules\mongodb-core\lib\topologies\server.js:119:3) 
     at null.messageHandler (D:\home\site\wwwroot\node_modules\mongodb-core\lib\topologies\server.js:295:23) 
     at Socket.<anonymous> (D:\home\site\wwwroot\node_modules\mongodb-core\lib\connection\connection.js:285:22) 
     at emitOne (events.js:77:13) 
     at Socket.emit (events.js:169:7) 
     at readableAddChunk (_stream_readable.js:146:16) 
     at Socket.Readable.push (_stream_readable.js:110:10) 
     at TCP.onread (net.js:523:20) 

查询工作于JavaScript,.near()查询还工作,但不withinKilometers查询。

这是一个分析服务器错误或mlab问题或我的一个愚蠢的错误?

+0

什么是您的分析服务器版本? –

回答

1

对不起。事实证明,当我设置网址时,我把JavaScript字符串转换为浮点数。

+0

你是如何解决它的?只需要对它进行编号? – InfinitePrime

+0

不能准确记住,但只是确保它是一个浮动。 – pseudozach