Location\Polygon::getArea PHP Method

getArea() public method

Calculates the polygon area.
public getArea ( ) : float
return float
    public function getArea()
    {
        $area = 0.0;
        $numberOfPoints = $this->getNumberOfPoints();
        if ($numberOfPoints < 2) {
            return $area;
        }
        foreach ($this->points as $key => $point) {
            $j = ($key + 1) % $numberOfPoints;
            $area += $this->points[$j]->getLng() * $point->getLat() - $point->getLng() * $this->points[$j]->getLat();
        }
        return abs($area / 2) * $this->points[0]->getEllipsoid()->getA();
    }