首页 \ 问答 \ 查询中的Mongodb $(Mongodb $within query)

查询中的Mongodb $(Mongodb $within query)

我正在尝试使用$within运算符在mongodb进行地理空间查询。 我有一个集合条目,其中包含一个位置字段:

location: {
  bounds: {
    south_west: { lat: XX.XXXXXX, lng: XX.XXXXX },
    north_east: { lat: XX.XXXXXX, lng: XX.XXXXX }
  },
  center: {
    lat: XX.XXXXXX,
    lng: XX.XXXXXX
  }
}

对于我的查询,我想让所有location.center都位于google.maps对象范围内的location.center 。 我有这样的事情:

query = {}

var southWest = map.getBounds().getSouthWest();
southWest = [southWest.lat(), southWest.lng()];

var northEast = map.getBounds().getNorthEast();
northEast = [northEast.lat(), northEast.lng()];

query["location.center"] = { $within: { $box: [southWest, northEast] } }

但我一直都会

Exception from Meteor.flush: Error: Unrecognized key in selector: $within
at Error (<anonymous>)
at Function.LocalCollection._exprForConstraint (http://localhost:3000/packages/minimongo/selector.js?2373a18a9a4640513e41d7850f17f62f76b7c589:559:11)
at Function.LocalCollection._exprForOperatorTest (http://localhost:3000/packages/minimongo/selector.js?2373a18a9a4640513e41d7850f17f62f76b7c589:468:36)
at Function.LocalCollection._exprForKeypathPredicate (http://localhost:3000/packages/minimongo/selector.js?2373a18a9a4640513e41d7850f17f62f76b7c589:387:34)
at Function.LocalCollection._exprForSelector (http://localhost:3000/packages/minimongo/selector.js?2373a18a9a4640513e41d7850f17f62f76b7c589:307:36)
at Function.LocalCollection._compileSelector (http://localhost:3000/packages/minimongo/selector.js?2373a18a9a4640513e41d7850f17f62f76b7c589:284:24)
at new LocalCollection.Cursor (http://localhost:3000/packages/minimongo/minimongo.js?7f5131f0f3d86c8269a6e6db0e2467e28eff6422:71:39)
at LocalCollection.find (http://localhost:3000/packages/minimongo/minimongo.js?7f5131f0f3d86c8269a6e6db0e2467e28eff6422:57:10)
at _.extend.find (http://localhost:3000/packages/mongo-livedata/collection.js?3ef9efcb8726ddf54f58384b2d8f226aaec8fd53:155:34)
at Template.feed.feed_items (http://localhost:3000/client/modules/js/feed.js?5ed30ddbd861944b636dbe03c13cc80421258a5b:129:17) 

我不确定如何继续。 使用简单的JSON.stringify(查询),我注意到查询就像是一样

{"location.center":{"$within":{"$box":[[39.93623526127148,-75.63687337060549],[39.984129247435064,-75.57438862939455]]}}}

无论如何,我可以阻止引号被$within$box选择器包围? 我相信这是我的例外被抛出的地方。


I'm attempting to make a geospatial query in mongodb using the $within operator. I have a collection entry that has a location field which holds:

location: {
  bounds: {
    south_west: { lat: XX.XXXXXX, lng: XX.XXXXX },
    north_east: { lat: XX.XXXXXX, lng: XX.XXXXX }
  },
  center: {
    lat: XX.XXXXXX,
    lng: XX.XXXXXX
  }
}

For my query, I'd like to get all places with a location.center that falls within the bounds of the google.maps object. I have something like this:

query = {}

var southWest = map.getBounds().getSouthWest();
southWest = [southWest.lat(), southWest.lng()];

var northEast = map.getBounds().getNorthEast();
northEast = [northEast.lat(), northEast.lng()];

query["location.center"] = { $within: { $box: [southWest, northEast] } }

But I consistently get

Exception from Meteor.flush: Error: Unrecognized key in selector: $within
at Error (<anonymous>)
at Function.LocalCollection._exprForConstraint (http://localhost:3000/packages/minimongo/selector.js?2373a18a9a4640513e41d7850f17f62f76b7c589:559:11)
at Function.LocalCollection._exprForOperatorTest (http://localhost:3000/packages/minimongo/selector.js?2373a18a9a4640513e41d7850f17f62f76b7c589:468:36)
at Function.LocalCollection._exprForKeypathPredicate (http://localhost:3000/packages/minimongo/selector.js?2373a18a9a4640513e41d7850f17f62f76b7c589:387:34)
at Function.LocalCollection._exprForSelector (http://localhost:3000/packages/minimongo/selector.js?2373a18a9a4640513e41d7850f17f62f76b7c589:307:36)
at Function.LocalCollection._compileSelector (http://localhost:3000/packages/minimongo/selector.js?2373a18a9a4640513e41d7850f17f62f76b7c589:284:24)
at new LocalCollection.Cursor (http://localhost:3000/packages/minimongo/minimongo.js?7f5131f0f3d86c8269a6e6db0e2467e28eff6422:71:39)
at LocalCollection.find (http://localhost:3000/packages/minimongo/minimongo.js?7f5131f0f3d86c8269a6e6db0e2467e28eff6422:57:10)
at _.extend.find (http://localhost:3000/packages/mongo-livedata/collection.js?3ef9efcb8726ddf54f58384b2d8f226aaec8fd53:155:34)
at Template.feed.feed_items (http://localhost:3000/client/modules/js/feed.js?5ed30ddbd861944b636dbe03c13cc80421258a5b:129:17) 

And I'm unsure how to proceed. With a simple JSON.stringify(query) I've noticed that the query is coming out like

{"location.center":{"$within":{"$box":[[39.93623526127148,-75.63687337060549],[39.984129247435064,-75.57438862939455]]}}}

Is there anyway I can prevent the quotes from being wrapped around the $within and $box selectors? I believe that's where my exception is being thrown from.


原文:https://stackoverflow.com/questions/14262881
更新时间:2022-03-17 15:03

最满意答案

您可能需要阅读这些通知图标,点击,双击,右键点击......这有什么用? 来自Raymond Chen的博客The Old New Thing

他甚至还包括指向通知区域指南的链接(通常称为“ 系统托盘 ”)。


You may want to read Those notification icons, with their clicks, double-clicks, right-clicks... what's up with that? from Raymond Chen's blog The Old New Thing.

He even includes a link to Guidelines for the Notification Area (more commonly known as the "system tray").

相关问答

更多
  • 控制台没有窗口可以自行减少。 它在命令提示符窗口中运行。 您可以勾住窗口消息并将窗口隐藏在最小程度。 在你的应用程序中,可以像在Windows应用程序中那样添加托盘图标。 好吧,不知何故,这味道 ... 但是:我不知道你为什么要这样做。 控制台应用程序在设计上与Windows应用程序不同。 因此,也许这是一个选项,将应用程序更改为Windows窗体应用程序? A console has no window to minimize by itself. It runs in a command prompt ...
  • Mango现在可以通过设置BackgroundColor和Opacity来实现透明度和颜色: shell:SystemTray.IsVisible="True" shell:SystemTray.BackgroundColor="Transparent" shell:SystemTray.Opacity="0" 我会默认显示它,除非它真的妨碍你解决问题,特别是如果它是一个应用程序而不是一个游戏。 Transparency and colors are now possible with Mango by ...
  • Java 6具有新功能,可以创建使用系统托盘的应用程序。 Java SE 6文章中的新系统托盘功能详细介绍,并提供了一些示例代码。 新添加的java.awt包中的SystemTray和TrayIcon类可用于将图标添加到系统托盘中。 图标可以响应鼠标点击并使用弹出式菜单。 但是,这个新功能是AWT的一部分,所以它不能很好地集成Swing组件。 下面是一个使用Java 6中的SystemTray和TrayIcon类制作的系统托盘中显示的小时钟示例: Java中的系统托盘时钟应用程序http://coobird ...
  • C#系统托盘最小化与NotifyIcon托盘 将窗口最小化到系统托盘 处理表单的Resize事件。 在此处理程序中,您将覆盖Resize事件的基本功能,以使窗体最小化到系统托盘,而不是任务栏。 这可以通过在表单的Resize事件处理程序中执行以下操作来完成:检查窗体的WindowState属性是否设置为FormWindowState.Minimized。 如果是,隐藏您的表单,启用NotifyIcon对象,并显示显示一些信息的气球提示。 WindowState成为FormWindowState.Normal ...
  • 您将需要一个全球访问的全局托盘图标。 通过在类的不同实例中使用一个静态变量来实现这一点。 那么,如果你想: 打开一个表单:在变量中保留对最新表单的引用并将其打开。 打开所有最小化的表单:遍历每个表单并再次打开它们。 You will need a single global tray icon that they all access. Do this by using a static variable that stays the same throughout different instances ...
  • 服务无法在Vista中显示UI(包括系统托盘图标),并且在早期版本中不鼓励它。 在所有版本的Windows中,应将用户界面分离为可由登录用户运行的非服务应用程序,管理该用户托盘的系统托盘图标,并根据需要与后端服务进行通信许多可用的IPC机制(管道,套接字,COM,RPC,WCF等)。 A service cannot display a UI at all (including a System Tray icon) in Vista onwards, and it is discouraged in ea ...
  • 完成了! 带绿色的鞋,请参阅sample54.rb done! with green shoes, see sample54.rb
  • “系统托盘”是explorer.exe一部分。 如果没有运行,你几乎没有桌面。 至于识别系统托盘中的内容...进入系统托盘,应用程序必须注册Windows shell(aka explorer.exe )。 在这些应用程序启动之前,您无法确定哪些应用程序可能存在。 如果shell没有运行,那些应用程序也不会运行。 The "system tray" is part of explorer.exe. If that's not running, you've pretty much got no deskto ...
  • 您可能需要阅读这些通知图标,点击,双击,右键点击......这有什么用? 来自Raymond Chen的博客The Old New Thing 。 他甚至还包括指向通知区域指南的链接(通常称为“ 系统托盘 ”)。 You may want to read Those notification icons, with their clicks, double-clicks, right-clicks... what's up with that? from Raymond Chen's blog The Ol ...
  • 尝试从QSystemTrayIcon的激活信号下拉菜单。 void Window::iconActivated(QSystemTrayIcon::ActivationReason reason) { switch (reason) { case QSystemTrayIcon::Trigger: // show your menu here } } Try to drop down menu from activated signal o ...

相关文章

更多

最新问答

更多
  • h2元素推动其他h2和div。(h2 element pushing other h2 and div down. two divs, two headers, and they're wrapped within a parent div)
  • 创建一个功能(Create a function)
  • 我投了份简历,是电脑编程方面的学徒,面试时说要培训三个月,前面
  • PDO语句不显示获取的结果(PDOstatement not displaying fetched results)
  • Qt冻结循环的原因?(Qt freezing cause of the loop?)
  • TableView重复youtube-api结果(TableView Repeating youtube-api result)
  • 如何使用自由职业者帐户登录我的php网站?(How can I login into my php website using freelancer account? [closed])
  • SQL Server 2014版本支持的最大数据库数(Maximum number of databases supported by SQL Server 2014 editions)
  • 我如何获得DynamicJasper 3.1.2(或更高版本)的Maven仓库?(How do I get the maven repository for DynamicJasper 3.1.2 (or higher)?)
  • 以编程方式创建UITableView(Creating a UITableView Programmatically)
  • 如何打破按钮上的生命周期循环(How to break do-while loop on button)
  • C#使用EF访问MVC上的部分类的自定义属性(C# access custom attributes of a partial class on MVC with EF)
  • 如何获得facebook app的publish_stream权限?(How to get publish_stream permissions for facebook app?)
  • 如何防止调用冗余函数的postgres视图(how to prevent postgres views calling redundant functions)
  • Sql Server在欧洲获取当前日期时间(Sql Server get current date time in Europe)
  • 设置kotlin扩展名(Setting a kotlin extension)
  • 如何并排放置两个元件?(How to position two elements side by side?)
  • 如何在vim中启用python3?(How to enable python3 in vim?)
  • 在MySQL和/或多列中使用多个表用于Rails应用程序(Using multiple tables in MySQL and/or multiple columns for a Rails application)
  • 如何隐藏谷歌地图上的登录按钮?(How to hide the Sign in button from Google maps?)
  • Mysql左连接旋转90°表(Mysql Left join rotate 90° table)
  • dedecms如何安装?
  • 在哪儿学计算机最好?
  • 学php哪个的书 最好,本人菜鸟
  • 触摸时不要突出显示表格视图行(Do not highlight table view row when touched)
  • 如何覆盖错误堆栈getter(How to override Error stack getter)
  • 带有ImageMagick和许多图像的GIF动画(GIF animation with ImageMagick and many images)
  • USSD INTERFACE - > java web应用程序通信(USSD INTERFACE -> java web app communication)
  • 电脑高中毕业学习去哪里培训
  • 正则表达式验证SMTP响应(Regex to validate SMTP Responses)