Mongo php Can't canonicalize query: BadValue bad geo query

446 views
Skip to first unread message

Dan Urban

unread,
May 9, 2014, 4:49:55 PM5/9/14
to node-mong...@googlegroups.com
We are working on a new Mongo DB Project and getting stumped running first query

The Error we are getting is 

Fatal error: Uncaught exception 'MongoCursorException' with message 'someserver.com:27017: Can't canonicalize query: BadValue bad geo query' in /var/www/html/one-call/lib/somefile.php:97

Here is our query:

$mongo = new MongoClient("mongodb://someserver.com:27017");
    $marks = $mongo->selectDB('atlantic');
        $q = array('bounds' => array(
          '$geoWithin' => array(
              '$geometry' => array(
                  'type' => 'Polygon',
            'coordinates' => array(array(
                    array(40.125246,-74.327963),
                    array(40.125246,-74.325989),
                    array(40.123738,-74.325989),
                    array(40.123738,-74.327963),
                    array(40.125246,-74.327963)
            ))
              )
          )
       )
    );
$marks = new MongoCollection($marks,'Analyzer_Marks');
    $marks = $marks->find($q);
    //var_dump($marks);
    $results = array();
    if(!empty($marks)){

        foreach($marks as $mark) {
            $results[] = array(
                "location" => $mark['location'],
                "tile" => $mark['tile'],
                "status" => $mark['status']
            );
        }
    }
Reply all
Reply to author
Forward
0 new messages