本文介绍了MongoDb 2.6.1错误:17444-“旧点超出了球形查询的范围"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的系统n中将MongoDb升级到2.6.1之后,有时会出现以下错误:

After upgrading MongoDb to 2.6.1 in my System n i get sometimes the following error:

ErrorCode 17444

ErrorCode 17444

此处: https://github.com/mongodb/mongo/blob/master/src/mongo/db/geo/geoquery.cpp#L73 我可以看到由于某些无效数据,这是由mongo db引发的.

Here: https://github.com/mongodb/mongo/blob/master/src/mongo/db/geo/geoquery.cpp#L73I can see that this is raised by mongo db due to some invalid data.

// The user-provided point can be flat.  We need to make sure that it's in bounds.
if (isNearSphere) {
    uassert(17444,
            "Legacy point is out of bounds for spherical query",
            centroid.flatUpgradedToSphere || (SPHERE == centroid.crs));
}

但是目前我不知道为什么以及如何防止它.

But currently i can't figure why and how to prevent it.

我的代码如下:

IEnumerable<BsonValue> cids = companyIds.ToBsonValueArray();


    return Collection.Find(
                            Query.And(
                               Query.In("CompanyId", cids),
                               Query.Near("Location", location.Geography.Longitude, location.Geography.Latitude, location.Radius / 6371000, true))).ToList();

Stacktrace:

Stacktrace:

推荐答案

您使用的是MongoDB 2.6.1或更高版本,因为您正在查看的代码已添加为 JIRA-13666 问题.

You're using MongoDB 2.6.1 or higher because the code you're looking at was added as a fix for a JIRA-13666 issue.

问题在于,当使用超出范围的旧坐标进行调用时,某些$ near查询会使MongoDB服务器崩溃.

The problem was that some $near queries would crash MongoDB server when called with legacy coordinates that are out of range.

您可能正在发送超出范围的坐标.代码部分,用于在以最大距离进行$ near查询时检查经度和纬度(GeoParser::parsePointWithMaxDistance方法/geo/geoparser.cpp"rel =" nofollow> geoparser.cpp ):

You're probably sending coordinates that are out of range. The part of the code that checks longitude and latitude when doing $near queries with max distance (GeoParser::parsePointWithMaxDistance method in geoparser.cpp):

bool isValidLngLat(double lng, double lat) {
    return lat >= -90 && lat <= 90 && lng >= -180 && lng <= 180;
}

如果坐标超出范围centroid.flatUpgradedToSphere将为false,这将导致您收到错误.

If the coordinates are out of range centroid.flatUpgradedToSphere will be false and that will cause the error you're receiving.

您应该将坐标更改为范围内,或者将spherical参数设置为false,以避免出现此错误.

You should either change your coordinates to be in range or set spherical parameter to false to avoid getting this error.

Query.Near("Location", location.Geography.Longitude, 
           location.Geography.Latitude, location.Radius / 6371000, false)

这篇关于MongoDb 2.6.1错误:17444-“旧点超出了球形查询的范围"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-01 19:27