我使用php查询附近的地方。
我在mongoDB中有以下geoJSON
{
"_id": {
"$oid": "dsfsdfsdfsdfsdfsdfsdf"
},
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
125.6342343431232,
10.121543413333423
]
},
"properties": {
"name": "Any Place"
}
}
我想查询附近有关某个点的位置,我在php中有索引
$collection->ensureIndex(array("geometry" => "2dsphere"));
我的查询是:
$arr = $collection->find(array('geometry' =>array('near'=>array("geometry"=>array("type"=>"Point","coordinates"=>$longLat),'minDistance' => 1000,'maxDistance' => 5000 ) ), ));
var_dump($arr->explain());
$ arr-> explain()没有给我想要的结果。如果有人可以提供帮助,会出现什么问题。
以下是结果
array (size=15)
'cursor' => string 'BasicCursor' (length=11)
'isMultiKey' => boolean false
'n' => int 0
'nscannedObjects' => int 5
'nscanned' => int 5
'nscannedObjectsAllPlans' => int 5
'nscannedAllPlans' => int 5
'scanAndOrder' => boolean false
'indexOnly' => boolean false
'nYields' => int 0
'nChunkSkips' => int 0
'millis' => int 0
'indexBounds' =>
array (size=0)
empty
'allPlans' =>
array (size=1)
0 =>
array (size=5)
'cursor' => string 'BasicCursor' (length=11)
'n' => int 0
'nscannedObjects' => int 5
'nscanned' => int 5
'indexBounds' =>
array (size=0)
...
'server' => string 'h0043434.mongolab.com:43434' (length=26)
它返回'BasicCursor',而应该给'S2Cursor'