@@ -101,7 +101,7 @@ |
||
101 | 101 | if ($type == 'GeometryCollection') { |
102 | 102 | return $this->geoJSONObjectToGeometryCollection($obj); |
103 | 103 | } |
104 | - $method = 'arrayTo' . $type; |
|
104 | + $method = 'arrayTo'.$type; |
|
105 | 105 | /** @var GeometryCollection $geometry */ |
106 | 106 | $geometry = $this->$method($obj->coordinates); |
107 | 107 | $geometry->setSRID($this->getSRID($obj)); |
@@ -102,10 +102,10 @@ discard block |
||
102 | 102 | $dataString = $m['data'] ?: $m['data_empty']; |
103 | 103 | |
104 | 104 | if ($geometryType) { |
105 | - $method = 'parse' . $geometryType; |
|
105 | + $method = 'parse'.$geometryType; |
|
106 | 106 | return call_user_func([$this, $method], $dataString); |
107 | 107 | } |
108 | - throw new \Exception('Invalid WKT type "' . $m[1] . '"'); |
|
108 | + throw new \Exception('Invalid WKT type "'.$m[1].'"'); |
|
109 | 109 | } |
110 | 110 | throw new \Exception('Cannot parse WKT'); |
111 | 111 | } |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | * MULTIPOINT (1 2, 3 4) |
181 | 181 | */ |
182 | 182 | foreach (explode(',', $dataString) as $part) { |
183 | - $points[] = $this->parsePoint(trim($part, ' ()')); |
|
183 | + $points[] = $this->parsePoint(trim($part, ' ()')); |
|
184 | 184 | } |
185 | 185 | return new MultiPoint($points); |
186 | 186 | } |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | $lines = []; |
200 | 200 | if (preg_match_all('/(\([^(]+\)|EMPTY)/', $dataString, $m)) { |
201 | 201 | foreach ($m[1] as $part) { |
202 | - $lines[] = $this->parseLineString(trim($part, ' ()')); |
|
202 | + $lines[] = $this->parseLineString(trim($part, ' ()')); |
|
203 | 203 | } |
204 | 204 | } |
205 | 205 | return new MultiLineString($lines); |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | $polygons = []; |
221 | 221 | if (preg_match_all('/(\(\([^(].+\)\)|EMPTY)/', $dataString, $m)) { |
222 | 222 | foreach ($m[0] as $part) { |
223 | - $polygons[] = $this->parsePolygon($part); |
|
223 | + $polygons[] = $this->parsePolygon($part); |
|
224 | 224 | } |
225 | 225 | } |
226 | 226 | return new MultiPolygon($polygons); |
@@ -251,10 +251,10 @@ discard block |
||
251 | 251 | // something weird happened, we stop here before running in an infinite loop |
252 | 252 | break; |
253 | 253 | } |
254 | - $cutPosition = strlen($m[0][0]) + $m[0][1]; |
|
254 | + $cutPosition = strlen($m[0][0])+$m[0][1]; |
|
255 | 255 | $geometry = $this->parseTypeAndGetData(trim(substr($dataString, 0, $cutPosition))); |
256 | 256 | $geometries[] = $geometry; |
257 | - $dataString = trim(substr($dataString, $cutPosition + 1)); |
|
257 | + $dataString = trim(substr($dataString, $cutPosition+1)); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | return new GeometryCollection($geometries); |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | $this->hasZ = $geometry->hasZ(); |
286 | 286 | |
287 | 287 | if ($geometry->isEmpty()) { |
288 | - return strtoupper($geometry->geometryType()) . ' EMPTY'; |
|
288 | + return strtoupper($geometry->geometryType()).' EMPTY'; |
|
289 | 289 | } |
290 | 290 | |
291 | 291 | if ($data = $this->extractData($geometry)) { |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | if ($this->measured) { |
297 | 297 | $extension .= 'M'; |
298 | 298 | } |
299 | - return strtoupper($geometry->geometryType()) . ($extension ? ' ' . $extension : '') . ' (' . $data . ')'; |
|
299 | + return strtoupper($geometry->geometryType()).($extension ? ' '.$extension : '').' ('.$data.')'; |
|
300 | 300 | } |
301 | 301 | return ''; |
302 | 302 | } |
@@ -313,13 +313,13 @@ discard block |
||
313 | 313 | $parts = []; |
314 | 314 | switch ($geometry->geometryType()) { |
315 | 315 | case Geometry::POINT: |
316 | - $p = $geometry->x() . ' ' . $geometry->y(); |
|
316 | + $p = $geometry->x().' '.$geometry->y(); |
|
317 | 317 | if ($geometry->hasZ()) { |
318 | - $p .= ' ' . $geometry->getZ(); |
|
318 | + $p .= ' '.$geometry->getZ(); |
|
319 | 319 | $this->hasZ = $this->hasZ || $geometry->hasZ(); |
320 | 320 | } |
321 | 321 | if ($geometry->isMeasured()) { |
322 | - $p .= ' ' . $geometry->getM(); |
|
322 | + $p .= ' '.$geometry->getM(); |
|
323 | 323 | $this->measured = $this->measured || $geometry->isMeasured(); |
324 | 324 | } |
325 | 325 | return $p; |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | if ($component->isEmpty()) { |
337 | 337 | $parts[] = 'EMPTY'; |
338 | 338 | } else { |
339 | - $parts[] = '(' . $this->extractData($component) . ')'; |
|
339 | + $parts[] = '('.$this->extractData($component).')'; |
|
340 | 340 | } |
341 | 341 | } |
342 | 342 | return implode(', ', $parts); |
@@ -354,8 +354,8 @@ discard block |
||
354 | 354 | } |
355 | 355 | $data = $this->extractData($component); |
356 | 356 | $parts[] = strtoupper($component->geometryType()) |
357 | - . ($extension ? ' ' . $extension : '') |
|
358 | - . ($data ? ' (' . $data . ')' : ' EMPTY'); |
|
357 | + . ($extension ? ' '.$extension : '') |
|
358 | + . ($data ? ' ('.$data.')' : ' EMPTY'); |
|
359 | 359 | } |
360 | 360 | return implode(', ', $parts); |
361 | 361 | } |
@@ -151,6 +151,6 @@ |
||
151 | 151 | */ |
152 | 152 | public static function zigZagDecode($value) |
153 | 153 | { |
154 | - return ($value & 1) === 0 ? $value >> 1 : -($value >> 1) - 1; |
|
154 | + return ($value & 1) === 0 ? $value >> 1 : -($value >> 1)-1; |
|
155 | 155 | } |
156 | 156 | } |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | { |
57 | 57 | if ($namespace) { |
58 | 58 | $this->namespace = $namespace; |
59 | - $this->nss = $namespace . ':'; |
|
59 | + $this->nss = $namespace.':'; |
|
60 | 60 | } |
61 | 61 | return $this->geometryToGeoRSS($geometry) ?: ''; |
62 | 62 | } |
@@ -71,14 +71,14 @@ discard block |
||
71 | 71 | $xmlObject = new \DOMDocument(); |
72 | 72 | @$xmlObject->loadXML($text); |
73 | 73 | if ($xmlObject === false) { |
74 | - throw new \Exception("Invalid GeoRSS: " . $text); |
|
74 | + throw new \Exception("Invalid GeoRSS: ".$text); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | $this->xmlObject = $xmlObject; |
78 | 78 | try { |
79 | 79 | $geom = $this->geomFromXML(); |
80 | 80 | } catch (\Exception $e) { |
81 | - throw new \Exception("Cannot Read Geometry From GeoRSS: " . $e->getMessage()); |
|
81 | + throw new \Exception("Cannot Read Geometry From GeoRSS: ".$e->getMessage()); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | return $geom; |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | */ |
224 | 224 | private function pointToGeoRSS($geometry) |
225 | 225 | { |
226 | - return '<' . $this->nss . 'point>' . $geometry->y() . ' ' . $geometry->x() . '</' . $this->nss . 'point>'; |
|
226 | + return '<'.$this->nss.'point>'.$geometry->y().' '.$geometry->x().'</'.$this->nss.'point>'; |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | /** |
@@ -232,14 +232,14 @@ discard block |
||
232 | 232 | */ |
233 | 233 | private function linestringToGeoRSS($geometry) |
234 | 234 | { |
235 | - $output = '<' . $this->nss . 'line>'; |
|
235 | + $output = '<'.$this->nss.'line>'; |
|
236 | 236 | foreach ($geometry->getComponents() as $k => $point) { |
237 | - $output .= $point->y() . ' ' . $point->x(); |
|
238 | - if ($k < ($geometry->numGeometries() - 1)) { |
|
237 | + $output .= $point->y().' '.$point->x(); |
|
238 | + if ($k < ($geometry->numGeometries()-1)) { |
|
239 | 239 | $output .= ' '; |
240 | 240 | } |
241 | 241 | } |
242 | - $output .= '</' . $this->nss . 'line>'; |
|
242 | + $output .= '</'.$this->nss.'line>'; |
|
243 | 243 | return $output; |
244 | 244 | } |
245 | 245 | |
@@ -249,15 +249,15 @@ discard block |
||
249 | 249 | */ |
250 | 250 | private function polygonToGeoRSS($geometry) |
251 | 251 | { |
252 | - $output = '<' . $this->nss . 'polygon>'; |
|
252 | + $output = '<'.$this->nss.'polygon>'; |
|
253 | 253 | $exteriorRing = $geometry->exteriorRing(); |
254 | 254 | foreach ($exteriorRing->getComponents() as $k => $point) { |
255 | - $output .= $point->y() . ' ' . $point->x(); |
|
256 | - if ($k < ($exteriorRing->numGeometries() - 1)) { |
|
255 | + $output .= $point->y().' '.$point->x(); |
|
256 | + if ($k < ($exteriorRing->numGeometries()-1)) { |
|
257 | 257 | $output .= ' '; |
258 | 258 | } |
259 | 259 | } |
260 | - $output .= '</' . $this->nss . 'polygon>'; |
|
260 | + $output .= '</'.$this->nss.'polygon>'; |
|
261 | 261 | return $output; |
262 | 262 | } |
263 | 263 | |
@@ -267,13 +267,13 @@ discard block |
||
267 | 267 | */ |
268 | 268 | public function collectionToGeoRSS($geometry) |
269 | 269 | { |
270 | - $georss = '<' . $this->nss . 'where>'; |
|
270 | + $georss = '<'.$this->nss.'where>'; |
|
271 | 271 | $components = $geometry->getComponents(); |
272 | 272 | foreach ($components as $component) { |
273 | 273 | $georss .= $this->geometryToGeoRSS($component); |
274 | 274 | } |
275 | 275 | |
276 | - $georss .= '</' . $this->nss . 'where>'; |
|
276 | + $georss .= '</'.$this->nss.'where>'; |
|
277 | 277 | |
278 | 278 | return $georss; |
279 | 279 | } |
@@ -21,7 +21,7 @@ |
||
21 | 21 | { |
22 | 22 | $srid = $geometry->getSRID(); |
23 | 23 | if ($srid) { |
24 | - $wkt = 'SRID=' . $srid . ';'; |
|
24 | + $wkt = 'SRID='.$srid.';'; |
|
25 | 25 | $wkt .= $geometry->out('wkt'); |
26 | 26 | return $wkt; |
27 | 27 | } else { |
@@ -54,14 +54,14 @@ discard block |
||
54 | 54 | $xmlobj = new \DOMDocument(); |
55 | 55 | $xmlobj->loadXML($osm); |
56 | 56 | if ($xmlobj === false) { |
57 | - throw new \Exception("Invalid OSM XML: " . substr($osm, 0, 100)); |
|
57 | + throw new \Exception("Invalid OSM XML: ".substr($osm, 0, 100)); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | $this->xmlObj = $xmlobj; |
61 | 61 | try { |
62 | 62 | $geom = $this->geomFromXML(); |
63 | 63 | } catch (\Exception $e) { |
64 | - throw new \Exception("Cannot read geometries from OSM XML: " . $e->getMessage()); |
|
64 | + throw new \Exception("Cannot read geometries from OSM XML: ".$e->getMessage()); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | return $geom; |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | 'nodes' => $wayNodes, |
123 | 123 | 'assigned' => false, |
124 | 124 | 'tags' => $tags, |
125 | - 'isRing' => ($wayNodes[0] === $wayNodes[count($wayNodes) - 1]) |
|
125 | + 'isRing' => ($wayNodes[0] === $wayNodes[count($wayNodes)-1]) |
|
126 | 126 | ]; |
127 | 127 | } |
128 | 128 | } |
@@ -154,11 +154,11 @@ discard block |
||
154 | 154 | $memberType = $member->attributes->getNamedItem('type')->nodeValue; |
155 | 155 | $ref = $member->attributes->getNamedItem('ref')->nodeValue; |
156 | 156 | |
157 | - if ($memberType === 'node' && isset($nodes[$ref])) { |
|
157 | + if ($memberType === 'node' && isset($nodes[$ref])) { |
|
158 | 158 | $nodes[$ref]['assigned'] = true; |
159 | 159 | $relationPoints[] = $nodes[$ref]['point']; |
160 | 160 | } |
161 | - if ($memberType === 'way' && isset($ways[$ref])) { |
|
161 | + if ($memberType === 'way' && isset($ways[$ref])) { |
|
162 | 162 | $ways[$ref]['assigned'] = true; |
163 | 163 | $relationWays[$ref] = $ways[$ref]['nodes']; |
164 | 164 | } |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | if ( |
194 | 194 | (!$way['assigned'] || !empty($way['tags'])) |
195 | 195 | && !isset($way['tags']['boundary']) |
196 | - && (!isset($way['tags']['natural']) || $way['tags']['natural'] !== 'mountain_range') |
|
196 | + && (!isset($way['tags']['natural']) || $way['tags']['natural'] !== 'mountain_range') |
|
197 | 197 | ) { |
198 | 198 | $linePoints = []; |
199 | 199 | foreach ($way['nodes'] as $wayNode) { |
@@ -231,23 +231,23 @@ discard block |
||
231 | 231 | $lineStrings = []; |
232 | 232 | while (count($relationWays) > 0) { |
233 | 233 | $line = array_shift($relationWays); |
234 | - if ($line[0] !== $line[count($line) - 1]) { |
|
234 | + if ($line[0] !== $line[count($line)-1]) { |
|
235 | 235 | do { |
236 | 236 | $waysAdded = 0; |
237 | 237 | foreach ($relationWays as $id => $wayNodes) { |
238 | 238 | // Last node of ring = first node of way => put way to the end of ring |
239 | - if ($line[count($line) - 1] === $wayNodes[0]) { |
|
239 | + if ($line[count($line)-1] === $wayNodes[0]) { |
|
240 | 240 | $line = array_merge($line, array_slice($wayNodes, 1)); |
241 | 241 | unset($relationWays[$id]); |
242 | 242 | $waysAdded++; |
243 | 243 | // Last node of ring = last node of way => reverse way and put to the end of ring |
244 | - } elseif ($line[count($line) - 1] === $wayNodes[count($wayNodes) - 1]) { |
|
244 | + } elseif ($line[count($line)-1] === $wayNodes[count($wayNodes)-1]) { |
|
245 | 245 | $line = array_merge($line, array_slice(array_reverse($wayNodes), 1)); |
246 | 246 | unset($relationWays[$id]); |
247 | 247 | $waysAdded++; |
248 | 248 | // First node of ring = last node of way => put way to the beginning of ring |
249 | - } elseif ($line[0] === $wayNodes[count($wayNodes) - 1]) { |
|
250 | - $line = array_merge(array_slice($wayNodes, 0, count($wayNodes) - 1), $line); |
|
249 | + } elseif ($line[0] === $wayNodes[count($wayNodes)-1]) { |
|
250 | + $line = array_merge(array_slice($wayNodes, 0, count($wayNodes)-1), $line); |
|
251 | 251 | unset($relationWays[$id]); |
252 | 252 | $waysAdded++; |
253 | 253 | // First node of ring = first node of way => reverse way and put to the beginning of ring |
@@ -285,23 +285,23 @@ discard block |
||
285 | 285 | $rings = []; |
286 | 286 | while (!empty($relationWays)) { |
287 | 287 | $ring = array_shift($relationWays); |
288 | - if ($ring[0] !== $ring[count($ring) - 1]) { |
|
288 | + if ($ring[0] !== $ring[count($ring)-1]) { |
|
289 | 289 | do { |
290 | 290 | $waysAdded = 0; |
291 | 291 | foreach ($relationWays as $id => $wayNodes) { |
292 | 292 | // Last node of ring = first node of way => put way to the end of ring |
293 | - if ($ring[count($ring) - 1] === $wayNodes[0]) { |
|
293 | + if ($ring[count($ring)-1] === $wayNodes[0]) { |
|
294 | 294 | $ring = array_merge($ring, array_slice($wayNodes, 1)); |
295 | 295 | unset($relationWays[$id]); |
296 | 296 | $waysAdded++; |
297 | 297 | // Last node of ring = last node of way => reverse way and put to the end of ring |
298 | - } elseif ($ring[count($ring) - 1] === $wayNodes[count($wayNodes) - 1]) { |
|
298 | + } elseif ($ring[count($ring)-1] === $wayNodes[count($wayNodes)-1]) { |
|
299 | 299 | $ring = array_merge($ring, array_slice(array_reverse($wayNodes), 1)); |
300 | 300 | unset($relationWays[$id]); |
301 | 301 | $waysAdded++; |
302 | 302 | // First node of ring = last node of way => put way to the beginning of ring |
303 | - } elseif ($ring[0] === $wayNodes[count($wayNodes) - 1]) { |
|
304 | - $ring = array_merge(array_slice($wayNodes, 0, count($wayNodes) - 1), $ring); |
|
303 | + } elseif ($ring[0] === $wayNodes[count($wayNodes)-1]) { |
|
304 | + $ring = array_merge(array_slice($wayNodes, 0, count($wayNodes)-1), $ring); |
|
305 | 305 | unset($relationWays[$id]); |
306 | 306 | $waysAdded++; |
307 | 307 | // First node of ring = first node of way => reverse way and put to the beginning of ring |
@@ -312,11 +312,11 @@ discard block |
||
312 | 312 | } |
313 | 313 | } |
314 | 314 | // If ring members are not ordered, we need to repeat end matching some times |
315 | - } while ($waysAdded > 0 && $ring[0] !== $ring[count($ring) - 1]); |
|
315 | + } while ($waysAdded > 0 && $ring[0] !== $ring[count($ring)-1]); |
|
316 | 316 | } |
317 | 317 | |
318 | 318 | // Create the new Polygon |
319 | - if ($ring[0] === $ring[count($ring) - 1]) { |
|
319 | + if ($ring[0] === $ring[count($ring)-1]) { |
|
320 | 320 | $ringPoints = []; |
321 | 321 | foreach ($ring as $ringNode) { |
322 | 322 | $ringPoints[] = $nodes[$ringNode]['point']; |
@@ -471,7 +471,7 @@ discard block |
||
471 | 471 | */ |
472 | 472 | protected function processPoint($point, $isWayPoint = false) |
473 | 473 | { |
474 | - $nodePosition = sprintf(self::OSM_COORDINATE_PRECISION . '_' . self::OSM_COORDINATE_PRECISION, $point->y(), $point->x()); |
|
474 | + $nodePosition = sprintf(self::OSM_COORDINATE_PRECISION.'_'.self::OSM_COORDINATE_PRECISION, $point->y(), $point->x()); |
|
475 | 475 | if (!isset($this->nodes[$nodePosition])) { |
476 | 476 | $this->nodes[$nodePosition] = ['id' => --$this->idCounter, "used" => $isWayPoint]; |
477 | 477 | return $this->idCounter; |
@@ -519,7 +519,7 @@ discard block |
||
519 | 519 | { |
520 | 520 | /** @noinspection PhpUnusedParameterInspection */ |
521 | 521 | set_error_handler( |
522 | - function ($errNO, $errStr, $errFile, $errLine, $errContext) { |
|
522 | + function($errNO, $errStr, $errFile, $errLine, $errContext) { |
|
523 | 523 | if (isset($errContext['http_response_header'])) { |
524 | 524 | foreach ($errContext['http_response_header'] as $line) { |
525 | 525 | if (strpos($line, 'Error: ') > -1) { |
@@ -533,12 +533,12 @@ discard block |
||
533 | 533 | ); |
534 | 534 | |
535 | 535 | try { |
536 | - $osmFile = file_get_contents(self::OSM_API_URL . "map?bbox={$left},{$bottom},{$right},{$top}"); |
|
536 | + $osmFile = file_get_contents(self::OSM_API_URL."map?bbox={$left},{$bottom},{$right},{$top}"); |
|
537 | 537 | restore_error_handler(); |
538 | 538 | return $osmFile; |
539 | 539 | } catch (\Exception $e) { |
540 | 540 | restore_error_handler(); |
541 | - throw new \Exception("Failed to download from OSM. " . $e->getMessage()); |
|
541 | + throw new \Exception("Failed to download from OSM. ".$e->getMessage()); |
|
542 | 542 | } |
543 | 543 | } |
544 | 544 | } |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | } |
90 | 90 | |
91 | 91 | if (empty($twkb)) { |
92 | - throw new \Exception('Cannot read empty TWKB. Found ' . gettype($twkb)); |
|
92 | + throw new \Exception('Cannot read empty TWKB. Found '.gettype($twkb)); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | $this->reader = new BinaryReader($twkb); |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | $options['remainderSize'] = $this->reader->readUVarInt(); |
140 | 140 | } |
141 | 141 | if ($options['hasBoundingBox']) { |
142 | - $dimension = 2 + ($options['hasZ'] ? 1 : 0) + ($options['hasM'] ? 1 : 0); |
|
142 | + $dimension = 2+($options['hasZ'] ? 1 : 0)+($options['hasM'] ? 1 : 0); |
|
143 | 143 | $precisions = [ |
144 | 144 | $options['precisionFactor'], |
145 | 145 | $options['precisionFactor'], |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | $bBoxMin = $bBoxMax = []; |
150 | 150 | for ($i = 0; $i < $dimension; $i++) { |
151 | 151 | $bBoxMin[$i] = $this->reader->readUVarInt() / $precisions[$i]; |
152 | - $bBoxMax[$i] = $this->reader->readUVarInt() / $precisions[$i] + $bBoxMin[$i]; |
|
152 | + $bBoxMax[$i] = $this->reader->readUVarInt() / $precisions[$i]+$bBoxMin[$i]; |
|
153 | 153 | } |
154 | 154 | /** @noinspection PhpUndefinedVariableInspection (minimum 2 dimension) */ |
155 | 155 | $options['boundingBox'] = ['minXYZM' => $bBoxMin, 'maxXYZM' => $bBoxMax]; |
@@ -191,8 +191,8 @@ discard block |
||
191 | 191 | break; |
192 | 192 | default: |
193 | 193 | throw new \Exception( |
194 | - 'Geometry type ' . $geometryType . |
|
195 | - ' (' . (array_search($geometryType, self::$typeMap) ?: 'unknown') . ') not supported' |
|
194 | + 'Geometry type '.$geometryType. |
|
195 | + ' ('.(array_search($geometryType, self::$typeMap) ?: 'unknown').') not supported' |
|
196 | 196 | ); |
197 | 197 | } |
198 | 198 | |
@@ -211,19 +211,19 @@ discard block |
||
211 | 211 | return new Point(); |
212 | 212 | } |
213 | 213 | $x = round( |
214 | - $this->lastPoint->x() + $this->reader->readSVarInt() / $options['precisionFactor'], |
|
214 | + $this->lastPoint->x()+$this->reader->readSVarInt() / $options['precisionFactor'], |
|
215 | 215 | $options['precision'] |
216 | 216 | ); |
217 | 217 | $y = round( |
218 | - $this->lastPoint->y() + $this->reader->readSVarInt() / $options['precisionFactor'], |
|
218 | + $this->lastPoint->y()+$this->reader->readSVarInt() / $options['precisionFactor'], |
|
219 | 219 | $options['precision'] |
220 | 220 | ); |
221 | 221 | $z = $options['hasZ'] ? round( |
222 | - $this->lastPoint->z() + $this->reader->readSVarInt() / $options['zPrecisionFactor'], |
|
222 | + $this->lastPoint->z()+$this->reader->readSVarInt() / $options['zPrecisionFactor'], |
|
223 | 223 | $options['zPrecision'] |
224 | 224 | ) : null; |
225 | 225 | $m = $options['hasM'] ? round( |
226 | - $this->lastPoint->m() + $this->reader->readSVarInt() / $options['mPrecisionFactor'], |
|
226 | + $this->lastPoint->m()+$this->reader->readSVarInt() / $options['mPrecisionFactor'], |
|
227 | 227 | $options['mPrecision'] |
228 | 228 | ) : null; |
229 | 229 | |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | $components = []; |
296 | 296 | for ($i = 0; $i < $multiLength; $i++) { |
297 | 297 | if ($type !== 'Geometry') { |
298 | - $func = 'get' . $type; |
|
298 | + $func = 'get'.$type; |
|
299 | 299 | $components[] = $this->$func($options); |
300 | 300 | } else { |
301 | 301 | $components[] = $this->getGeometry(); |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | $this->writeOptions['hasM'] = $geometry->isMeasured(); |
367 | 367 | |
368 | 368 | // Type and precision |
369 | - $type = self::$typeMap[$geometry->geometryType()] + |
|
369 | + $type = self::$typeMap[$geometry->geometryType()]+ |
|
370 | 370 | (BinaryWriter::zigZagEncode($this->writeOptions['decimalDigitsXY']) << 4); |
371 | 371 | $twkbHead = $this->writer->writeUInt8($type); |
372 | 372 | |
@@ -415,32 +415,32 @@ discard block |
||
415 | 415 | $bBox = $geometry->getBoundingBox(); |
416 | 416 | // X |
417 | 417 | $twkbBox = $this->writer->writeSVarInt($bBox['minx'] * $this->writeOptions['xyFactor']); |
418 | - $twkbBox .= $this->writer->writeSVarInt(($bBox['maxx'] - $bBox['minx']) * $this->writeOptions['xyFactor']); |
|
418 | + $twkbBox .= $this->writer->writeSVarInt(($bBox['maxx']-$bBox['minx']) * $this->writeOptions['xyFactor']); |
|
419 | 419 | // Y |
420 | 420 | $twkbBox .= $this->writer->writeSVarInt($bBox['miny'] * $this->writeOptions['xyFactor']); |
421 | - $twkbBox .= $this->writer->writeSVarInt(($bBox['maxy'] - $bBox['miny']) * $this->writeOptions['xyFactor']); |
|
421 | + $twkbBox .= $this->writer->writeSVarInt(($bBox['maxy']-$bBox['miny']) * $this->writeOptions['xyFactor']); |
|
422 | 422 | if ($geometry->hasZ()) { |
423 | 423 | $bBox['minz'] = $geometry->minimumZ(); |
424 | 424 | $bBox['maxz'] = $geometry->maximumZ(); |
425 | 425 | $twkbBox .= $this->writer->writeSVarInt(round($bBox['minz'] * $this->writeOptions['zFactor'])); |
426 | - $twkbBox .= $this->writer->writeSVarInt(round(($bBox['maxz'] - $bBox['minz']) * $this->writeOptions['zFactor'])); |
|
426 | + $twkbBox .= $this->writer->writeSVarInt(round(($bBox['maxz']-$bBox['minz']) * $this->writeOptions['zFactor'])); |
|
427 | 427 | } |
428 | 428 | if ($geometry->isMeasured()) { |
429 | 429 | $bBox['minm'] = $geometry->minimumM(); |
430 | 430 | $bBox['maxm'] = $geometry->maximumM(); |
431 | 431 | $twkbBox .= $this->writer->writeSVarInt($bBox['minm'] * $this->writeOptions['mFactor']); |
432 | - $twkbBox .= $this->writer->writeSVarInt(($bBox['maxm'] - $bBox['minm']) * $this->writeOptions['mFactor']); |
|
432 | + $twkbBox .= $this->writer->writeSVarInt(($bBox['maxm']-$bBox['minm']) * $this->writeOptions['mFactor']); |
|
433 | 433 | } |
434 | - $twkbGeom = $twkbBox . $twkbGeom; |
|
434 | + $twkbGeom = $twkbBox.$twkbGeom; |
|
435 | 435 | } |
436 | 436 | |
437 | 437 | if ($geometry->hasZ() || $geometry->isMeasured()) { |
438 | 438 | $extendedPrecision = 0; |
439 | 439 | if ($geometry->hasZ()) { |
440 | - $extendedPrecision |= ($geometry->hasZ() ? 0x1 : 0) | ($this->writeOptions['decimalDigitsZ'] << 2); |
|
440 | + $extendedPrecision |= ($geometry->hasZ() ? 0x1 : 0)|($this->writeOptions['decimalDigitsZ'] << 2); |
|
441 | 441 | } |
442 | 442 | if ($geometry->isMeasured()) { |
443 | - $extendedPrecision |= ($geometry->isMeasured() ? 0x2 : 0) | ($this->writeOptions['decimalDigitsM'] << 5); |
|
443 | + $extendedPrecision |= ($geometry->isMeasured() ? 0x2 : 0)|($this->writeOptions['decimalDigitsM'] << 5); |
|
444 | 444 | } |
445 | 445 | $twkbHead .= $this->writer->writeUInt8($extendedPrecision); |
446 | 446 | } |
@@ -448,7 +448,7 @@ discard block |
||
448 | 448 | $twkbHead .= $this->writer->writeUVarInt(strlen($twkbGeom)); |
449 | 449 | } |
450 | 450 | |
451 | - return $twkbHead . $twkbGeom; |
|
451 | + return $twkbHead.$twkbGeom; |
|
452 | 452 | } |
453 | 453 | |
454 | 454 | /** |
@@ -462,13 +462,13 @@ discard block |
||
462 | 462 | $z = round($geometry->z() * $this->writeOptions['zFactor']); |
463 | 463 | $m = round($geometry->m() * $this->writeOptions['mFactor']); |
464 | 464 | |
465 | - $twkb = $this->writer->writeSVarInt($x - $this->lastPoint->x()); |
|
466 | - $twkb .= $this->writer->writeSVarInt($y - $this->lastPoint->y()); |
|
465 | + $twkb = $this->writer->writeSVarInt($x-$this->lastPoint->x()); |
|
466 | + $twkb .= $this->writer->writeSVarInt($y-$this->lastPoint->y()); |
|
467 | 467 | if ($this->writeOptions['hasZ']) { |
468 | - $twkb .= $this->writer->writeSVarInt($z - $this->lastPoint->z()); |
|
468 | + $twkb .= $this->writer->writeSVarInt($z-$this->lastPoint->z()); |
|
469 | 469 | } |
470 | 470 | if ($this->writeOptions['hasM']) { |
471 | - $twkb .= $this->writer->writeSVarInt($m - $this->lastPoint->m()); |
|
471 | + $twkb .= $this->writer->writeSVarInt($m-$this->lastPoint->m()); |
|
472 | 472 | } |
473 | 473 | |
474 | 474 | $this->lastPoint = new Point($x, $y, $this->writeOptions['hasZ'] ? $z : null, $this->writeOptions['hasM'] ? $m : null); |
@@ -516,7 +516,7 @@ discard block |
||
516 | 516 | //} |
517 | 517 | foreach ($geometry->getComponents() as $component) { |
518 | 518 | if ($geometry->geometryType() !== Geometry::GEOMETRY_COLLECTION) { |
519 | - $func = 'write' . $component->geometryType(); |
|
519 | + $func = 'write'.$component->geometryType(); |
|
520 | 520 | $twkb .= $this->$func($component); |
521 | 521 | } else { |
522 | 522 | $twkb .= $this->writeGeometry($component); |
@@ -56,14 +56,14 @@ discard block |
||
56 | 56 | $bounds = $bounds->getBBox(); |
57 | 57 | } |
58 | 58 | if (gettype($bounds) == 'array') { |
59 | - $boundsString = '&bounds=' . $bounds['miny'] . ',' . $bounds['minx'] . '|' . $bounds['maxy'] . ',' . $bounds['maxx']; |
|
59 | + $boundsString = '&bounds='.$bounds['miny'].','.$bounds['minx'].'|'.$bounds['maxy'].','.$bounds['maxx']; |
|
60 | 60 | } else { |
61 | 61 | $boundsString = ''; |
62 | 62 | } |
63 | 63 | |
64 | 64 | $url = "http://maps.googleapis.com/maps/api/geocode/json"; |
65 | - $url .= '?address=' . urlencode($address); |
|
66 | - $url .= $boundsString . ($apiKey ? '&key=' . $apiKey : ''); |
|
65 | + $url .= '?address='.urlencode($address); |
|
66 | + $url .= $boundsString.($apiKey ? '&key='.$apiKey : ''); |
|
67 | 67 | $this->result = json_decode(@file_get_contents($url)); |
68 | 68 | |
69 | 69 | if ($this->result->status == 'OK') { |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | throw new \Exception( |
98 | 98 | 'Error in Google Reverse Geocoder: ' |
99 | 99 | . $this->result->status |
100 | - . (isset($this->result->error_message) ? '. ' . $this->result->error_message : '') |
|
100 | + . (isset($this->result->error_message) ? '. '.$this->result->error_message : '') |
|
101 | 101 | ); |
102 | 102 | } else { |
103 | 103 | throw new \Exception('Unknown error in Google Reverse Geocoder'); |
@@ -128,8 +128,8 @@ discard block |
||
128 | 128 | |
129 | 129 | $url = "http://maps.googleapis.com/maps/api/geocode/json"; |
130 | 130 | /** @noinspection SpellCheckingInspection */ |
131 | - $url .= '?latlng=' . $lat . ',' . $lon; |
|
132 | - $url .= ($language ? '&language=' . $language : '') . ($apiKey ? '&key=' . $apiKey : ''); |
|
131 | + $url .= '?latlng='.$lat.','.$lon; |
|
132 | + $url .= ($language ? '&language='.$language : '').($apiKey ? '&key='.$apiKey : ''); |
|
133 | 133 | |
134 | 134 | $this->result = json_decode(@file_get_contents($url)); |
135 | 135 | |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | throw new \Exception( |
154 | 154 | 'Error in Google Reverse Geocoder: ' |
155 | 155 | . $this->result->status |
156 | - . (isset($this->result->error_message) ? '. ' . $this->result->error_message : '') |
|
156 | + . (isset($this->result->error_message) ? '. '.$this->result->error_message : '') |
|
157 | 157 | ); |
158 | 158 | } else { |
159 | 159 | throw new \Exception('Unknown error in Google Reverse Geocoder'); |
@@ -64,14 +64,14 @@ discard block |
||
64 | 64 | $xmlObject = new \DOMDocument(); |
65 | 65 | @$xmlObject->loadXML($text); |
66 | 66 | if ($xmlObject === false) { |
67 | - throw new \Exception("Invalid KML: " . $text); |
|
67 | + throw new \Exception("Invalid KML: ".$text); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | $this->xmlObject = $xmlObject; |
71 | 71 | try { |
72 | 72 | $geom = $this->geomFromXML(); |
73 | 73 | } catch (\Exception $e) { |
74 | - throw new \Exception("Cannot Read Geometry From KML. " . $e->getMessage()); |
|
74 | + throw new \Exception("Cannot Read Geometry From KML. ".$e->getMessage()); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | return $geom; |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | // Node names are all the same, except for MultiGeometry, which maps to GeometryCollection |
91 | 91 | $nodeName = $child->nodeName == 'multigeometry' ? 'geometrycollection' : $child->nodeName; |
92 | 92 | if (array_key_exists($nodeName, geoPHP::getGeometryList())) { |
93 | - $function = 'parse' . geoPHP::getGeometryList()[$nodeName]; |
|
93 | + $function = 'parse'.geoPHP::getGeometryList()[$nodeName]; |
|
94 | 94 | $geometry = $this->$function($child); |
95 | 95 | } elseif ($child->nodeType === 1) { |
96 | 96 | $data[$child->nodeName] = $child->nodeValue; |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | // The document does not have a placemark, try to create a valid geometry from the root element |
109 | 109 | $nodeName = $this->xmlObject->documentElement->nodeName == 'multigeometry' ? 'geometrycollection' : $this->xmlObject->documentElement->nodeName; |
110 | 110 | if (array_key_exists($nodeName, geoPHP::getGeometryList())) { |
111 | - $function = 'parse' . geoPHP::getGeometryList()[$nodeName]; |
|
111 | + $function = 'parse'.geoPHP::getGeometryList()[$nodeName]; |
|
112 | 112 | return $this->$function($this->xmlObject->documentElement); |
113 | 113 | } |
114 | 114 | } |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | ? 'geometrycollection' |
207 | 207 | : $child->nodeName); |
208 | 208 | if (array_key_exists($nodeName, $geometryTypes)) { |
209 | - $function = 'parse' . $geometryTypes[$nodeName]; |
|
209 | + $function = 'parse'.$geometryTypes[$nodeName]; |
|
210 | 210 | $components[] = $this->$function($child); |
211 | 211 | } |
212 | 212 | } |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | { |
246 | 246 | if ($namespace) { |
247 | 247 | $this->namespace = $namespace; |
248 | - $this->nss = $namespace . ':'; |
|
248 | + $this->nss = $namespace.':'; |
|
249 | 249 | } |
250 | 250 | return $this->geometryToKML($geometry); |
251 | 251 | } |
@@ -283,13 +283,13 @@ discard block |
||
283 | 283 | */ |
284 | 284 | private function pointToKML($geometry) |
285 | 285 | { |
286 | - $str = '<' . $this->nss . "Point>\n<" . $this->nss . 'coordinates>'; |
|
286 | + $str = '<'.$this->nss."Point>\n<".$this->nss.'coordinates>'; |
|
287 | 287 | if ($geometry->isEmpty()) { |
288 | 288 | $str .= "0,0"; |
289 | 289 | } else { |
290 | - $str .= $geometry->x() . ',' . $geometry->y() . ($geometry->hasZ() ? ',' . $geometry->z() : ''); |
|
290 | + $str .= $geometry->x().','.$geometry->y().($geometry->hasZ() ? ','.$geometry->z() : ''); |
|
291 | 291 | } |
292 | - return $str . '</' . $this->nss . 'coordinates></' . $this->nss . "Point>\n"; |
|
292 | + return $str.'</'.$this->nss.'coordinates></'.$this->nss."Point>\n"; |
|
293 | 293 | } |
294 | 294 | |
295 | 295 | /** |
@@ -303,23 +303,23 @@ discard block |
||
303 | 303 | $type = $geometry->geometryType(); |
304 | 304 | } |
305 | 305 | |
306 | - $str = '<' . $this->nss . $type . ">\n"; |
|
306 | + $str = '<'.$this->nss.$type.">\n"; |
|
307 | 307 | |
308 | 308 | if (!$geometry->isEmpty()) { |
309 | - $str .= '<' . $this->nss . 'coordinates>'; |
|
309 | + $str .= '<'.$this->nss.'coordinates>'; |
|
310 | 310 | $i = 0; |
311 | 311 | foreach ($geometry->getComponents() as $comp) { |
312 | 312 | if ($i != 0) { |
313 | 313 | $str .= ' '; |
314 | 314 | } |
315 | - $str .= $comp->x() . ',' . $comp->y(); |
|
315 | + $str .= $comp->x().','.$comp->y(); |
|
316 | 316 | $i++; |
317 | 317 | } |
318 | 318 | |
319 | - $str .= '</' . $this->nss . 'coordinates>'; |
|
319 | + $str .= '</'.$this->nss.'coordinates>'; |
|
320 | 320 | } |
321 | 321 | |
322 | - $str .= '</' . $this->nss . $type . ">\n"; |
|
322 | + $str .= '</'.$this->nss.$type.">\n"; |
|
323 | 323 | |
324 | 324 | return $str; |
325 | 325 | } |
@@ -334,13 +334,13 @@ discard block |
||
334 | 334 | $str = ''; |
335 | 335 | if (!empty($components)) { |
336 | 336 | /** @noinspection PhpParamsInspection */ |
337 | - $str = '<' . $this->nss . 'outerBoundaryIs>' . $this->linestringToKML($components[0], 'LinearRing') . '</' . $this->nss . 'outerBoundaryIs>'; |
|
337 | + $str = '<'.$this->nss.'outerBoundaryIs>'.$this->linestringToKML($components[0], 'LinearRing').'</'.$this->nss.'outerBoundaryIs>'; |
|
338 | 338 | foreach (array_slice($components, 1) as $comp) { |
339 | - $str .= '<' . $this->nss . 'innerBoundaryIs>' . $this->linestringToKML($comp) . '</' . $this->nss . 'innerBoundaryIs>'; |
|
339 | + $str .= '<'.$this->nss.'innerBoundaryIs>'.$this->linestringToKML($comp).'</'.$this->nss.'innerBoundaryIs>'; |
|
340 | 340 | } |
341 | 341 | } |
342 | 342 | |
343 | - return '<' . $this->nss . "Polygon>\n" . $str . '</' . $this->nss . "Polygon>\n"; |
|
343 | + return '<'.$this->nss."Polygon>\n".$str.'</'.$this->nss."Polygon>\n"; |
|
344 | 344 | } |
345 | 345 | |
346 | 346 | /** |
@@ -350,12 +350,12 @@ discard block |
||
350 | 350 | public function collectionToKML($geometry) |
351 | 351 | { |
352 | 352 | $components = $geometry->getComponents(); |
353 | - $str = '<' . $this->nss . "MultiGeometry>\n"; |
|
353 | + $str = '<'.$this->nss."MultiGeometry>\n"; |
|
354 | 354 | foreach ($components as $component) { |
355 | 355 | $subAdapter = new KML(); |
356 | 356 | $str .= $subAdapter->write($component); |
357 | 357 | } |
358 | 358 | |
359 | - return $str . '</' . $this->nss . "MultiGeometry>\n"; |
|
359 | + return $str.'</'.$this->nss."MultiGeometry>\n"; |
|
360 | 360 | } |
361 | 361 | } |