| @@ 95-108 (lines=14) @@ | ||
| 92 | * |
|
| 93 | * @return float |
|
| 94 | */ |
|
| 95 | public function getLength(DistanceInterface $calculator): float |
|
| 96 | { |
|
| 97 | $distance = 0.0; |
|
| 98 | ||
| 99 | if (count($this->points) <= 1) { |
|
| 100 | return $distance; |
|
| 101 | } |
|
| 102 | ||
| 103 | foreach ($this->getSegments() as $segment) { |
|
| 104 | $distance += $segment->getLength($calculator); |
|
| 105 | } |
|
| 106 | ||
| 107 | return $distance; |
|
| 108 | } |
|
| 109 | ||
| 110 | /** |
|
| 111 | * Create a new polyline with reversed order of points, i. e. reversed |
|
| @@ 198-211 (lines=14) @@ | ||
| 195 | * |
|
| 196 | * @return float |
|
| 197 | */ |
|
| 198 | public function getPerimeter(DistanceInterface $calculator): float |
|
| 199 | { |
|
| 200 | $perimeter = 0.0; |
|
| 201 | ||
| 202 | if (count($this->points) < 2) { |
|
| 203 | return $perimeter; |
|
| 204 | } |
|
| 205 | ||
| 206 | foreach ($this->getSegments() as $segment) { |
|
| 207 | $perimeter += $segment->getLength($calculator); |
|
| 208 | } |
|
| 209 | ||
| 210 | return $perimeter; |
|
| 211 | } |
|
| 212 | ||
| 213 | /** |
|
| 214 | * Calculates the polygon area. |
|