@@ 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. |
@@ 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 |