@@ -79,16 +79,16 @@ discard block |
||
79 | 79 | $y = 0; |
80 | 80 | $length = 0.0; |
81 | 81 | $points = $this->getPoints(); |
82 | - $numPoints = count($points)-1; |
|
83 | - for ($i=0; $i<$numPoints; ++$i) { |
|
82 | + $numPoints = count($points) - 1; |
|
83 | + for ($i = 0; $i < $numPoints; ++$i) { |
|
84 | 84 | $currX = $points[$i]->getX(); |
85 | 85 | $currY = $points[$i]->getY(); |
86 | - $nextX = $points[$i+1]->getX(); |
|
87 | - $nextY = $points[$i+1]->getY(); |
|
86 | + $nextX = $points[$i + 1]->getX(); |
|
87 | + $nextY = $points[$i + 1]->getY(); |
|
88 | 88 | |
89 | 89 | $dx = $nextX - $currX; |
90 | 90 | $dy = $nextY - $currY; |
91 | - $segmentLength = sqrt($dx*$dx + $dy*$dy); |
|
91 | + $segmentLength = sqrt($dx * $dx + $dy * $dy); |
|
92 | 92 | $length += $segmentLength; |
93 | 93 | $x += ($currX + $nextX) / 2 * $segmentLength; |
94 | 94 | $y += ($currY + $nextY) / 2 * $segmentLength; |
@@ -114,11 +114,11 @@ discard block |
||
114 | 114 | |
115 | 115 | $length = 0.0; |
116 | 116 | $points = $this->getPoints(); |
117 | - $numPoints = count($points)-1; |
|
118 | - for ($i=0; $i<$numPoints; ++$i) { |
|
117 | + $numPoints = count($points) - 1; |
|
118 | + for ($i = 0; $i < $numPoints; ++$i) { |
|
119 | 119 | $length += sqrt( |
120 | - pow(($points[$i]->getX() - $points[$i+1]->getX()), 2) + |
|
121 | - pow(($points[$i]->getY() - $points[$i+1]->getY()), 2) |
|
120 | + pow(($points[$i]->getX() - $points[$i + 1]->getX()), 2) + |
|
121 | + pow(($points[$i]->getY() - $points[$i + 1]->getY()), 2) |
|
122 | 122 | ); |
123 | 123 | } |
124 | 124 | |
@@ -270,14 +270,14 @@ discard block |
||
270 | 270 | $C = $f / 16 * $cosSqAlpha * (4 + $f * (4 - 3 * $cosSqAlpha)); |
271 | 271 | $lambdaP = $lambda; |
272 | 272 | $lambda = $L + (1 - $C) * $f * $sinAlpha * |
273 | - ($sigma + $C * $sinSigma * ($cos2SigmaM + $C * $cosSigma * (- 1 + 2 * $cos2SigmaM * $cos2SigmaM))); |
|
273 | + ($sigma + $C * $sinSigma * ($cos2SigmaM + $C * $cosSigma * (-1 + 2 * $cos2SigmaM * $cos2SigmaM))); |
|
274 | 274 | } while (abs($lambda - $lambdaP) > 1e-12 && --$iterationLimit > 0); |
275 | 275 | if ($iterationLimit == 0) { |
276 | 276 | return 0.0; // not converging |
277 | 277 | } |
278 | 278 | $uSq = $cosSqAlpha * ($a * $a - $b * $b) / ($b * $b); |
279 | - $A = 1 + $uSq / 16384 * (4096 + $uSq * (- 768 + $uSq * (320 - 175 * $uSq))); |
|
280 | - $B = $uSq / 1024 * (256 + $uSq * (- 128 + $uSq * (74 - 47 * $uSq))); |
|
279 | + $A = 1 + $uSq / 16384 * (4096 + $uSq * (-768 + $uSq * (320 - 175 * $uSq))); |
|
280 | + $B = $uSq / 1024 * (256 + $uSq * (-128 + $uSq * (74 - 47 * $uSq))); |
|
281 | 281 | $deltaSigma = $B * $sinSigma * ($cos2SigmaM + $B / 4 * |
282 | 282 | ($cosSigma * (-1 + 2 * $cos2SigmaM * $cos2SigmaM) - $B / 6 |
283 | 283 | * $cos2SigmaM * (-3 + 4 * $sinSigma * $sinSigma) |
@@ -51,8 +51,7 @@ |
||
51 | 51 | } |
52 | 52 | } else { |
53 | 53 | $componentType = gettype($components[$i]) !== 'object' ? |
54 | - gettype($components[$i]) : |
|
55 | - get_class($components[$i]); |
|
54 | + gettype($components[$i]) : get_class($components[$i]); |
|
56 | 55 | |
57 | 56 | throw new InvalidGeometryException( |
58 | 57 | 'Cannot create a collection of ' . $componentType . ' components, ' . |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | public function read(string $gpx, array $allowedElements = []): Geometry |
68 | 68 | { |
69 | 69 | // Converts XML tags to lower-case (DOMDocument functions are case sensitive) |
70 | - $gpx = preg_replace_callback("/(<\/?\w+)(.*?>)/", function ($m) { |
|
70 | + $gpx = preg_replace_callback("/(<\/?\w+)(.*?>)/", function($m) { |
|
71 | 71 | return strtolower($m[1]) . $m[2]; |
72 | 72 | }, $gpx); |
73 | 73 | |
@@ -217,14 +217,13 @@ discard block |
||
217 | 217 | $points[] = $this->parsePoint($trkpt); |
218 | 218 | } |
219 | 219 | // Avoids creating invalid LineString |
220 | - if (count($points)>1) { |
|
220 | + if (count($points) > 1) { |
|
221 | 221 | $segments[] = new LineString($points); |
222 | 222 | } |
223 | 223 | } |
224 | 224 | if (!empty($segments)) { |
225 | 225 | $track = count($segments) === 1 ? |
226 | - $segments[0] : |
|
227 | - new MultiLineString($segments); |
|
226 | + $segments[0] : new MultiLineString($segments); |
|
228 | 227 | $track->setData($this->parseNodeProperties($trk, $this->gpxTypes->get('trkType'))); |
229 | 228 | $track->setData('gpxType', 'track'); |
230 | 229 | $tracks[] = $track; |
@@ -440,7 +439,7 @@ discard block |
||
440 | 439 | { |
441 | 440 | $metadata = self::processGeometryData($geometry, $this->gpxTypes->get('metadataType')); |
442 | 441 | $metadata = empty($metadata) || !in_array('metadataType', $this->gpxTypes->get('gpxType')) ? |
443 | - '' : "<metadata>\n" . $metadata. "</metadata>\n\n"; |
|
442 | + '' : "<metadata>\n" . $metadata . "</metadata>\n\n"; |
|
444 | 443 | $wayPoints = $routes = $tracks = ""; |
445 | 444 | |
446 | 445 | foreach ($geometry->getComponents() as $component) { |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | * MULTIPOINT (1 2, 3 4) |
199 | 199 | */ |
200 | 200 | foreach (explode(',', $dataString) as $part) { |
201 | - $points[] = $this->parsePoint(trim($part, ' ()')); |
|
201 | + $points[] = $this->parsePoint(trim($part, ' ()')); |
|
202 | 202 | } |
203 | 203 | return new MultiPoint($points); |
204 | 204 | } |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | $m = []; |
219 | 219 | if (preg_match_all('/(\([^(]+?\)|EMPTY)/', $dataString, $m)) { |
220 | 220 | foreach ($m[1] as $part) { |
221 | - $lines[] = $this->parseLineString(trim($part, ' ()')); |
|
221 | + $lines[] = $this->parseLineString(trim($part, ' ()')); |
|
222 | 222 | } |
223 | 223 | } |
224 | 224 | return new MultiLineString($lines); |
@@ -548,7 +548,7 @@ |
||
548 | 548 | if (isset($errContext['http_response_header'])) { |
549 | 549 | foreach ($errContext['http_response_header'] as $line) { |
550 | 550 | if (strpos($line, 'Error: ') > -1) { |
551 | - throw new \Exception($line); |
|
551 | + throw new \Exception($line); |
|
552 | 552 | } |
553 | 553 | } |
554 | 554 | } |
@@ -544,7 +544,7 @@ |
||
544 | 544 | { |
545 | 545 | /** @noinspection PhpUnusedParameterInspection */ |
546 | 546 | set_error_handler( |
547 | - function ($errNO, $errStr, $errFile, $errLine, $errContext) { |
|
547 | + function($errNO, $errStr, $errFile, $errLine, $errContext) { |
|
548 | 548 | if (isset($errContext['http_response_header'])) { |
549 | 549 | foreach ($errContext['http_response_header'] as $line) { |
550 | 550 | if (strpos($line, 'Error: ') > -1) { |
@@ -189,8 +189,7 @@ |
||
189 | 189 | return new Point($coordinates[0], $coordinates[1]); |
190 | 190 | case 3: |
191 | 191 | return $this->hasZ ? |
192 | - new Point($coordinates[0], $coordinates[1], $coordinates[2]) : |
|
193 | - new Point($coordinates[0], $coordinates[1], null, $coordinates[2]); |
|
192 | + new Point($coordinates[0], $coordinates[1], $coordinates[2]) : new Point($coordinates[0], $coordinates[1], null, $coordinates[2]); |
|
194 | 193 | case 4: |
195 | 194 | return new Point($coordinates[0], $coordinates[1], $coordinates[2], $coordinates[3]); |
196 | 195 | } |
@@ -112,8 +112,7 @@ |
||
112 | 112 | |
113 | 113 | // The document does not have a placemark, try to create a valid geometry from the root element |
114 | 114 | $nodeName = $this->xmlObject->documentElement->nodeName === 'multigeometry' ? |
115 | - 'geometrycollection' : |
|
116 | - $this->xmlObject->documentElement->nodeName; |
|
115 | + 'geometrycollection' : $this->xmlObject->documentElement->nodeName; |
|
117 | 116 | |
118 | 117 | if (array_key_exists($nodeName, geoPHP::getGeometryList())) { |
119 | 118 | $function = 'parse' . geoPHP::getGeometryList()[$nodeName]; |
@@ -299,7 +299,7 @@ |
||
299 | 299 | return false; |
300 | 300 | } |
301 | 301 | /** @var string $wkt */ |
302 | - $wkt = str_ireplace(['LINESTRING(',')'], '', $ring->asText()); |
|
302 | + $wkt = str_ireplace(['LINESTRING(', ')'], '', $ring->asText()); |
|
303 | 303 | $pts = array_unique(array_map('trim', explode(',', $wkt))); |
304 | 304 | if (count($pts) < 3) { |
305 | 305 | return false; |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | } |
378 | 378 | |
379 | 379 | // First char is a tab, space or carriage-return. trim it and try again |
380 | - if (in_array($bytes[1], [9,10,32], true)) { |
|
380 | + if (in_array($bytes[1], [9, 10, 32], true)) { |
|
381 | 381 | $input = ltrim($input); |
382 | 382 | return geoPHP::detectFormat($input); |
383 | 383 | } |
@@ -445,7 +445,7 @@ discard block |
||
445 | 445 | |
446 | 446 | // We need an 8 byte string for geohash and unpacked WKB / WKT |
447 | 447 | fseek($mem, 0); |
448 | - $string = trim((string)fread($mem, 8)); |
|
448 | + $string = trim((string) fread($mem, 8)); |
|
449 | 449 | |
450 | 450 | // Detect geohash - geohash ONLY contains lowercase chars and numerics |
451 | 451 | $matches = []; |