| @@ 186-199 (lines=14) @@ | ||
| 183 | * |
|
| 184 | * @return float |
|
| 185 | */ |
|
| 186 | public function getPerimeter(DistanceInterface $calculator): float |
|
| 187 | { |
|
| 188 | $perimeter = 0.0; |
|
| 189 | ||
| 190 | if (count($this->points) < 2) { |
|
| 191 | return $perimeter; |
|
| 192 | } |
|
| 193 | ||
| 194 | foreach ($this->getSegments() as $segment) { |
|
| 195 | $perimeter += $segment->getLength($calculator); |
|
| 196 | } |
|
| 197 | ||
| 198 | return $perimeter; |
|
| 199 | } |
|
| 200 | ||
| 201 | /** |
|
| 202 | * Calculates the polygon area. |
|
| @@ 85-98 (lines=14) @@ | ||
| 82 | * |
|
| 83 | * @return float |
|
| 84 | */ |
|
| 85 | public function getLength(DistanceInterface $calculator): float |
|
| 86 | { |
|
| 87 | $distance = 0.0; |
|
| 88 | ||
| 89 | if (count($this->points) <= 1) { |
|
| 90 | return $distance; |
|
| 91 | } |
|
| 92 | ||
| 93 | foreach ($this->getSegments() as $segment) { |
|
| 94 | $distance += $segment->getLength($calculator); |
|
| 95 | } |
|
| 96 | ||
| 97 | return $distance; |
|
| 98 | } |
|
| 99 | ||
| 100 | /** |
|
| 101 | * Create a new polyline with reversed order of points, i. e. reversed |
|