public function addNearCondition($field, GeoPoint $point, $booleanOperator = 'AND') { if ($point->hasAllDistances()) { $prepared = ['$near' => ['$geometry' => ['type' => 'Point', 'coordinates' => [$point->getLatitude(), $point->getLongitude()]]], '$minDistance' => $point->getMinDistance(), '$maxDistance' => $point->getMaxDistance()]; } else { if ($point->hasMaxDistance()) { $prepared = ['$near' => ['$geometry' => ['type' => 'Point', 'coordinates' => [$point->getLatitude(), $point->getLongitude()]]], '$maxDistance' => $point->getMaxDistance()]; } else { if ($point->hasMinDistance()) { $prepared = ['$near' => ['$geometry' => ['type' => 'Point', 'coordinates' => [$point->getLatitude(), $point->getLongitude()]]], '$minDistance' => $point->getMinDistance()]; } else { $prepared = ['$near' => ['$geometry' => ['type' => 'Point', 'coordinates' => [$point->getLatitude(), $point->getLongitude()]]]]; } } } $this->addRawCondition($field, $prepared, $booleanOperator); }