您的位置:首页 > 编程语言 > Go语言

mongo按坐标点查询其所在多边形区域

2016-04-13 10:24 344 查看
1.存储进去的格式为:

db.geom.insert({"demo":

                      {"type":"Polygon",

                         coordinates:

                          [[[ 17.60083012593064, 78.18557739257812], 

                            [ 17.16834652544664, 78.19381713867188], 

                            [ 17.17490690610013, 78.739013671875], 

                            [ 17.613919673106714, 78.73489379882812],

                            [ 17.60083012593064, 78.18557739257812]

                          ]]

                      }

                 });

注意最后一个坐标点须与第一个坐标点一致,以形成封闭的区域

2.查找:

db.geom.find({"demo": {$geoIntersects: {$geometry:{ "type" : "Point", "coordinates" : [ 17.613919673106714, 78.73489379882812] }}}});

coordinates里可以换成其它在多边形里面的点
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: