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里可以换成其它在多边形里面的点

posted on 2016-04-13 10:24  chimmu  阅读(218)  评论(0)    收藏  举报