| @@ 171-184 (lines=14) @@ | ||
| 168 | * |
|
| 169 | * @return float |
|
| 170 | */ |
|
| 171 | public function getPerimeter(DistanceInterface $calculator) |
|
| 172 | { |
|
| 173 | $perimeter = 0.0; |
|
| 174 | ||
| 175 | if (count($this->points) < 2) { |
|
| 176 | return $perimeter; |
|
| 177 | } |
|
| 178 | ||
| 179 | foreach ($this->getSegments() as $segment) { |
|
| 180 | $perimeter += $segment->getLength($calculator); |
|
| 181 | } |
|
| 182 | ||
| 183 | return $perimeter; |
|
| 184 | } |
|
| 185 | ||
| 186 | /** |
|
| 187 | * Calculates the polygon area. |
|
| @@ 95-108 (lines=14) @@ | ||
| 92 | * |
|
| 93 | * @return float |
|
| 94 | */ |
|
| 95 | public function getLength(DistanceInterface $calculator) |
|
| 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 |
|