3
我已經獲得了點(緯度,經度)數組中點的列表。我已經對這些數組做了一個索引,現在我想知道一個點是否在該多邊形內。Mongodb:如何檢查點是否包含在多邊形中?
MongoDB有可能嗎? 我已經與這些命令,但沒有運氣嘗試:
> polygonA = [ [ 48.780809,2.307129],[ 48.781809,2.300129],[ 48.770809,2.317129]]
> db.contours.find({ "rings.ring" : { "$within" : { "$polygon" : polygonA } } })
和
> db.runCommand({ geoNear : "contours" , within : [2.307129,48.780809,], num : 10 });
我的數據結構爲:
> db.contours.findOne({},{'rings':0})
{
"_id" : ObjectId("50364617d591ac166000c196"),
"foundfieldname" : "Name",
"geometrytype" : "geometryPolygon",
"attributes" : {
"Shape" : "Polygon",
"Name" : "France",
"Type" : "Country",
"Country" : "France",
"Area" : "1162358716567.45"
},
"country" : "France",
"rings":{
"ring":[[12.32,43.54],...],
...
}
感謝
這是一個C#項目嗎?你有沒有訪問Windows窗體的System.Drawing庫? –
是的我正在使用C#項目來連接到mongo。我可以訪問該庫。有沒有一種形式來使用這個庫來完成這個? –