标签:enter 坐标 location within 多边形 fc7 ati bsp pre
1、$box:矩形,使用 {$box:[[<x1>,<y1>],[<x2>,<y2>]]}表示 都是坐标,第一个坐标表示矩形的左边界,第二个坐标表示矩形的右边界 2、$center:圆形,使用 {$center:[[<x1>,<y1>],r]} 第一个表示圆心位置,第二个代表半径 3、$polygon:多边形,使用 {$polygon:[<x1>,<y1>],[<x2>,<y2>],[<x3>,<y3>]}表示 每个数组代表一个坐标点,这些点代表一个多边形
> db.location.find({w:{$geoWithin:{$box:[[0,0],[3,3]]}}}) { "_id" : ObjectId("5b6b6fa572ff7510af7fc783"), "w" : [ 1, 1 ] } { "_id" : ObjectId("5b6b6fa872ff7510af7fc784"), "w" : [ 1, 2 ] } { "_id" : ObjectId("5b6b6fab72ff7510af7fc785"), "w" : [ 3, 2 ] }
> db.location.find({w:{$geoWithin:{$box:[[1,1],[2,3]]}}}) { "_id" : ObjectId("5b6b6fa572ff7510af7fc783"), "w" : [ 1, 1 ] } { "_id" : ObjectId("5b6b6fa872ff7510af7fc784"), "w" : [ 1, 2 ] }
> db.location.find({w:{$geoWithin:{$center:[[0,0],5]}}}) { "_id" : ObjectId("5b6b6fa572ff7510af7fc783"), "w" : [ 1, 1 ] } { "_id" : ObjectId("5b6b6fa872ff7510af7fc784"), "w" : [ 1, 2 ] } { "_id" : ObjectId("5b6b6fab72ff7510af7fc785"), "w" : [ 3, 2 ] }
> db.location.find({w:{$geoWithin:{$polygon:[[0,0],[0,1],[2,5],[6,1]]}}}) { "_id" : ObjectId("5b6b6fa572ff7510af7fc783"), "w" : [ 1, 1 ] } { "_id" : ObjectId("5b6b6fa872ff7510af7fc784"), "w" : [ 1, 2 ] } { "_id" : ObjectId("5b6b6fab72ff7510af7fc785"), "w" : [ 3, 2 ] }
标签:enter 坐标 location within 多边形 fc7 ati bsp pre
原文地址:https://www.cnblogs.com/wzndkj/p/9452774.html