/** * Return a rectangle that contains all points whose latitude distance from * this rectangle is at most margin.lat(), and whose longitude distance from * this rectangle is at most margin.lng(). In particular, latitudes are * clamped while longitudes are wrapped. Note that any expansion of an empty * interval remains empty, and both components of the given margin must be * non-negative. * * NOTE: If you are trying to grow a rectangle by a certain *distance* on the * sphere (e.g. 5km), use the ConvolveWithCap() method instead. * @return S2LatLngRect */ public function expanded(S2LatLng $margin) { // assert (margin.lat().radians() >= 0 && margin.lng().radians() >= 0); if ($this->isEmpty()) { return $this; } return new S2LatLngRect($this->lat->expanded($margin->lat()->radians())->intersection($this->fullLat()), $this->lng->expanded($margin->lng()->radians())); }