public function area($exterior_only = FALSE, $signed = FALSE) { if ($this->isEmpty()) { return 0; } if ($this->geos() && $exterior_only == FALSE) { return $this->geos()->area(); } $exterior_ring = $this->components[0]; $pts = $exterior_ring->getComponents(); $c = count($pts); if ((int) $c == '0') { return NULL; } $a = '0'; foreach ($pts as $k => $p) { $j = ($k + 1) % $c; $a = $a + $p->getX() * $pts[$j]->getY() - $p->getY() * $pts[$j]->getX(); } if ($signed) { $area = $a / 2; } else { $area = abs($a / 2); } if ($exterior_only == TRUE) { return $area; } foreach ($this->components as $delta => $component) { if ($delta != 0) { $inner_poly = new Polygon(array($component)); $area -= $inner_poly->area(); } } return $area; }