Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7429553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:59:15+00:00 2026-05-29T08:59:15+00:00

Per title – I am using the official mongodb driver and I am looking

  • 0

Per title – I am using the official mongodb driver and I am looking to get all POIs within the given bounding box.

So far I have:

MongoCollection<BsonDocument> collection = _MongoDatabase.GetCollection("pois");

BsonArray lowerLeftDoc = new BsonArray(new[] { lowerLeft.Lon, lowerLeft.Lat});
BsonArray upperRightDoc = new BsonArray(new[] { upperRight.Lon, upperRight.Lat});

BsonDocument locDoc = new BsonDocument 
{
   { "$within", new BsonArray(new[] { lowerLeftDoc, upperRightDoc})}
};

BsonDocument queryDoc = new BsonDocument { { "loc", locDoc }};

IList<TrafficUpdate> updates = new List<TrafficUpdate>();
var results = collection.Find(new QueryDocument(queryDoc)).SetLimit(limit);
foreach (BsonDocument t in results)
{
} 

Unfortunatelly this doesnt work. I get:

QueryFailure flag was unknown $within type: 0 (response was { “$err” :
“unknown $within type: 0”, “code” : 13058 }).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T08:59:16+00:00Added an answer on May 29, 2026 at 8:59 am

    The problem in your code is that you didnt specify which geo operation you wanted to use. You only specified $within but missed where. you must specify $within along with $box (bounding box) , $polygon , $center or $centerSphere / $nearSphere.

    This is the correct mongo syntax to run $box queries

    > box = [[40.73083, -73.99756], [40.741404,  -73.988135]]
    > db.places.find({"loc" : {"$within" : {"$box" : box}}})
    

    i am not sure about the c# mongodb syntax. But if you include ‘$box’, it ll work

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using Visual Studio 2005 As per the title; MSDN and google can't tell me,
As per title. Using native ID's The only thing I can think to do
Question as per the title really. I'm looking for a way to step through
As per the title, I am looking for a Python function similar to Lua's
As per the title. I don't really want to list all the other members
As per title, what practise for string comparisons do you use and why?
as per the title; is it possible to have nested comments in valid HTML?
As per the title, how would I fit text into a UILabel when the
As per the title, is there PHP equivalent of __name__ == __main__ ? Is
As per the title, plus what are the limitations and gotchas. For example, on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.