public function testGetFirstEccentricitySquared() { $referenceEllipsoidObject = new ReferenceEllipsoid(ReferenceEllipsoid::MODIFIED_AIRY); $firstEccentricitySquared = $referenceEllipsoidObject->getFirstEccentricitySquared(); $this->assertEquals(0.0066705399999854, $firstEccentricitySquared, '', 1.0E-7); $referenceEllipsoidObject->setEllipsoid(ReferenceEllipsoid::WGS_1984); $firstEccentricitySquared = $referenceEllipsoidObject->getFirstEccentricitySquared(); $this->assertEquals(0.0066943799901413, $firstEccentricitySquared, '', 1.0E-7); }
/** * Get the Area of this region * * The algorithm used here is derived from the algorithm used by the GRASS GIS package * * @param ReferenceEllipsoid|null $ellipsoid Reference Ellipsoid to use for this calculation * If null, then the WGS 1984 Ellipsoid will be used * @return Area The area of this region */ public function getArea(ReferenceEllipsoid $ellipsoid = null) { $pointCount = count($this->nodePoints); if ($pointCount == 0) { return new Area(); } elseif (is_null($ellipsoid)) { $ellipsoid = new ReferenceEllipsoid(ReferenceEllipsoid::WGS_1984); } $semiMajorAxis = $ellipsoid->getSemiMajorAxis(); $eccentricitySquared = $ellipsoid->getFirstEccentricitySquared(); $eccentricity4 = $eccentricitySquared * $eccentricitySquared; $eccentricity6 = $eccentricity4 * $eccentricitySquared; $AE = $semiMajorAxis * $semiMajorAxis * (1 - $eccentricitySquared); $this->QA = 2.0 / 3.0 * $eccentricitySquared; $this->QB = 3.0 / 5.0 * $eccentricity4; $this->QC = 4.0 / 7.0 * $eccentricity6; $this->QbarA = -1.0 - 2.0 / 3.0 * $eccentricitySquared - 3.0 / 5.0 * $eccentricity4 - 4.0 / 7.0 * $eccentricity6; $this->QbarB = 2.0 / 9.0 * $eccentricitySquared + 2.0 / 5.0 * $eccentricity4 + 4.0 / 7.0 * $eccentricity6; $this->QbarC = -(3.0 / 25.0) * $eccentricity4 - 12.0 / 35.0 * $eccentricity6; $this->QbarD = 4.0 / 49.0 * $eccentricity6; $Qp = $this->_Q(M_PI_2); $pointCount--; $longitude2 = $this->nodePoints[$pointCount]->getLongitude()->getValue(Angle::RADIANS); $latitude2 = $this->nodePoints[$pointCount]->getLatitude()->getValue(Angle::RADIANS); $Qbar2 = $this->_Qbar($latitude2); $area = 0.0; $n = 0; while ($n++ < $pointCount) { $longitude1 = $longitude2; $latitude1 = $latitude2; $Qbar1 = $Qbar2; $longitude2 = $this->nodePoints[$n]->getLongitude()->getValue(Angle::RADIANS); $latitude2 = $this->nodePoints[$n]->getLatitude()->getValue(Angle::RADIANS); $Qbar2 = $this->_Qbar($latitude2); self::datelineAdjust($longitude1, $longitude2); $deltaLongitude = $longitude2 - $longitude1; $area += $deltaLongitude * ($Qp - $this->_Q($latitude2)); if (($deltaLatitude = $latitude2 - $latitude1) != 0.0) { $area += $deltaLongitude * $this->_Q($latitude2) - $deltaLongitude / $deltaLatitude * ($Qbar2 - $Qbar1); } } $area = self::polarAdjust($area, $AE, $Qp); return new Area($area); }