@@ -18,7 +18,7 @@ |
||
18 | 18 | public function __construct($components = [], $allowEmptyComponents = false, $allowedComponentType = Point::class) |
19 | 19 | { |
20 | 20 | if (is_array($components) && count($components) == 1) { |
21 | - throw new InvalidGeometryException("Cannot construct a " . static::class . " with a single point"); |
|
21 | + throw new InvalidGeometryException("Cannot construct a ".static::class." with a single point"); |
|
22 | 22 | } |
23 | 23 | parent::__construct($components, $allowEmptyComponents, $allowedComponentType); |
24 | 24 | } |
@@ -41,8 +41,8 @@ discard block |
||
41 | 41 | if ($components[$i] instanceof $allowedComponentType) { |
42 | 42 | if (!$allowEmptyComponents && $components[$i]->isEmpty()) { |
43 | 43 | throw new InvalidGeometryException( |
44 | - 'Cannot create a collection of empty ' . |
|
45 | - $components[$i]->geometryType() . 's (' . ($i + 1) . '. component)' |
|
44 | + 'Cannot create a collection of empty '. |
|
45 | + $components[$i]->geometryType().'s ('.($i+1).'. component)' |
|
46 | 46 | ); |
47 | 47 | } |
48 | 48 | if ($components[$i]->hasZ() && !$this->hasZ) { |
@@ -56,8 +56,8 @@ discard block |
||
56 | 56 | ? gettype($components[$i]) |
57 | 57 | : get_class($components[$i]); |
58 | 58 | throw new InvalidGeometryException( |
59 | - 'Cannot create a collection of ' . $componentType . |
|
60 | - ' components, expected type is ' . $allowedComponentType |
|
59 | + 'Cannot create a collection of '.$componentType. |
|
60 | + ' components, expected type is '.$allowedComponentType |
|
61 | 61 | ); |
62 | 62 | } |
63 | 63 | } |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | */ |
199 | 199 | public function geometryN($n) |
200 | 200 | { |
201 | - return isset($this->components[$n - 1]) ? $this->components[$n - 1] : null; |
|
201 | + return isset($this->components[$n-1]) ? $this->components[$n-1] : null; |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | /** |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | { |
64 | 64 | return $n >= 0 |
65 | 65 | ? $this->geometryN($n) |
66 | - : $this->geometryN(count($this->components) - abs($n + 1)); |
|
66 | + : $this->geometryN(count($this->components)-abs($n+1)); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | public function centroid() |
@@ -93,12 +93,12 @@ discard block |
||
93 | 93 | if ($previousPoint) { |
94 | 94 | // Equivalent to $previousPoint->distance($point) but much faster |
95 | 95 | $segmentLength = sqrt( |
96 | - pow(($previousPoint->x() - $point->x()), 2) + |
|
97 | - pow(($previousPoint->y() - $point->y()), 2) |
|
96 | + pow(($previousPoint->x()-$point->x()), 2)+ |
|
97 | + pow(($previousPoint->y()-$point->y()), 2) |
|
98 | 98 | ); |
99 | 99 | $length += $segmentLength; |
100 | - $x += ($previousPoint->x() + $point->x()) / 2 * $segmentLength; |
|
101 | - $y += ($previousPoint->y() + $point->y()) / 2 * $segmentLength; |
|
100 | + $x += ($previousPoint->x()+$point->x()) / 2 * $segmentLength; |
|
101 | + $y += ($previousPoint->y()+$point->y()) / 2 * $segmentLength; |
|
102 | 102 | } |
103 | 103 | $previousPoint = $point; |
104 | 104 | } |
@@ -127,8 +127,8 @@ discard block |
||
127 | 127 | foreach ($this->getPoints() as $point) { |
128 | 128 | if ($previousPoint) { |
129 | 129 | $length += sqrt( |
130 | - pow(($previousPoint->x() - $point->x()), 2) + |
|
131 | - pow(($previousPoint->y() - $point->y()), 2) |
|
130 | + pow(($previousPoint->x()-$point->x()), 2)+ |
|
131 | + pow(($previousPoint->y()-$point->y()), 2) |
|
132 | 132 | ); |
133 | 133 | } |
134 | 134 | $previousPoint = $point; |
@@ -144,9 +144,9 @@ discard block |
||
144 | 144 | foreach ($this->getPoints() as $point) { |
145 | 145 | if ($previousPoint) { |
146 | 146 | $length += sqrt( |
147 | - pow(($previousPoint->x() - $point->x()), 2) + |
|
148 | - pow(($previousPoint->y() - $point->y()), 2) + |
|
149 | - pow(($previousPoint->z() - $point->z()), 2) |
|
147 | + pow(($previousPoint->x()-$point->x()), 2)+ |
|
148 | + pow(($previousPoint->y()-$point->y()), 2)+ |
|
149 | + pow(($previousPoint->z()-$point->z()), 2) |
|
150 | 150 | ); |
151 | 151 | } |
152 | 152 | $previousPoint = $point; |
@@ -163,28 +163,28 @@ discard block |
||
163 | 163 | $length = 0.0; |
164 | 164 | $rad = M_PI / 180; |
165 | 165 | $points = $this->getPoints(); |
166 | - $numPoints = $this->numPoints() - 1; |
|
166 | + $numPoints = $this->numPoints()-1; |
|
167 | 167 | for ($i = 0; $i < $numPoints; ++$i) { |
168 | 168 | // Simplified Vincenty formula with equal major and minor axes (a sphere) |
169 | 169 | $lat1 = $points[$i]->y() * $rad; |
170 | - $lat2 = $points[$i + 1]->y() * $rad; |
|
170 | + $lat2 = $points[$i+1]->y() * $rad; |
|
171 | 171 | $lon1 = $points[$i]->x() * $rad; |
172 | - $lon2 = $points[$i + 1]->x() * $rad; |
|
173 | - $deltaLon = $lon2 - $lon1; |
|
172 | + $lon2 = $points[$i+1]->x() * $rad; |
|
173 | + $deltaLon = $lon2-$lon1; |
|
174 | 174 | $d = |
175 | 175 | $radius * |
176 | 176 | atan2( |
177 | 177 | sqrt( |
178 | - pow(cos($lat2) * sin($deltaLon), 2) + |
|
179 | - pow(cos($lat1) * sin($lat2) - sin($lat1) * cos($lat2) * cos($deltaLon), 2) |
|
178 | + pow(cos($lat2) * sin($deltaLon), 2)+ |
|
179 | + pow(cos($lat1) * sin($lat2)-sin($lat1) * cos($lat2) * cos($deltaLon), 2) |
|
180 | 180 | ), |
181 | - sin($lat1) * sin($lat2) + |
|
181 | + sin($lat1) * sin($lat2)+ |
|
182 | 182 | cos($lat1) * cos($lat2) * cos($deltaLon) |
183 | 183 | ); |
184 | 184 | if ($points[$i]->is3D()) { |
185 | 185 | $d = sqrt( |
186 | - pow($d, 2) + |
|
187 | - pow($points[$i + 1]->z() - $points[$i]->z(), 2) |
|
186 | + pow($d, 2)+ |
|
187 | + pow($points[$i+1]->z()-$points[$i]->z(), 2) |
|
188 | 188 | ); |
189 | 189 | } |
190 | 190 | |
@@ -201,15 +201,15 @@ discard block |
||
201 | 201 | { |
202 | 202 | $distance = 0.0; |
203 | 203 | $points = $this->getPoints(); |
204 | - $numPoints = $this->numPoints() - 1; |
|
204 | + $numPoints = $this->numPoints()-1; |
|
205 | 205 | for ($i = 0; $i < $numPoints; ++$i) { |
206 | 206 | $point = $points[$i]; |
207 | - $nextPoint = $points[$i + 1]; |
|
207 | + $nextPoint = $points[$i+1]; |
|
208 | 208 | $degree = (geoPHP::EARTH_WGS84_SEMI_MAJOR_AXIS * |
209 | 209 | acos( |
210 | - sin(deg2rad($point->y())) * sin(deg2rad($nextPoint->y())) + |
|
210 | + sin(deg2rad($point->y())) * sin(deg2rad($nextPoint->y()))+ |
|
211 | 211 | cos(deg2rad($point->y())) * cos(deg2rad($nextPoint->y())) * |
212 | - cos(deg2rad(abs($point->x() - $nextPoint->x()))) |
|
212 | + cos(deg2rad(abs($point->x()-$nextPoint->x()))) |
|
213 | 213 | ) |
214 | 214 | ); |
215 | 215 | if (!is_nan($degree)) { |
@@ -232,20 +232,20 @@ discard block |
||
232 | 232 | $length = 0.0; |
233 | 233 | $rad = M_PI / 180; |
234 | 234 | $points = $this->getPoints(); |
235 | - $numPoints = $this->numPoints() - 1; |
|
235 | + $numPoints = $this->numPoints()-1; |
|
236 | 236 | for ($i = 0; $i < $numPoints; ++$i) { |
237 | 237 | // Inverse Vincenty formula |
238 | 238 | $lat1 = $points[$i]->y() * $rad; |
239 | - $lat2 = $points[$i + 1]->y() * $rad; |
|
239 | + $lat2 = $points[$i+1]->y() * $rad; |
|
240 | 240 | $lng1 = $points[$i]->x() * $rad; |
241 | - $lng2 = $points[$i + 1]->x() * $rad; |
|
241 | + $lng2 = $points[$i+1]->x() * $rad; |
|
242 | 242 | |
243 | 243 | $a = geoPHP::EARTH_WGS84_SEMI_MAJOR_AXIS; |
244 | 244 | $b = geoPHP::EARTH_WGS84_SEMI_MINOR_AXIS; |
245 | 245 | $f = 1 / geoPHP::EARTH_WGS84_FLATTENING; |
246 | - $L = $lng2 - $lng1; |
|
247 | - $U1 = atan((1 - $f) * tan($lat1)); |
|
248 | - $U2 = atan((1 - $f) * tan($lat2)); |
|
246 | + $L = $lng2-$lng1; |
|
247 | + $U1 = atan((1-$f) * tan($lat1)); |
|
248 | + $U2 = atan((1-$f) * tan($lat2)); |
|
249 | 249 | $iterationLimit = 100; |
250 | 250 | $lambda = $L; |
251 | 251 | $sinU1 = sin($U1); |
@@ -257,38 +257,38 @@ discard block |
||
257 | 257 | $cosLambda = cos($lambda); |
258 | 258 | $sinSigma = sqrt( |
259 | 259 | ($cosU2 * $sinLambda) * |
260 | - ($cosU2 * $sinLambda) + |
|
261 | - ($cosU1 * $sinU2 - $sinU1 * $cosU2 * $cosLambda) * |
|
262 | - ($cosU1 * $sinU2 - $sinU1 * $cosU2 * $cosLambda) |
|
260 | + ($cosU2 * $sinLambda)+ |
|
261 | + ($cosU1 * $sinU2-$sinU1 * $cosU2 * $cosLambda) * |
|
262 | + ($cosU1 * $sinU2-$sinU1 * $cosU2 * $cosLambda) |
|
263 | 263 | ); |
264 | 264 | if ($sinSigma == 0) { |
265 | 265 | return 0.0; |
266 | 266 | } |
267 | - $cosSigma = $sinU1 * $sinU2 + $cosU1 * $cosU2 * $cosLambda; |
|
267 | + $cosSigma = $sinU1 * $sinU2+$cosU1 * $cosU2 * $cosLambda; |
|
268 | 268 | $sigma = atan2($sinSigma, $cosSigma); |
269 | 269 | $sinAlpha = $cosU1 * $cosU2 * $sinLambda / $sinSigma; |
270 | - $cosSqAlpha = 1 - $sinAlpha * $sinAlpha; |
|
270 | + $cosSqAlpha = 1-$sinAlpha * $sinAlpha; |
|
271 | 271 | $cos2SigmaM = 0; |
272 | 272 | if ($cosSqAlpha <> 0) { |
273 | - $cos2SigmaM = $cosSigma - 2 * $sinU1 * $sinU2 / $cosSqAlpha; |
|
273 | + $cos2SigmaM = $cosSigma-2 * $sinU1 * $sinU2 / $cosSqAlpha; |
|
274 | 274 | } |
275 | - $C = $f / 16 * $cosSqAlpha * (4 + $f * (4 - 3 * $cosSqAlpha)); |
|
275 | + $C = $f / 16 * $cosSqAlpha * (4+$f * (4-3 * $cosSqAlpha)); |
|
276 | 276 | $lambdaP = $lambda; |
277 | - $lambda = $L + (1 - $C) * $f * $sinAlpha * |
|
278 | - ($sigma + $C * $sinSigma * ($cos2SigmaM + $C * $cosSigma * (- 1 + 2 * $cos2SigmaM * $cos2SigmaM))); |
|
279 | - } while (abs($lambda - $lambdaP) > 1e-12 && --$iterationLimit > 0); |
|
277 | + $lambda = $L+(1-$C) * $f * $sinAlpha * |
|
278 | + ($sigma+$C * $sinSigma * ($cos2SigmaM+$C * $cosSigma * (-1+2 * $cos2SigmaM * $cos2SigmaM))); |
|
279 | + } while (abs($lambda-$lambdaP) > 1e-12 && --$iterationLimit > 0); |
|
280 | 280 | if ($iterationLimit == 0) { |
281 | 281 | return null; // not converging |
282 | 282 | } |
283 | - $uSq = $cosSqAlpha * ($a * $a - $b * $b) / ($b * $b); |
|
284 | - $A = 1 + $uSq / 16384 * (4096 + $uSq * (- 768 + $uSq * (320 - 175 * $uSq))); |
|
285 | - $B = $uSq / 1024 * (256 + $uSq * (- 128 + $uSq * (74 - 47 * $uSq))); |
|
286 | - $deltaSigma = $B * $sinSigma * ($cos2SigmaM + $B / 4 * |
|
287 | - ($cosSigma * (-1 + 2 * $cos2SigmaM * $cos2SigmaM) - $B / 6 |
|
288 | - * $cos2SigmaM * (-3 + 4 * $sinSigma * $sinSigma) |
|
289 | - * (-3 + 4 * $cos2SigmaM * $cos2SigmaM))); |
|
290 | - |
|
291 | - $length += $b * $A * ($sigma - $deltaSigma); |
|
283 | + $uSq = $cosSqAlpha * ($a * $a-$b * $b) / ($b * $b); |
|
284 | + $A = 1+$uSq / 16384 * (4096+$uSq * (-768+$uSq * (320-175 * $uSq))); |
|
285 | + $B = $uSq / 1024 * (256+$uSq * (-128+$uSq * (74-47 * $uSq))); |
|
286 | + $deltaSigma = $B * $sinSigma * ($cos2SigmaM+$B / 4 * |
|
287 | + ($cosSigma * (-1+2 * $cos2SigmaM * $cos2SigmaM)-$B / 6 |
|
288 | + * $cos2SigmaM * (-3+4 * $sinSigma * $sinSigma) |
|
289 | + * (-3+4 * $cos2SigmaM * $cos2SigmaM))); |
|
290 | + |
|
291 | + $length += $b * $A * ($sigma-$deltaSigma); |
|
292 | 292 | } |
293 | 293 | // Returns length in meters. |
294 | 294 | return $length; |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | public function zDifference() |
321 | 321 | { |
322 | 322 | if ($this->startPoint()->hasZ() && $this->endPoint()->hasZ()) { |
323 | - return abs($this->startPoint()->z() - $this->endPoint()->z()); |
|
323 | + return abs($this->startPoint()->z()-$this->endPoint()->z()); |
|
324 | 324 | } else { |
325 | 325 | return null; |
326 | 326 | } |
@@ -341,9 +341,9 @@ discard block |
||
341 | 341 | $lastEle = $this->startPoint()->z(); |
342 | 342 | $pointCount = $this->numPoints(); |
343 | 343 | foreach ($this->getPoints() as $i => $point) { |
344 | - if (abs($point->z() - $lastEle) > $verticalTolerance || $i === $pointCount - 1) { |
|
344 | + if (abs($point->z()-$lastEle) > $verticalTolerance || $i === $pointCount-1) { |
|
345 | 345 | if ($point->z() > $lastEle) { |
346 | - $gain += $point->z() - $lastEle; |
|
346 | + $gain += $point->z()-$lastEle; |
|
347 | 347 | } |
348 | 348 | $lastEle = $point->z(); |
349 | 349 | } |
@@ -366,9 +366,9 @@ discard block |
||
366 | 366 | $lastEle = $this->startPoint()->z(); |
367 | 367 | $pointCount = $this->numPoints(); |
368 | 368 | foreach ($this->getPoints() as $i => $point) { |
369 | - if (abs($point->z() - $lastEle) > $verticalTolerance || $i === $pointCount - 1) { |
|
369 | + if (abs($point->z()-$lastEle) > $verticalTolerance || $i === $pointCount-1) { |
|
370 | 370 | if ($point->z() < $lastEle) { |
371 | - $loss += $lastEle - $point->z(); |
|
371 | + $loss += $lastEle-$point->z(); |
|
372 | 372 | } |
373 | 373 | $lastEle = $point->z(); |
374 | 374 | } |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | } |
415 | 415 | $parts = []; |
416 | 416 | for ($i = 1; $i < $numPoints; ++$i) { |
417 | - $segment = [$points[$i - 1], $points[$i]]; |
|
417 | + $segment = [$points[$i-1], $points[$i]]; |
|
418 | 418 | $parts[] = $toArray ? $segment : new LineString($segment); |
419 | 419 | } |
420 | 420 | return $parts; |
@@ -58,7 +58,7 @@ |
||
58 | 58 | { |
59 | 59 | $componentCount = count($this->components); |
60 | 60 | for ($i = 0; $i < $componentCount; $i++) { |
61 | - for ($j = $i + 1; $j < $componentCount; $j++) { |
|
61 | + for ($j = $i+1; $j < $componentCount; $j++) { |
|
62 | 62 | if ($this->components[$i]->equals($this->components[$j])) { |
63 | 63 | return false; |
64 | 64 | } |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | public function envelope() |
334 | 334 | { |
335 | 335 | if ($this->isEmpty()) { |
336 | - $type = geoPHP::CLASS_NAMESPACE . 'Geometry\\' . $this->geometryType(); |
|
336 | + $type = geoPHP::CLASS_NAMESPACE.'Geometry\\'.$this->geometryType(); |
|
337 | 337 | return new $type(); |
338 | 338 | } |
339 | 339 | if ($this->geometryType() === Geometry::POINT) { |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | $format = str_replace('xdr', '', $format); |
373 | 373 | } |
374 | 374 | |
375 | - $processorType = geoPHP::CLASS_NAMESPACE . 'Adapter\\' . geoPHP::getAdapterMap()[$format]; |
|
375 | + $processorType = geoPHP::CLASS_NAMESPACE.'Adapter\\'.geoPHP::getAdapterMap()[$format]; |
|
376 | 376 | $processor = new $processorType(); |
377 | 377 | array_unshift($args, $this); |
378 | 378 | |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | |
385 | 385 | public function coordinateDimension() |
386 | 386 | { |
387 | - return 2 + ($this->hasZ() ? 1 : 0) + ($this->isMeasured() ? 1 : 0); |
|
387 | + return 2+($this->hasZ() ? 1 : 0)+($this->isMeasured() ? 1 : 0); |
|
388 | 388 | } |
389 | 389 | |
390 | 390 | /** |
@@ -407,20 +407,20 @@ discard block |
||
407 | 407 | $p3x = $segment2End->x(); |
408 | 408 | $p3y = $segment2End->y(); |
409 | 409 | |
410 | - $s1x = $p1x - $p0x; |
|
411 | - $s1y = $p1y - $p0y; |
|
412 | - $s2x = $p3x - $p2x; |
|
413 | - $s2y = $p3y - $p2y; |
|
410 | + $s1x = $p1x-$p0x; |
|
411 | + $s1y = $p1y-$p0y; |
|
412 | + $s2x = $p3x-$p2x; |
|
413 | + $s2y = $p3y-$p2y; |
|
414 | 414 | |
415 | - $fps = (-$s2x * $s1y) + ($s1x * $s2y); |
|
416 | - $fpt = (-$s2x * $s1y) + ($s1x * $s2y); |
|
415 | + $fps = (-$s2x * $s1y)+($s1x * $s2y); |
|
416 | + $fpt = (-$s2x * $s1y)+($s1x * $s2y); |
|
417 | 417 | |
418 | 418 | if ($fps == 0 || $fpt == 0) { |
419 | 419 | return false; |
420 | 420 | } |
421 | 421 | |
422 | - $s = (-$s1y * ($p0x - $p2x) + $s1x * ($p0y - $p2y)) / $fps; |
|
423 | - $t = ($s2x * ($p0y - $p2y) - $s2y * ($p0x - $p2x)) / $fpt; |
|
422 | + $s = (-$s1y * ($p0x-$p2x)+$s1x * ($p0y-$p2y)) / $fps; |
|
423 | + $t = ($s2x * ($p0y-$p2y)-$s2y * ($p0x-$p2x)) / $fpt; |
|
424 | 424 | |
425 | 425 | // Return true if collision is detected |
426 | 426 | return ($s > 0 && $s < 1 && $t > 0 && $t < 1); |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | public function equals($geometry) |
231 | 231 | { |
232 | 232 | return $geometry->geometryType() === Geometry::POINT |
233 | - ? (abs($this->x() - $geometry->x()) <= 1.0E-9 && abs($this->y() - $geometry->y()) <= 1.0E-9) |
|
233 | + ? (abs($this->x()-$geometry->x()) <= 1.0E-9 && abs($this->y()-$geometry->y()) <= 1.0E-9) |
|
234 | 234 | : false; |
235 | 235 | } |
236 | 236 | |
@@ -265,8 +265,8 @@ discard block |
||
265 | 265 | } |
266 | 266 | if ($geometry->geometryType() == Geometry::POINT) { |
267 | 267 | return sqrt( |
268 | - pow(($this->x() - $geometry->x()), 2) |
|
269 | - + pow(($this->y() - $geometry->y()), 2) |
|
268 | + pow(($this->x()-$geometry->x()), 2) |
|
269 | + + pow(($this->y()-$geometry->y()), 2) |
|
270 | 270 | ); |
271 | 271 | } |
272 | 272 | if ($geometry instanceof MultiGeometry) { |
@@ -296,27 +296,27 @@ discard block |
||
296 | 296 | $y1 = $seg[0]->y(); |
297 | 297 | $x2 = $seg[1]->x(); |
298 | 298 | $y2 = $seg[1]->y(); |
299 | - $px = $x2 - $x1; |
|
300 | - $py = $y2 - $y1; |
|
301 | - $d = ($px * $px) + ($py * $py); |
|
299 | + $px = $x2-$x1; |
|
300 | + $py = $y2-$y1; |
|
301 | + $d = ($px * $px)+($py * $py); |
|
302 | 302 | if ($d == 0) { |
303 | 303 | // Line-segment's endpoints are identical. This is merely a point masquerading as a line-segment. |
304 | 304 | $checkDistance = $this->distance($seg[1]); |
305 | 305 | } else { |
306 | 306 | $x3 = $this->x(); |
307 | 307 | $y3 = $this->y(); |
308 | - $u = ((($x3 - $x1) * $px) + (($y3 - $y1) * $py)) / $d; |
|
308 | + $u = ((($x3-$x1) * $px)+(($y3-$y1) * $py)) / $d; |
|
309 | 309 | if ($u > 1) { |
310 | 310 | $u = 1; |
311 | 311 | } |
312 | 312 | if ($u < 0) { |
313 | 313 | $u = 0; |
314 | 314 | } |
315 | - $x = $x1 + ($u * $px); |
|
316 | - $y = $y1 + ($u * $py); |
|
317 | - $dx = $x - $x3; |
|
318 | - $dy = $y - $y3; |
|
319 | - $checkDistance = sqrt(($dx * $dx) + ($dy * $dy)); |
|
315 | + $x = $x1+($u * $px); |
|
316 | + $y = $y1+($u * $py); |
|
317 | + $dx = $x-$x3; |
|
318 | + $dy = $y-$y3; |
|
319 | + $checkDistance = sqrt(($dx * $dx)+($dy * $dy)); |
|
320 | 320 | } |
321 | 321 | if ($checkDistance === 0.0) { |
322 | 322 | return 0.0; |
@@ -151,7 +151,7 @@ |
||
151 | 151 | $startPoint = $this->startPoint(); |
152 | 152 | $endPoint = $this->endPoint(); |
153 | 153 | if ($startPoint && $endPoint && $startPoint->hasZ() && $endPoint->hasZ()) { |
154 | - return abs($startPoint->z() - $endPoint->z()); |
|
154 | + return abs($startPoint->z()-$endPoint->z()); |
|
155 | 155 | } else { |
156 | 156 | return null; |
157 | 157 | } |
@@ -28,8 +28,8 @@ discard block |
||
28 | 28 | foreach ($this->getComponents() as $i => $component) { |
29 | 29 | if ($component->numPoints() < 4) { |
30 | 30 | throw new InvalidGeometryException( |
31 | - 'Cannot create Polygon: Invalid number of points in LinearRing. Found ' . |
|
32 | - $component->numPoints() . ', expected more than 3' |
|
31 | + 'Cannot create Polygon: Invalid number of points in LinearRing. Found '. |
|
32 | + $component->numPoints().', expected more than 3' |
|
33 | 33 | ); |
34 | 34 | } |
35 | 35 | if (!$component->isClosed()) { |
@@ -40,8 +40,8 @@ discard block |
||
40 | 40 | } else { |
41 | 41 | throw new InvalidGeometryException( |
42 | 42 | 'Cannot create Polygon: contains non-closed ring (first point: ' |
43 | - . implode(' ', $component->startPoint()->asArray()) . ', last point: ' |
|
44 | - . implode(' ', $component->endPoint()->asArray()) . ')' |
|
43 | + . implode(' ', $component->startPoint()->asArray()).', last point: ' |
|
44 | + . implode(' ', $component->endPoint()->asArray()).')' |
|
45 | 45 | ); |
46 | 46 | } |
47 | 47 | } |
@@ -90,8 +90,8 @@ discard block |
||
90 | 90 | } |
91 | 91 | $a = 0.0; |
92 | 92 | foreach ($points as $k => $p) { |
93 | - $j = ($k + 1) % $pointCount; |
|
94 | - $a = $a + ($p->x() * $points[$j]->y()) - ($p->y() * $points[$j]->x()); |
|
93 | + $j = ($k+1) % $pointCount; |
|
94 | + $a = $a+($p->x() * $points[$j]->y())-($p->y() * $points[$j]->x()); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | $area = $signed ? ($a / 2) : abs(($a / 2)); |
@@ -161,10 +161,10 @@ discard block |
||
161 | 161 | $x = 0; |
162 | 162 | $y = 0; |
163 | 163 | foreach ($points as $k => $point) { |
164 | - $j = ($k + 1) % $pointCount; |
|
165 | - $P = ($point->x() * $points[$j]->y()) - ($point->y() * $points[$j]->x()); |
|
166 | - $x += ($point->x() + $points[$j]->x()) * $P; |
|
167 | - $y += ($point->y() + $points[$j]->y()) * $P; |
|
164 | + $j = ($k+1) % $pointCount; |
|
165 | + $P = ($point->x() * $points[$j]->y())-($point->y() * $points[$j]->x()); |
|
166 | + $x += ($point->x()+$points[$j]->x()) * $P; |
|
167 | + $y += ($point->y()+$points[$j]->y()) * $P; |
|
168 | 168 | } |
169 | 169 | return ['area' => abs($area), 'x' => $x / (6 * $area), 'y' => $y / (6 * $area)]; |
170 | 170 | } |
@@ -212,12 +212,12 @@ discard block |
||
212 | 212 | if ($this->isEmpty()) { |
213 | 213 | return 0; |
214 | 214 | } |
215 | - return $this->numGeometries() - 1; |
|
215 | + return $this->numGeometries()-1; |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | public function interiorRingN($n) |
219 | 219 | { |
220 | - return $this->geometryN($n + 1); |
|
220 | + return $this->geometryN($n+1); |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | public function isSimple() |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | $intersections = 0; |
269 | 269 | $verticesCount = count($vertices); |
270 | 270 | for ($i = 1; $i < $verticesCount; $i++) { |
271 | - $vertex1 = $vertices[$i - 1]; |
|
271 | + $vertex1 = $vertices[$i-1]; |
|
272 | 272 | $vertex2 = $vertices[$i]; |
273 | 273 | if ( |
274 | 274 | $vertex1->y() == $vertex2->y() |
@@ -286,8 +286,8 @@ discard block |
||
286 | 286 | && $vertex1->y() != $vertex2->y() |
287 | 287 | ) { |
288 | 288 | $xinters = |
289 | - ($point->y() - $vertex1->y()) * ($vertex2->x() - $vertex1->x()) |
|
290 | - / ($vertex2->y() - $vertex1->y()) |
|
289 | + ($point->y()-$vertex1->y()) * ($vertex2->x()-$vertex1->x()) |
|
290 | + / ($vertex2->y()-$vertex1->y()) |
|
291 | 291 | + $vertex1->x(); |
292 | 292 | if ($xinters == $point->x()) { |
293 | 293 | // Check if point is on the polygon boundary (other than horizontal) |
@@ -17,7 +17,7 @@ |
||
17 | 17 | */ |
18 | 18 | public function __construct($method, $code = 0, $message = null) |
19 | 19 | { |
20 | - $message = 'The method ' . $method . '() is not supported yet.' . ($message ? ' ' . $message : ''); |
|
20 | + $message = 'The method '.$method.'() is not supported yet.'.($message ? ' '.$message : ''); |
|
21 | 21 | parent::__construct($message, $code); |
22 | 22 | } |
23 | 23 |