我需要使用GeoWithin在找到他的位置之后找到几乎指向用户,之前是否使用过任何身体?
答案 0 :(得分:1)
顺便说一下,这是near
和GeoWithin
的示例:
var point = GeoJson.Point(GeoJson.Geographic(-73.97, 40.77));
var filter = Builders<BsonDocument>.Filter.Near("location", point, 10);
var a = collection.Find(filter1).Any();
var filter2 = Builders<BsonDocument>.Filter.GeoWithin("location", point);
var b = collection.Find(filter2).Any();
您还可以使用GeoWithinPolygon
和GeoWithinCenter
。
double[,] polygon = new double[,] { { -73.97, 40.77 }, { -73.9928, 40.7193 }, { -73.9375, 40.8303 }, { -73.97, 40.77 } };
var filter3 = Builders<BsonDocument>.Filter.GeoWithinPolygon("location", polygon);
var c = collection.Find(filter3).Any();
var filter4 = Builders<BsonDocument>.Filter.GeoWithinCenter("location", -73.97, 40.77, 10);
var d = collection.Find(filter4).Any();
希望有帮助。