I want to retrieve data within the bounding box ((ra_min,dec_min),(ra_max,dec_max)). Could anyone tell me what's wrong with below?
php Code and structure of data are below. Thanks......
Structure :
{
"filter": "E",
"loc": {
"dec": 130,
"ra": 15
},
"path": "00015+00130E.jpeg"
},
{
"filter": "Z",
"loc": {
"dec": 130,
"ra": 15
},
"path": "00015+00130Z.jpeg"
},
Code :
$lowerLeft = array("ra"=>$RA_min - $ra_offset, "dec"=>$DEC_min - $dec_offset);
$upperRight= array("ra"=>$RA_max + $ra_offset, "dec"=>$DEC_max + $dec_offset);
$cond = array("loc" => array('$within' => array('$box' => $lowerLeft, $upperRight)));
$cursor = $collection->find($cond);
i Think problem is on $box Usage
$box Usage Example:
$cursor = $collection->find( array( 'loc'=>array('$within'=> array('$box'=>array(array(0,0), array(100,100) ) ) ) ));
This will return all the documents that are within the box having points at: [0,0], [0,100], [100,0], and [100,100].
use print_r($cond); before find(); for see the array value that show you where is problem