查询中的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 thegoogle.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
最满意答案
您可能需要阅读这些通知图标,点击,双击,右键点击......这有什么用? 来自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 ...
-
隐藏或不隐藏Windows Phone 7应用程序中的系统托盘?(Hide or not to hide the system tray in a Windows Phone 7 application?)[2022-07-28]
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 ...
-
最小化应用程序到系统托盘(minimize app to system tray)[2023-04-27]
C#系统托盘最小化与NotifyIcon托盘 将窗口最小化到系统托盘 处理表单的Resize事件。 在此处理程序中,您将覆盖Resize事件的基本功能,以使窗体最小化到系统托盘,而不是任务栏。 这可以通过在表单的Resize事件处理程序中执行以下操作来完成:检查窗体的WindowState属性是否设置为FormWindowState.Minimized。 如果是,隐藏您的表单,启用NotifyIcon对象,并显示显示一些信息的气球提示。 WindowState成为FormWindowState.Normal ... -
系统托盘图标(System Tray Icon)[2023-01-07]
您将需要一个全球访问的全局托盘图标。 通过在类的不同实例中使用一个静态变量来实现这一点。 那么,如果你想: 打开一个表单:在变量中保留对最新表单的引用并将其打开。 打开所有最小化的表单:遍历每个表单并再次打开它们。 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 ...