我正在尝试学习如何在 MongoDB 中使用地理空间查询,但似乎我真的做对了!所以我在 mongo 中有我的瓷砖集合,为了争论,假设我只有一个文档,最准确的是,这个:
{
"_id" : "-180-9018090",
"geometry" : {
"type" : "Polygon",
"coordinates" : [
[
[
-180,
-90
],
[
180,
-90
],
[
180,
90
],
[
-180,
90
],
[
-180,
-90
]
]
]
},
"type" : "Feature",
"properties" : {
"zoom-level" : 0,
"center" : [
0,
0
]
}
}
Run Code Online (Sandbox Code Playgroud)
这基本上代表了整个世界。现在我想看看某个点是否在这个区域内,比如说 (0,0)。我的理解是我应该使用 geointersects 来完成这个任务,所以查询应该是这样的(?):
db.tiles.find({
geometry: {
$geoIntersects: {
$geometry: {
type: "Point" ,
coordinates: [ 0,0]
}
}
}
}); …
Run Code Online (Sandbox Code Playgroud) 我想知道,当您使用 2x2 内核进行卷积时,您将运算结果放在哪里?使用对称掩码,结果应用于与掩码中心相对应的像素;那么当面具没有中心时会发生什么?此外,为什么有人会使用大小均匀的内核?
在 python 中,不可能多次定义init函数,在了解该语言如何工作的情况下,这是相当公平的。当创建一个对象时,会调用init,因此,拥有两个对象会产生不确定性。然而,在某些设计中,这种特性是需要的。例如:
class Triangle(object):
def __init__(self,vertices):
self.v1 = vertices[0]
self.v2 = vertices[1]
self.v3 = vertices[2]
def area(self):
# calculate the are using vertices
...
return result
class Triangle(object):
def __init__(self,sides):
self.v1 = sides[0]
self.v2 = sides[1]
self.v3 = sides[2]
def area(self):
# calculate the are using sides
...
return result
Run Code Online (Sandbox Code Playgroud)
在这种情况下,我们有相同数量的属性要初始化,而且它们是相关的,这样您就可以从一个属性获得另一个属性。确实,在这个特定的示例中,我们可以处理以下事实:顶点是元组,而边可能是浮点数(或字符串或其他东西)但当然情况并非总是如此。
一种可能的解决方案是将初始化过程委托给其他函数,例如:
class Triangle(object):
def __init__(self):
self.v1 = None
self.v2 = None
self.v3 = None
def byVertices(self,vertices):
self.v1 = vertices[0]
self.v2 = vertices[1]
self.v3 = …
Run Code Online (Sandbox Code Playgroud) 是否可以将数字转换为一周中的某一天?
我试过了
to_date(1,'DAY')
to_date('1','DAY')
Run Code Online (Sandbox Code Playgroud)
没有运气.