我试图获得距离某个位置20公里范围内最近的解析对象。
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()查询也可以,但不能在公尺内查询。
这是一个解析服务器错误或mlab问题还是我自己的愚蠢错误?
答案 0 :(得分:1)
对此感到抱歉。事实证明,在设置geopoint时我搞砸了将javascript字符串转换为float。