我在MongoDB中有一个带有2dsphere索引的集合.我想保存的对象如下所示:
{
"type" : "Polygon",
"coordinates" : [
[
[
5.052617929724351,
52.64653192570052
],
[
5.051738165167465,
52.64765805672784
],
[
5.054162882116928,
52.64831549553909
],
[
5.054592035559312,
52.64780777138566
],
[
5.055364511755601,
52.64790541110375
],
[
5.056094072607651,
52.64688343792051
],
[
5.054237983969346,
52.64661654927096
],
[
5.052617929724351,
52.64653192570052
]
]
]
}
Run Code Online (Sandbox Code Playgroud)
根据http://geojsonlint.com/,这是完全有效的GeoJSON.但MongoDB表示无法提取地理密钥,因为GeoJSON可能格式不正确.
任何人都可以帮助我并发现错误吗?
这是我得到的MongoDB错误:
insertDocument :: caused by :: 16755 Can't extract geo keys from object, malformed geometry?
Run Code Online (Sandbox Code Playgroud) 由于某种原因,我使用 Docker Swarm 中的 Docker Compose 文件创建的作为堆栈一部分的 Docker 容器没有正确的网络设置。
在这里阅读有关网络的 Docker 文档,我看到:
By default, a container inherits the DNS settings of the Docker daemon, including the /etc/hosts and /etc/resolv.conf.You can override these settings on a per-container basis.
但是,当我使用 Docker Compose 文件创建新堆栈时,容器内的 /etc/resolv.conf 文件与主机的 /etc/resolv.conf 文件完全不同。因此,我无法连接到同一网络上的数据库服务器。
现在主机上的 /etc/resolv.conf 看起来像这样:
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 10.0.0.254
search localdomain
Docker 容器内部如下所示:
search …
我正在创建一个程序,将SVG文件转换为我自己的格式.我创建了一个基于Web的应用程序来执行此操作.我使用Web浏览器的默认DOM解析功能来迭代SVG内容.
使用Javascript,我可以使用以下命令获取SVG路径元素:
var path = document.getElementById("path3388");
Run Code Online (Sandbox Code Playgroud)
我可以使用以下方式获取路径段:
var pathSegments = path.pathSegList
Run Code Online (Sandbox Code Playgroud)
但是,这些路径段相对于定义的任何父SVG元素.转换不包含在路径段列表中.
有没有办法获得这条路径的绝对坐标,因为它们最终在屏幕上绘制时使用?
示例:说我得到以下SVG代码段:
<g transform="translate(100, 100)">
<g transform="translate(50, 50)">
<path d="M 0,0 10,0 10,10"></path>
</g>
</g>
Run Code Online (Sandbox Code Playgroud)
我想要的是检索路径的坐标与应用的两个g元素的变换.在这种情况下,路径的坐标应为:
[150,150], [160, 150], [160, 160]
Run Code Online (Sandbox Code Playgroud) 我正在尝试安排附加了一些自定义数据的本地通知,然后当用户通过单击通知打开应用程序时,我会读取该数据.
我安排这样的本地通知:
UILocalNotification *notification = [[UILocalNotification alloc] init];
notification.fireDate = [[NSDate date] dateByAddingTimeInterval:10];
notification.alertBody = @"Hello World!";
notification.userInfo = [[NSDictionary alloc] initWithObjectsAndKeys:
@"123123123123", @"beaconUUID",
[NSNumber numberWithInt:10], @"beaconMajor",
[NSNumber numberWithInt:20], @"beaconMinor",
nil];
[[UIApplication sharedApplication] scheduleLocalNotification:notification];
Run Code Online (Sandbox Code Playgroud)
然后在处理通知的代码中我这样做:
- (void)onAppDidBecomeActive:(NSNotification*)notification
{
NSLog(@"Object = %@", [notification object]);
NSDictionary* userInfo = [notification userInfo];
NSLog(@"UserInfo = %@", userInfo);
NSString* beaconUUID = [userInfo objectForKey:@"beaconUUID"];
NSLog(@"Beacon UUID = %@", beaconUUID);
}
Run Code Online (Sandbox Code Playgroud)
我的问题是,当我尝试读取userInfo时,它总是返回null.如何从NSNotification对象中读取userInfo字典?
上面代码示例中的三个NSLog调用在控制台中打印以下内容:
2015-02-04 14:11:52.690 BeaconPlugin[17050:724150] Object = <UIConcreteLocalNotification: 0x7ff1d37199a0>{
fire date = Wednesday, February 4, 2015 at …Run Code Online (Sandbox Code Playgroud) 我有以下架构
var Schema = new mongoose.Schema({
type: {required: true, type: String, enum: ["device", "beacon"], index: true},
device: {
type: {type: String},
version: {type: String},
model: {type: String}
},
name: String,
beaconId: {required: false, type: mongoose.Schema.Types.ObjectId},
lastMeasuredTimestamp: {type: Number, index: true},
lastMeasuredPosition: {type: [Number], index: "2dsphere"},
lastMeasuredFloor: {type: Number, index: true}
}, {strict: false});
Run Code Online (Sandbox Code Playgroud)
请注意,我已将严格设置为 false。这是因为将架构中未定义的自定义属性添加到文档是有效的。
接下来我做以下查询
DB.Document.update({_id: "SOME_ID_HERE"}, {$set: {type: "bull"}}, {runValidators: true})
这会将属性“type”更改为根据 Mongoose 架构无效的值。我使用 runValidators 选项来确保运行模式验证。
但是,此查询的最终结果是“type”更改为“bull”并且不运行验证。但是,当我将严格设置为 true 时,验证确实运行并(正确)显示了错误。
为什么严格会影响验证是否运行?当我查看这个描述http://mongoosejs.com/docs/guide.html#strict 时,它只提到严格限制添加未在架构中定义的属性(我不想要这个特定架构的东西)。
安装信息:
我正在我正在开发的应用程序中集成推送通知.我选择使用Firebase云消息传递(FCM)来支持Android和iOS.
当使用控制台发送推送消息时,我看到有一个选项可以延迟实际发送推送通知.但是,当检查HTTP文档时,我似乎无法找到此选项.
我如何安排通知,以便以后使用FCM和HTTP API发送通知?
android push-notification ios firebase firebase-cloud-messaging
我正在将e2e测试集成到我的项目中。该项目使用Typescript(2.6.1)。
我刚刚安装了量角器(5.2.0),但是无论我做什么,Typescript都无法从量角器模块导入任何内容。
我的tsconfig看起来像这样:
{
"compilerOptions": {
"target": "es5",
"module": "amd"
},
"exclude": [
"./spec",
"./node_modules",
"./bower_components"
]
}
Run Code Online (Sandbox Code Playgroud)
我非常简单的试用测试如下所示:
import { browser } from "protractor";
describe("test should run", () => {
it("should navigate to the page", () => {
});
});
Run Code Online (Sandbox Code Playgroud)
我收到以下错误: TypeScript error: usermanagement/ts/controllers/RolesController.e2e.ts(1,25): error TS2307: Cannot find module 'protractor'.
查看我node_modules文件夹中的Protractor安装,我确实找到了对键入文件和实际键入本身的引用。但是Typescript根本不会“看到”它们。有趣的是,Typescript在node_modules/@types文件夹中查找类型没有问题。
有人知道我在做什么错吗?
ios ×2
mongodb ×2
android ×1
docker ×1
docker-swarm ×1
e2e-testing ×1
firebase ×1
geojson ×1
javascript ×1
mongoose ×1
node.js ×1
objective-c ×1
protractor ×1
svg ×1
typescript ×1