title: MongoDb 2.6.1 Error: 17444 - "Legacy point is out of bounds for spherical query"
body: <p>After upgrading MongoDb to 2.6.1 in my System n i get sometimes the following error:</p>
  
  <blockquote>
    <p>Legacy point is out of bounds for spherical query</p>
  </blockquote>
  
  <p>ErrorCode 17444</p>
  
  <p>Here: <a href="https://github.com/mongodb/mongo/blob/master/src/mongo/db/geo/geoquery.cpp#L73" rel="nofollow">https://github.com/mongodb/mongo/blob/master/src/mongo/db/geo/geoquery.cpp#L73</a>
  I can see that this is raised by mongo db due to some invalid data. </p>
  
  <pre><code>// 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));
  }
  </code></pre>
  
  <p>But currently i can't figure why and how to prevent it.</p>
  
  <p>My Code looks like this:</p>
  
  <pre><code>IEnumerable&lt;BsonValue&gt; 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();
  </code></pre>
  
  <p>Stacktrace:</p>
  
  <blockquote>
    <p>QueryFailure flag was Legacy point is out of bounds for spherical
    query (response was { "$err" : "Legacy point is out of bounds for
    spherical query", "code" : 17444 }).
         at MongoDB.Driver.Internal.MongoReplyMessage<code>1.ReadFrom(BsonBuffer buffer, IBsonSerializationOptions serializationOptions)
         at MongoDB.Driver.Internal.MongoConnection.ReceiveMessage[TDocument](BsonBinaryReaderSettings
    readerSettings, IBsonSerializer serializer, IBsonSerializationOptions
    serializationOptions)
         at MongoDB.Driver.Operations.QueryOperation</code>1.GetFirstBatch(IConnectionProvider
    connectionProvider)</p>
  </blockquote>