Doctrine\MongoDB\Query\Expr::geoWithinBox PHP Method

geoWithinBox() public method

A rectangular polygon will be constructed from a pair of coordinates corresponding to the bottom left and top right corners. Note: the $box operator only supports legacy coordinate pairs and 2d indexes. This cannot be used with 2dsphere indexes and GeoJSON shapes.
See also: Builder::geoWithinBox()
See also: http://docs.mongodb.org/manual/reference/operator/box/
public geoWithinBox ( float $x1, float $y1, float $x2, float $y2 )
$x1 float
$y1 float
$x2 float
$y2 float
    public function geoWithinBox($x1, $y1, $x2, $y2)
    {
        $shape = ['$box' => [[$x1, $y1], [$x2, $y2]]];
        return $this->operator('$geoWithin', $shape);
    }

Usage Example

コード例 #1
0
ファイル: Builder.php プロジェクト: Wizkunde/mongodb
 /**
  * Add $geoWithin criteria with a $box shape to the query.
  *
  * A rectangular polygon will be constructed from a pair of coordinates
  * corresponding to the bottom left and top right corners.
  *
  * Note: the $box operator only supports legacy coordinate pairs and 2d
  * indexes. This cannot be used with 2dsphere indexes and GeoJSON shapes.
  *
  * @see Expr::geoWithinBox()
  * @see http://docs.mongodb.org/manual/reference/operator/box/
  * @param float $x1
  * @param float $y1
  * @param float $x2
  * @param float $y2
  * @return self
  */
 public function geoWithinBox($x1, $y1, $x2, $y2)
 {
     $this->expr->geoWithinBox($x1, $y1, $x2, $y2);
     return $this;
 }