1

我有一个 mongodb 数据库,其中包含以下形式的纬度和经度:
例如 {a:1,latitude:1.0,longitude:2.0,b:2} 等。
我希望检查纬度经度对是否在坐标中存在。

我已在

collecton = db['DbName']
cursor = collection.find()
for doc in cursor:  
    collection.find({"LondonCoordinates":{"$geoIntersects":{"$geometry":{"type":"Point", "coordinates":[longitude1, latitude1]}}}}  

也:

for doc in cursor: 
    collection.find({loc: {$geoWithin: {$geometry: {type : "Polygon" ,coordinates: [[[ -0.5103750999999999, 51.286760199999996], [ -0.5103750999999999, 51.6918741],[ 0.33401549999999997, 51.6918741],[ 0.33401549999999997, 51.286760199999996], [ -0.5103750999999999, 51.286760199999996]]]}}}})    

这些似乎不起作用。我想要的是一个真/假值,无论 [doc["Longitude"],doc["Latitude"]] 是否存在于多边形中。

4

0 回答 0