@@ 185-198 (lines=14) @@ | ||
182 | * |
|
183 | * @return float |
|
184 | */ |
|
185 | public function getPerimeter(DistanceInterface $calculator): float |
|
186 | { |
|
187 | $perimeter = 0.0; |
|
188 | ||
189 | if (count($this->points) < 2) { |
|
190 | return $perimeter; |
|
191 | } |
|
192 | ||
193 | foreach ($this->getSegments() as $segment) { |
|
194 | $perimeter += $segment->getLength($calculator); |
|
195 | } |
|
196 | ||
197 | return $perimeter; |
|
198 | } |
|
199 | ||
200 | /** |
|
201 | * Calculates the polygon area. |
@@ 123-136 (lines=14) @@ | ||
120 | * |
|
121 | * @return float |
|
122 | */ |
|
123 | public function getLength(DistanceInterface $calculator): float |
|
124 | { |
|
125 | $distance = 0.0; |
|
126 | ||
127 | if (count($this->points) <= 1) { |
|
128 | return $distance; |
|
129 | } |
|
130 | ||
131 | foreach ($this->getSegments() as $segment) { |
|
132 | $distance += $segment->getLength($calculator); |
|
133 | } |
|
134 | ||
135 | return $distance; |
|
136 | } |
|
137 | ||
138 | /** |
|
139 | * Create a new polyline with reversed order of points, i. e. reversed |