Code Coverage Classes and Traits Functions and Methods Lines Total 0.00% covered (danger) 0.00% 0 / 1 33.33% covered (danger) 33.33% 2 / 6 CRAP 55.56% covered (warning) 55.56% 10 / 18 BoundingBox 0.00% covered (danger) 0.00% 0 / 1 33.33% covered (danger) 33.33% 2 / 6 13.62 55.56% covered (warning) 55.56% 10 / 18 __construct 100.00% covered (success) 100.00% 1 / 1 1 100.00% covered (success) 100.00% 6 / 6 newFromPoints 0.00% covered (danger) 0.00% 0 / 1 2 0.00% covered (danger) 0.00% 0 / 2 topLeft 0.00% covered (danger) 0.00% 0 / 1 2 0.00% covered (danger) 0.00% 0 / 1 bottomRight 0.00% covered (danger) 0.00% 0 / 1 2 0.00% covered (danger) 0.00% 0 / 1 area 0.00% covered (danger) 0.00% 0 / 1 2 0.00% covered (danger) 0.00% 0 / 4 center 100.00% covered (success) 100.00% 1 / 1 3 100.00% covered (success) 100.00% 4 / 4
 lat1 = \$lat1; \$this->lon1 = \$lon1; \$this->lat2 = \$lat2; \$this->lon2 = \$lon2; \$this->globe = \$globe; } /** * Constructs a bounding box from 2 corner coordinates * * @param Coord \$topLeft * @param Coord \$bottomRight * @return self */ public static function newFromPoints( Coord \$topLeft, Coord \$bottomRight ): self { return new self( \$topLeft->lat, \$topLeft->lon, \$bottomRight->lat, \$bottomRight->lon, \$topLeft->globe ); } /** * @return Coord Top left corner of this bounding box */ public function topLeft(): Coord { return new Coord( \$this->lat1, \$this->lon1, \$this->globe ); } /** * @return Coord Bottom right corner of this bounding box */ public function bottomRight(): Coord { return new Coord( \$this->lat2, \$this->lon2, \$this->globe ); } /** * Computes a (very approximate) area of this bounding box * * @return float */ public function area() { \$midLat = ( \$this->lat2 + \$this->lat1 ) / 2; \$vert = Math::distance( \$this->lat1, 0, \$this->lat2, 0 ); \$horz = Math::distance( \$midLat, \$this->lon1, \$midLat, \$this->lon2 ); return \$horz * \$vert; } /** * Returns center of this bounding box * * @return Coord */ public function center(): Coord { \$lon = ( \$this->lon2 + \$this->lon1 ) / 2.0; if ( \$this->lon1 > \$this->lon2 ) { // Wrap around \$lon += ( \$lon < 0 ) ? 180 : -180; } return new Coord( ( \$this->lat1 + \$this->lat2 ) / 2.0, \$lon ); } }