Completed
Push — master ( 4465ab...8cdfe4 )
by Michal
03:38
created
src/ShapeFile.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -334,6 +334,9 @@
 block discarded – undo
334 334
       }
335 335
     }
336 336
 
337
+    /**
338
+     * @param string $error
339
+     */
337 340
     function setError($error) {
338 341
       $this->lastError = $error;
339 342
       return false;
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -95,20 +95,20 @@  discard block
 block discarded – undo
95 95
         $this->records[] = $record;
96 96
         $this->records[count($this->records) - 1]->recordNumber = count($this->records);
97 97
 
98
-        if ($this->boundingBox["xmin"]==0.0 || ($this->boundingBox["xmin"]>$record->SHPData["xmin"])) $this->boundingBox["xmin"] = $record->SHPData["xmin"];
99
-        if ($this->boundingBox["xmax"]==0.0 || ($this->boundingBox["xmax"]<$record->SHPData["xmax"])) $this->boundingBox["xmax"] = $record->SHPData["xmax"];
98
+        if ($this->boundingBox["xmin"] == 0.0 || ($this->boundingBox["xmin"] > $record->SHPData["xmin"])) $this->boundingBox["xmin"] = $record->SHPData["xmin"];
99
+        if ($this->boundingBox["xmax"] == 0.0 || ($this->boundingBox["xmax"] < $record->SHPData["xmax"])) $this->boundingBox["xmax"] = $record->SHPData["xmax"];
100 100
 
101
-        if ($this->boundingBox["ymin"]==0.0 || ($this->boundingBox["ymin"]>$record->SHPData["ymin"])) $this->boundingBox["ymin"] = $record->SHPData["ymin"];
102
-        if ($this->boundingBox["ymax"]==0.0 || ($this->boundingBox["ymax"]<$record->SHPData["ymax"])) $this->boundingBox["ymax"] = $record->SHPData["ymax"];
101
+        if ($this->boundingBox["ymin"] == 0.0 || ($this->boundingBox["ymin"] > $record->SHPData["ymin"])) $this->boundingBox["ymin"] = $record->SHPData["ymin"];
102
+        if ($this->boundingBox["ymax"] == 0.0 || ($this->boundingBox["ymax"] < $record->SHPData["ymax"])) $this->boundingBox["ymax"] = $record->SHPData["ymax"];
103 103
 
104
-        if (in_array($this->shapeType,array(11,13,15,18,21,23,25,28))) {
105
-            if (!isset($this->boundingBox["mmin"]) || $this->boundingBox["mmin"]==0.0 || ($this->boundingBox["mmin"]>$record->SHPData["mmin"])) $this->boundingBox["mmin"] = $record->SHPData["mmin"];
106
-            if (!isset($this->boundingBox["mmax"]) || $this->boundingBox["mmax"]==0.0 || ($this->boundingBox["mmax"]<$record->SHPData["mmax"])) $this->boundingBox["mmax"] = $record->SHPData["mmax"];
104
+        if (in_array($this->shapeType, array(11, 13, 15, 18, 21, 23, 25, 28))) {
105
+            if (!isset($this->boundingBox["mmin"]) || $this->boundingBox["mmin"] == 0.0 || ($this->boundingBox["mmin"] > $record->SHPData["mmin"])) $this->boundingBox["mmin"] = $record->SHPData["mmin"];
106
+            if (!isset($this->boundingBox["mmax"]) || $this->boundingBox["mmax"] == 0.0 || ($this->boundingBox["mmax"] < $record->SHPData["mmax"])) $this->boundingBox["mmax"] = $record->SHPData["mmax"];
107 107
         }
108 108
 
109
-        if (in_array($this->shapeType,array(11,13,15,18))) {
110
-            if (!isset($this->boundingBox["zmin"]) || $this->boundingBox["zmin"]==0.0 || ($this->boundingBox["zmin"]>$record->SHPData["zmin"])) $this->boundingBox["zmin"] = $record->SHPData["zmin"];
111
-            if (!isset($this->boundingBox["zmax"]) || $this->boundingBox["zmax"]==0.0 || ($this->boundingBox["zmax"]<$record->SHPData["zmax"])) $this->boundingBox["zmax"] = $record->SHPData["zmax"];
109
+        if (in_array($this->shapeType, array(11, 13, 15, 18))) {
110
+            if (!isset($this->boundingBox["zmin"]) || $this->boundingBox["zmin"] == 0.0 || ($this->boundingBox["zmin"] > $record->SHPData["zmin"])) $this->boundingBox["zmin"] = $record->SHPData["zmin"];
111
+            if (!isset($this->boundingBox["zmax"]) || $this->boundingBox["zmax"] == 0.0 || ($this->boundingBox["zmax"] < $record->SHPData["zmax"])) $this->boundingBox["zmax"] = $record->SHPData["zmax"];
112 112
         }
113 113
 
114 114
         return (count($this->records) - 1);
@@ -219,23 +219,23 @@  discard block
 block discarded – undo
219 219
         fwrite($this->SHPFile, Util::packDouble($this->boundingBox['ymin']));
220 220
         fwrite($this->SHPFile, Util::packDouble($this->boundingBox['xmax']));
221 221
         fwrite($this->SHPFile, Util::packDouble($this->boundingBox['ymax']));
222
-        fwrite($this->SHPFile, Util::packDouble(isset($this->boundingBox['zmin'])?$this->boundingBox['zmin']:0));
223
-        fwrite($this->SHPFile, Util::packDouble(isset($this->boundingBox['zmax'])?$this->boundingBox['zmax']:0));
224
-        fwrite($this->SHPFile, Util::packDouble(isset($this->boundingBox['mmin'])?$this->boundingBox['mmin']:0));
225
-        fwrite($this->SHPFile, Util::packDouble(isset($this->boundingBox['mmax'])?$this->boundingBox['mmax']:0));
222
+        fwrite($this->SHPFile, Util::packDouble(isset($this->boundingBox['zmin']) ? $this->boundingBox['zmin'] : 0));
223
+        fwrite($this->SHPFile, Util::packDouble(isset($this->boundingBox['zmax']) ? $this->boundingBox['zmax'] : 0));
224
+        fwrite($this->SHPFile, Util::packDouble(isset($this->boundingBox['mmin']) ? $this->boundingBox['mmin'] : 0));
225
+        fwrite($this->SHPFile, Util::packDouble(isset($this->boundingBox['mmax']) ? $this->boundingBox['mmax'] : 0));
226 226
 
227 227
         fwrite($this->SHXFile, pack("NNNNNN", 9994, 0, 0, 0, 0, 0));
228
-        fwrite($this->SHXFile, pack("N", 50 + 4*count($this->records)));
228
+        fwrite($this->SHXFile, pack("N", 50 + 4 * count($this->records)));
229 229
         fwrite($this->SHXFile, pack("V", 1000));
230 230
         fwrite($this->SHXFile, pack("V", $this->shapeType));
231 231
         fwrite($this->SHXFile, Util::packDouble($this->boundingBox['xmin']));
232 232
         fwrite($this->SHXFile, Util::packDouble($this->boundingBox['ymin']));
233 233
         fwrite($this->SHXFile, Util::packDouble($this->boundingBox['xmax']));
234 234
         fwrite($this->SHXFile, Util::packDouble($this->boundingBox['ymax']));
235
-        fwrite($this->SHXFile, Util::packDouble(isset($this->boundingBox['zmin'])?$this->boundingBox['zmin']:0));
236
-        fwrite($this->SHXFile, Util::packDouble(isset($this->boundingBox['zmax'])?$this->boundingBox['zmax']:0));
237
-        fwrite($this->SHXFile, Util::packDouble(isset($this->boundingBox['mmin'])?$this->boundingBox['mmin']:0));
238
-        fwrite($this->SHXFile, Util::packDouble(isset($this->boundingBox['mmax'])?$this->boundingBox['mmax']:0));
235
+        fwrite($this->SHXFile, Util::packDouble(isset($this->boundingBox['zmin']) ? $this->boundingBox['zmin'] : 0));
236
+        fwrite($this->SHXFile, Util::packDouble(isset($this->boundingBox['zmax']) ? $this->boundingBox['zmax'] : 0));
237
+        fwrite($this->SHXFile, Util::packDouble(isset($this->boundingBox['mmin']) ? $this->boundingBox['mmin'] : 0));
238
+        fwrite($this->SHXFile, Util::packDouble(isset($this->boundingBox['mmax']) ? $this->boundingBox['mmax'] : 0));
239 239
     }
240 240
 
241 241
     private function _loadRecords() {
Please login to merge, or discard this patch.
Braces   +27 added lines, -9 removed lines patch added patch discarded remove patch
@@ -73,7 +73,9 @@  discard block
 block discarded – undo
73 73
     }
74 74
 
75 75
     public function saveToFile($FileName = NULL) {
76
-        if ($FileName != NULL) $this->FileName = $FileName;
76
+        if ($FileName != NULL) {
77
+            $this->FileName = $FileName;
78
+        }
77 79
 
78 80
         if (($this->_openSHPFile(TRUE)) && ($this->_openSHXFile(TRUE)) && ($this->_openDBFFile(TRUE))) {
79 81
             $this->_saveHeaders();
@@ -95,20 +97,36 @@  discard block
 block discarded – undo
95 97
         $this->records[] = $record;
96 98
         $this->records[count($this->records) - 1]->recordNumber = count($this->records);
97 99
 
98
-        if ($this->boundingBox["xmin"]==0.0 || ($this->boundingBox["xmin"]>$record->SHPData["xmin"])) $this->boundingBox["xmin"] = $record->SHPData["xmin"];
99
-        if ($this->boundingBox["xmax"]==0.0 || ($this->boundingBox["xmax"]<$record->SHPData["xmax"])) $this->boundingBox["xmax"] = $record->SHPData["xmax"];
100
+        if ($this->boundingBox["xmin"]==0.0 || ($this->boundingBox["xmin"]>$record->SHPData["xmin"])) {
101
+            $this->boundingBox["xmin"] = $record->SHPData["xmin"];
102
+        }
103
+        if ($this->boundingBox["xmax"]==0.0 || ($this->boundingBox["xmax"]<$record->SHPData["xmax"])) {
104
+            $this->boundingBox["xmax"] = $record->SHPData["xmax"];
105
+        }
100 106
 
101
-        if ($this->boundingBox["ymin"]==0.0 || ($this->boundingBox["ymin"]>$record->SHPData["ymin"])) $this->boundingBox["ymin"] = $record->SHPData["ymin"];
102
-        if ($this->boundingBox["ymax"]==0.0 || ($this->boundingBox["ymax"]<$record->SHPData["ymax"])) $this->boundingBox["ymax"] = $record->SHPData["ymax"];
107
+        if ($this->boundingBox["ymin"]==0.0 || ($this->boundingBox["ymin"]>$record->SHPData["ymin"])) {
108
+            $this->boundingBox["ymin"] = $record->SHPData["ymin"];
109
+        }
110
+        if ($this->boundingBox["ymax"]==0.0 || ($this->boundingBox["ymax"]<$record->SHPData["ymax"])) {
111
+            $this->boundingBox["ymax"] = $record->SHPData["ymax"];
112
+        }
103 113
 
104 114
         if (in_array($this->shapeType,array(11,13,15,18,21,23,25,28))) {
105
-            if (!isset($this->boundingBox["mmin"]) || $this->boundingBox["mmin"]==0.0 || ($this->boundingBox["mmin"]>$record->SHPData["mmin"])) $this->boundingBox["mmin"] = $record->SHPData["mmin"];
106
-            if (!isset($this->boundingBox["mmax"]) || $this->boundingBox["mmax"]==0.0 || ($this->boundingBox["mmax"]<$record->SHPData["mmax"])) $this->boundingBox["mmax"] = $record->SHPData["mmax"];
115
+            if (!isset($this->boundingBox["mmin"]) || $this->boundingBox["mmin"]==0.0 || ($this->boundingBox["mmin"]>$record->SHPData["mmin"])) {
116
+                $this->boundingBox["mmin"] = $record->SHPData["mmin"];
117
+            }
118
+            if (!isset($this->boundingBox["mmax"]) || $this->boundingBox["mmax"]==0.0 || ($this->boundingBox["mmax"]<$record->SHPData["mmax"])) {
119
+                $this->boundingBox["mmax"] = $record->SHPData["mmax"];
120
+            }
107 121
         }
108 122
 
109 123
         if (in_array($this->shapeType,array(11,13,15,18))) {
110
-            if (!isset($this->boundingBox["zmin"]) || $this->boundingBox["zmin"]==0.0 || ($this->boundingBox["zmin"]>$record->SHPData["zmin"])) $this->boundingBox["zmin"] = $record->SHPData["zmin"];
111
-            if (!isset($this->boundingBox["zmax"]) || $this->boundingBox["zmax"]==0.0 || ($this->boundingBox["zmax"]<$record->SHPData["zmax"])) $this->boundingBox["zmax"] = $record->SHPData["zmax"];
124
+            if (!isset($this->boundingBox["zmin"]) || $this->boundingBox["zmin"]==0.0 || ($this->boundingBox["zmin"]>$record->SHPData["zmin"])) {
125
+                $this->boundingBox["zmin"] = $record->SHPData["zmin"];
126
+            }
127
+            if (!isset($this->boundingBox["zmax"]) || $this->boundingBox["zmax"]==0.0 || ($this->boundingBox["zmax"]<$record->SHPData["zmax"])) {
128
+                $this->boundingBox["zmax"] = $record->SHPData["zmax"];
129
+            }
112 130
         }
113 131
 
114 132
         return (count($this->records) - 1);
Please login to merge, or discard this patch.
src/ShapeRecord.php 3 patches
Doc Comments   +18 added lines patch added patch discarded remove patch
@@ -42,6 +42,9 @@  discard block
 block discarded – undo
42 42
     var $SHPData = array();
43 43
     var $DBFData = array();
44 44
 
45
+    /**
46
+     * @param integer $shapeType
47
+     */
45 48
     public function __construct($shapeType) {
46 49
       $this->shapeType = $shapeType;
47 50
     }
@@ -275,6 +278,9 @@  discard block
 block discarded – undo
275 278
       }
276 279
     }
277 280
 
281
+    /**
282
+     * @param string $type
283
+     */
278 284
     function _loadMultiPointMZRecord( $type ) {
279 285
 
280 286
       $this->SHPData[$type."min"] = Util::loadData("d", fread($this->SHPFile, 8));
@@ -308,6 +314,9 @@  discard block
 block discarded – undo
308 314
       }
309 315
     }
310 316
 
317
+    /**
318
+     * @param string $type
319
+     */
311 320
     function _saveMultiPointMZRecord( $type ) {
312 321
 
313 322
       fwrite($this->SHPFile, pack("dd", $this->SHPData[$type."min"], $this->SHPData[$type."max"]));
@@ -361,6 +370,9 @@  discard block
 block discarded – undo
361 370
       fseek($this->SHPFile, $firstIndex + ($readPoints*16));
362 371
     }
363 372
 
373
+    /**
374
+     * @param string $type
375
+     */
364 376
     function _loadPolyLineMZRecord( $type ) {
365 377
 
366 378
       $this->SHPData[$type."min"] = Util::loadData("d", fread($this->SHPFile, 8));
@@ -409,6 +421,9 @@  discard block
 block discarded – undo
409 421
       }
410 422
     }
411 423
 
424
+    /**
425
+     * @param string $type
426
+     */
412 427
     function _savePolyLineMZRecord( $type ) {
413 428
       fwrite($this->SHPFile, pack("dd", $this->SHPData[$type."min"], $this->SHPData[$type."max"]));
414 429
 
@@ -641,6 +656,9 @@  discard block
 block discarded – undo
641 656
       }
642 657
     }
643 658
 
659
+    /**
660
+     * @param string $error
661
+     */
644 662
     function setError($error) {
645 663
       $this->lastError = $error;
646 664
       return false;
Please login to merge, or discard this patch.
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
         }
276 276
     }
277 277
 
278
-    private function _loadMultiPointMZRecord( $type ) {
278
+    private function _loadMultiPointMZRecord($type) {
279 279
 
280 280
         $this->SHPData[$type."min"] = Util::loadData("d", fread($this->SHPFile, 8));
281 281
         $this->SHPData[$type."max"] = Util::loadData("d", fread($this->SHPFile, 8));
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
         }
309 309
     }
310 310
 
311
-    private function _saveMultiPointMZRecord( $type ) {
311
+    private function _saveMultiPointMZRecord($type) {
312 312
 
313 313
         fwrite($this->SHPFile, pack("dd", $this->SHPData[$type."min"], $this->SHPData[$type."max"]));
314 314
 
@@ -358,10 +358,10 @@  discard block
 block discarded – undo
358 358
             }
359 359
         }
360 360
 
361
-        fseek($this->SHPFile, $firstIndex + ($readPoints*16));
361
+        fseek($this->SHPFile, $firstIndex + ($readPoints * 16));
362 362
     }
363 363
 
364
-    private function _loadPolyLineMZRecord( $type ) {
364
+    private function _loadPolyLineMZRecord($type) {
365 365
 
366 366
         $this->SHPData[$type."min"] = Util::loadData("d", fread($this->SHPFile, 8));
367 367
         $this->SHPData[$type."max"] = Util::loadData("d", fread($this->SHPFile, 8));
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
             }
377 377
         }
378 378
 
379
-        fseek($this->SHPFile, $firstIndex + ($readPoints*24));
379
+        fseek($this->SHPFile, $firstIndex + ($readPoints * 24));
380 380
     }
381 381
 
382 382
     private function _loadPolyLineMRecord() {
@@ -398,10 +398,10 @@  discard block
 block discarded – undo
398 398
         fwrite($this->SHPFile, pack("VV", $this->SHPData["numparts"], $this->SHPData["numpoints"]));
399 399
 
400 400
         for ($i = 0; $i < $this->SHPData["numparts"]; $i++) {
401
-            fwrite($this->SHPFile, pack("V", count($this->SHPData["parts"][$i])-1));
401
+            fwrite($this->SHPFile, pack("V", count($this->SHPData["parts"][$i]) - 1));
402 402
         }
403 403
 
404
-        foreach ($this->SHPData["parts"] as $partData){
404
+        foreach ($this->SHPData["parts"] as $partData) {
405 405
             reset($partData["points"]);
406 406
             while (list($pointIndex, $pointData) = each($partData["points"])) {
407 407
                 $this->_savePoint($pointData);
@@ -409,10 +409,10 @@  discard block
 block discarded – undo
409 409
         }
410 410
     }
411 411
 
412
-    private function _savePolyLineMZRecord( $type ) {
412
+    private function _savePolyLineMZRecord($type) {
413 413
         fwrite($this->SHPFile, pack("dd", $this->SHPData[$type."min"], $this->SHPData[$type."max"]));
414 414
 
415
-        foreach ($this->SHPData["parts"] as $partData){
415
+        foreach ($this->SHPData["parts"] as $partData) {
416 416
             reset($partData["points"]);
417 417
             while (list($pointIndex, $pointData) = each($partData["points"])) {
418 418
                 fwrite($this->SHPFile, Util::packDouble($pointData[$type]));
@@ -465,8 +465,8 @@  discard block
 block discarded – undo
465 465
             case 1:
466 466
             case 11:
467 467
             case 21:
468
-                if (in_array($this->shapeType,array(11,21)) && !isset($point["m"])) $point["m"] = 0.0; // no_value
469
-                if (in_array($this->shapeType,array(11)) && !isset($point["z"])) $point["z"] = 0.0; // no_value
468
+                if (in_array($this->shapeType, array(11, 21)) && !isset($point["m"])) $point["m"] = 0.0; // no_value
469
+                if (in_array($this->shapeType, array(11)) && !isset($point["z"])) $point["z"] = 0.0; // no_value
470 470
                 //Substitutes the value of the current point
471 471
                 $this->SHPData = $point;
472 472
                 break;
@@ -476,8 +476,8 @@  discard block
 block discarded – undo
476 476
             case 15:
477 477
             case 23:
478 478
             case 25:
479
-                if (in_array($this->shapeType,array(13,15,23,25)) && !isset($point["m"])) $point["m"] = 0.0; // no_value
480
-                if (in_array($this->shapeType,array(13,15)) && !isset($point["z"])) $point["z"] = 0.0; // no_value
479
+                if (in_array($this->shapeType, array(13, 15, 23, 25)) && !isset($point["m"])) $point["m"] = 0.0; // no_value
480
+                if (in_array($this->shapeType, array(13, 15)) && !isset($point["z"])) $point["z"] = 0.0; // no_value
481 481
 
482 482
                 //Adds a new point to the selected part
483 483
                 if (!isset($this->SHPData["xmin"]) || ($this->SHPData["xmin"] > $point["x"])) $this->SHPData["xmin"] = $point["x"];
@@ -492,13 +492,13 @@  discard block
 block discarded – undo
492 492
                 $this->SHPData["parts"][$partIndex]["points"][] = $point;
493 493
 
494 494
                 $this->SHPData["numparts"] = count($this->SHPData["parts"]);
495
-                $this->SHPData["numpoints"] = 1 + (isset($this->SHPData["numpoints"])?$this->SHPData["numpoints"]:0);
495
+                $this->SHPData["numpoints"] = 1 + (isset($this->SHPData["numpoints"]) ? $this->SHPData["numpoints"] : 0);
496 496
                 break;
497 497
             case 8:
498 498
             case 18:
499 499
             case 28:
500
-                if (in_array($this->shapeType,array(18,28)) && !isset($point["m"])) $point["m"] = 0.0; // no_value
501
-                if (in_array($this->shapeType,array(18)) && !isset($point["z"])) $point["z"] = 0.0; // no_value
500
+                if (in_array($this->shapeType, array(18, 28)) && !isset($point["m"])) $point["m"] = 0.0; // no_value
501
+                if (in_array($this->shapeType, array(18)) && !isset($point["z"])) $point["z"] = 0.0; // no_value
502 502
 
503 503
                 //Adds a new point
504 504
                 if (!isset($this->SHPData["xmin"]) || ($this->SHPData["xmin"] > $point["x"])) $this->SHPData["xmin"] = $point["x"];
@@ -511,7 +511,7 @@  discard block
 block discarded – undo
511 511
                 if (isset($point["z"]) && (!isset($this->SHPData["zmax"]) || ($this->SHPData["zmax"] < $point["z"]))) $this->SHPData["zmax"] = $point["z"];
512 512
 
513 513
                 $this->SHPData["points"][] = $point;
514
-                $this->SHPData["numpoints"] = 1 + (isset($this->SHPData["numpoints"])?$this->SHPData["numpoints"]:0);
514
+                $this->SHPData["numpoints"] = 1 + (isset($this->SHPData["numpoints"]) ? $this->SHPData["numpoints"] : 0);
515 515
                 break;
516 516
             default:
517 517
                 $this->setError(sprintf("The Shape Type '%s' is not supported.", $this->shapeType));
@@ -530,8 +530,8 @@  discard block
 block discarded – undo
530 530
                 //Sets the value of the point to zero
531 531
                 $this->SHPData["x"] = 0.0;
532 532
                 $this->SHPData["y"] = 0.0;
533
-                if (in_array($this->shapeType,array(11,21))) $this->SHPData["m"] = 0.0;
534
-                if (in_array($this->shapeType,array(11))) $this->SHPData["z"] = 0.0;
533
+                if (in_array($this->shapeType, array(11, 21))) $this->SHPData["m"] = 0.0;
534
+                if (in_array($this->shapeType, array(11))) $this->SHPData["z"] = 0.0;
535 535
                 break;
536 536
             case 3:
537 537
             case 5:
@@ -587,33 +587,33 @@  discard block
 block discarded – undo
587 587
                 break;
588 588
             case 3:
589 589
             case 5:
590
-                $result = 22 + 2*count($this->SHPData["parts"]);
590
+                $result = 22 + 2 * count($this->SHPData["parts"]);
591 591
                 for ($i = 0; $i < count($this->SHPData["parts"]); $i++) {
592
-                    $result += 8*count($this->SHPData["parts"][$i]["points"]);
592
+                    $result += 8 * count($this->SHPData["parts"][$i]["points"]);
593 593
                 }
594 594
                 break;
595 595
             case 23:
596 596
             case 25:
597
-                $result = 22 + (2*4) + 2*count($this->SHPData["parts"]);
597
+                $result = 22 + (2 * 4) + 2 * count($this->SHPData["parts"]);
598 598
                 for ($i = 0; $i < count($this->SHPData["parts"]); $i++) {
599
-                    $result += (8+4)*count($this->SHPData["parts"][$i]["points"]);
599
+                    $result += (8 + 4) * count($this->SHPData["parts"][$i]["points"]);
600 600
                 }
601 601
                 break;
602 602
             case 13:
603 603
             case 15:
604
-                $result = 22 + (4*4) + 2*count($this->SHPData["parts"]);
604
+                $result = 22 + (4 * 4) + 2 * count($this->SHPData["parts"]);
605 605
                 for ($i = 0; $i < count($this->SHPData["parts"]); $i++) {
606
-                    $result += (8+8)*count($this->SHPData["parts"][$i]["points"]);
606
+                    $result += (8 + 8) * count($this->SHPData["parts"][$i]["points"]);
607 607
                 }
608 608
                 break;
609 609
             case 8:
610
-                $result = 20 + 8*count($this->SHPData["points"]);
610
+                $result = 20 + 8 * count($this->SHPData["points"]);
611 611
                 break;
612 612
             case 28:
613
-                $result = 20 + (2*4) + (8+4)*count($this->SHPData["points"]);
613
+                $result = 20 + (2 * 4) + (8 + 4) * count($this->SHPData["points"]);
614 614
                 break;
615 615
             case 18:
616
-                $result = 20 + (4*4) + (8+8)*count($this->SHPData["points"]);
616
+                $result = 20 + (4 * 4) + (8 + 8) * count($this->SHPData["points"]);
617 617
                 break;
618 618
             default:
619 619
                 $result = false;
Please login to merge, or discard this patch.
Braces   +78 added lines, -24 removed lines patch added patch discarded remove patch
@@ -465,8 +465,14 @@  discard block
 block discarded – undo
465 465
             case 1:
466 466
             case 11:
467 467
             case 21:
468
-                if (in_array($this->shapeType,array(11,21)) && !isset($point["m"])) $point["m"] = 0.0; // no_value
469
-                if (in_array($this->shapeType,array(11)) && !isset($point["z"])) $point["z"] = 0.0; // no_value
468
+                if (in_array($this->shapeType,array(11,21)) && !isset($point["m"])) {
469
+                    $point["m"] = 0.0;
470
+                }
471
+                // no_value
472
+                if (in_array($this->shapeType,array(11)) && !isset($point["z"])) {
473
+                    $point["z"] = 0.0;
474
+                }
475
+                // no_value
470 476
                 //Substitutes the value of the current point
471 477
                 $this->SHPData = $point;
472 478
                 break;
@@ -476,18 +482,40 @@  discard block
 block discarded – undo
476 482
             case 15:
477 483
             case 23:
478 484
             case 25:
479
-                if (in_array($this->shapeType,array(13,15,23,25)) && !isset($point["m"])) $point["m"] = 0.0; // no_value
480
-                if (in_array($this->shapeType,array(13,15)) && !isset($point["z"])) $point["z"] = 0.0; // no_value
485
+                if (in_array($this->shapeType,array(13,15,23,25)) && !isset($point["m"])) {
486
+                    $point["m"] = 0.0;
487
+                }
488
+                // no_value
489
+                if (in_array($this->shapeType,array(13,15)) && !isset($point["z"])) {
490
+                    $point["z"] = 0.0;
491
+                }
492
+                // no_value
481 493
 
482 494
                 //Adds a new point to the selected part
483
-                if (!isset($this->SHPData["xmin"]) || ($this->SHPData["xmin"] > $point["x"])) $this->SHPData["xmin"] = $point["x"];
484
-                if (!isset($this->SHPData["ymin"]) || ($this->SHPData["ymin"] > $point["y"])) $this->SHPData["ymin"] = $point["y"];
485
-                if (isset($point["m"]) && (!isset($this->SHPData["mmin"]) || ($this->SHPData["mmin"] > $point["m"]))) $this->SHPData["mmin"] = $point["m"];
486
-                if (isset($point["z"]) && (!isset($this->SHPData["zmin"]) || ($this->SHPData["zmin"] > $point["z"]))) $this->SHPData["zmin"] = $point["z"];
487
-                if (!isset($this->SHPData["xmax"]) || ($this->SHPData["xmax"] < $point["x"])) $this->SHPData["xmax"] = $point["x"];
488
-                if (!isset($this->SHPData["ymax"]) || ($this->SHPData["ymax"] < $point["y"])) $this->SHPData["ymax"] = $point["y"];
489
-                if (isset($point["m"]) && (!isset($this->SHPData["mmax"]) || ($this->SHPData["mmax"] < $point["m"]))) $this->SHPData["mmax"] = $point["m"];
490
-                if (isset($point["z"]) && (!isset($this->SHPData["zmax"]) || ($this->SHPData["zmax"] < $point["z"]))) $this->SHPData["zmax"] = $point["z"];
495
+                if (!isset($this->SHPData["xmin"]) || ($this->SHPData["xmin"] > $point["x"])) {
496
+                    $this->SHPData["xmin"] = $point["x"];
497
+                }
498
+                if (!isset($this->SHPData["ymin"]) || ($this->SHPData["ymin"] > $point["y"])) {
499
+                    $this->SHPData["ymin"] = $point["y"];
500
+                }
501
+                if (isset($point["m"]) && (!isset($this->SHPData["mmin"]) || ($this->SHPData["mmin"] > $point["m"]))) {
502
+                    $this->SHPData["mmin"] = $point["m"];
503
+                }
504
+                if (isset($point["z"]) && (!isset($this->SHPData["zmin"]) || ($this->SHPData["zmin"] > $point["z"]))) {
505
+                    $this->SHPData["zmin"] = $point["z"];
506
+                }
507
+                if (!isset($this->SHPData["xmax"]) || ($this->SHPData["xmax"] < $point["x"])) {
508
+                    $this->SHPData["xmax"] = $point["x"];
509
+                }
510
+                if (!isset($this->SHPData["ymax"]) || ($this->SHPData["ymax"] < $point["y"])) {
511
+                    $this->SHPData["ymax"] = $point["y"];
512
+                }
513
+                if (isset($point["m"]) && (!isset($this->SHPData["mmax"]) || ($this->SHPData["mmax"] < $point["m"]))) {
514
+                    $this->SHPData["mmax"] = $point["m"];
515
+                }
516
+                if (isset($point["z"]) && (!isset($this->SHPData["zmax"]) || ($this->SHPData["zmax"] < $point["z"]))) {
517
+                    $this->SHPData["zmax"] = $point["z"];
518
+                }
491 519
 
492 520
                 $this->SHPData["parts"][$partIndex]["points"][] = $point;
493 521
 
@@ -497,18 +525,40 @@  discard block
 block discarded – undo
497 525
             case 8:
498 526
             case 18:
499 527
             case 28:
500
-                if (in_array($this->shapeType,array(18,28)) && !isset($point["m"])) $point["m"] = 0.0; // no_value
501
-                if (in_array($this->shapeType,array(18)) && !isset($point["z"])) $point["z"] = 0.0; // no_value
528
+                if (in_array($this->shapeType,array(18,28)) && !isset($point["m"])) {
529
+                    $point["m"] = 0.0;
530
+                }
531
+                // no_value
532
+                if (in_array($this->shapeType,array(18)) && !isset($point["z"])) {
533
+                    $point["z"] = 0.0;
534
+                }
535
+                // no_value
502 536
 
503 537
                 //Adds a new point
504
-                if (!isset($this->SHPData["xmin"]) || ($this->SHPData["xmin"] > $point["x"])) $this->SHPData["xmin"] = $point["x"];
505
-                if (!isset($this->SHPData["ymin"]) || ($this->SHPData["ymin"] > $point["y"])) $this->SHPData["ymin"] = $point["y"];
506
-                if (isset($point["m"]) && (!isset($this->SHPData["mmin"]) || ($this->SHPData["mmin"] > $point["m"]))) $this->SHPData["mmin"] = $point["m"];
507
-                if (isset($point["z"]) && (!isset($this->SHPData["zmin"]) || ($this->SHPData["zmin"] > $point["z"]))) $this->SHPData["zmin"] = $point["z"];
508
-                if (!isset($this->SHPData["xmax"]) || ($this->SHPData["xmax"] < $point["x"])) $this->SHPData["xmax"] = $point["x"];
509
-                if (!isset($this->SHPData["ymax"]) || ($this->SHPData["ymax"] < $point["y"])) $this->SHPData["ymax"] = $point["y"];
510
-                if (isset($point["m"]) && (!isset($this->SHPData["mmax"]) || ($this->SHPData["mmax"] < $point["m"]))) $this->SHPData["mmax"] = $point["m"];
511
-                if (isset($point["z"]) && (!isset($this->SHPData["zmax"]) || ($this->SHPData["zmax"] < $point["z"]))) $this->SHPData["zmax"] = $point["z"];
538
+                if (!isset($this->SHPData["xmin"]) || ($this->SHPData["xmin"] > $point["x"])) {
539
+                    $this->SHPData["xmin"] = $point["x"];
540
+                }
541
+                if (!isset($this->SHPData["ymin"]) || ($this->SHPData["ymin"] > $point["y"])) {
542
+                    $this->SHPData["ymin"] = $point["y"];
543
+                }
544
+                if (isset($point["m"]) && (!isset($this->SHPData["mmin"]) || ($this->SHPData["mmin"] > $point["m"]))) {
545
+                    $this->SHPData["mmin"] = $point["m"];
546
+                }
547
+                if (isset($point["z"]) && (!isset($this->SHPData["zmin"]) || ($this->SHPData["zmin"] > $point["z"]))) {
548
+                    $this->SHPData["zmin"] = $point["z"];
549
+                }
550
+                if (!isset($this->SHPData["xmax"]) || ($this->SHPData["xmax"] < $point["x"])) {
551
+                    $this->SHPData["xmax"] = $point["x"];
552
+                }
553
+                if (!isset($this->SHPData["ymax"]) || ($this->SHPData["ymax"] < $point["y"])) {
554
+                    $this->SHPData["ymax"] = $point["y"];
555
+                }
556
+                if (isset($point["m"]) && (!isset($this->SHPData["mmax"]) || ($this->SHPData["mmax"] < $point["m"]))) {
557
+                    $this->SHPData["mmax"] = $point["m"];
558
+                }
559
+                if (isset($point["z"]) && (!isset($this->SHPData["zmax"]) || ($this->SHPData["zmax"] < $point["z"]))) {
560
+                    $this->SHPData["zmax"] = $point["z"];
561
+                }
512 562
 
513 563
                 $this->SHPData["points"][] = $point;
514 564
                 $this->SHPData["numpoints"] = 1 + (isset($this->SHPData["numpoints"])?$this->SHPData["numpoints"]:0);
@@ -530,8 +580,12 @@  discard block
 block discarded – undo
530 580
                 //Sets the value of the point to zero
531 581
                 $this->SHPData["x"] = 0.0;
532 582
                 $this->SHPData["y"] = 0.0;
533
-                if (in_array($this->shapeType,array(11,21))) $this->SHPData["m"] = 0.0;
534
-                if (in_array($this->shapeType,array(11))) $this->SHPData["z"] = 0.0;
583
+                if (in_array($this->shapeType,array(11,21))) {
584
+                    $this->SHPData["m"] = 0.0;
585
+                }
586
+                if (in_array($this->shapeType,array(11))) {
587
+                    $this->SHPData["z"] = 0.0;
588
+                }
535 589
                 break;
536 590
             case 3:
537 591
             case 5:
Please login to merge, or discard this patch.
src/Util.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 
40 40
     public static function swap($binValue) {
41 41
         $result = $binValue{strlen($binValue) - 1};
42
-        for($i = strlen($binValue) - 2; $i >= 0 ; $i--) {
42
+        for ($i = strlen($binValue) - 2; $i >= 0; $i--) {
43 43
             $result .= $binValue{$i};
44 44
         }
45 45
 
@@ -47,15 +47,15 @@  discard block
 block discarded – undo
47 47
     }
48 48
 
49 49
     public static function packDouble($value, $mode = 'LE') {
50
-        $value = (double)$value;
50
+        $value = (double) $value;
51 51
         $bin = pack("d", $value);
52 52
 
53 53
         //We test if the conversion of an integer (1) is done as LE or BE by default
54
-        switch (pack ('L', 1)) {
55
-            case pack ('V', 1): //Little Endian
54
+        switch (pack('L', 1)) {
55
+            case pack('V', 1): //Little Endian
56 56
                 $result = ($mode == 'LE') ? $bin : self::swap($bin);
57 57
                 break;
58
-            case pack ('N', 1): //Big Endian
58
+            case pack('N', 1): //Big Endian
59 59
                 $result = ($mode == 'BE') ? $bin : self::swap($bin);
60 60
                 break;
61 61
             default: //Some other thing, we just return false
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -32,7 +32,9 @@
 block discarded – undo
32 32
 
33 33
 class Util {
34 34
     public static function loadData($type, $data) {
35
-        if (!$data) return $data;
35
+        if (!$data) {
36
+            return $data;
37
+        }
36 38
         $tmp = unpack($type, $data);
37 39
         return current($tmp);
38 40
     }
Please login to merge, or discard this patch.
examples/read_polygon.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -7,14 +7,14 @@
 block discarded – undo
7 7
 $shp->loadFromFile('../data/mexico.*');
8 8
 
9 9
 $i = 1;
10
-foreach ($shp->records as $record){
10
+foreach ($shp->records as $record) {
11 11
     echo "<pre>";
12 12
     echo "Record No. $i:\n\n\n";
13 13
     echo "SHP Data = ";
14
-    print_r($record->SHPData);   //All the data related to the poligon
14
+    print_r($record->SHPData); //All the data related to the poligon
15 15
     print_r("\n\n\n");
16 16
     echo "DBF Data = ";
17
-    print_r($record->DBFData);   //All the information related to each poligon
17
+    print_r($record->DBFData); //All the information related to each poligon
18 18
     print_r("\n\n\n");
19 19
     echo "</pre>";
20 20
     $i++;
Please login to merge, or discard this patch.
examples/read_point.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -7,14 +7,14 @@
 block discarded – undo
7 7
 $shp->loadFromFile('../data/capitals.*');
8 8
 
9 9
 $i = 1;
10
-foreach ($shp->records as $record){
10
+foreach ($shp->records as $record) {
11 11
     echo "<pre>";
12 12
     echo "Record No. $i:\n\n\n";
13 13
     echo "SHP Data = ";
14
-    print_r($record->SHPData);   //All the data related to the point
14
+    print_r($record->SHPData); //All the data related to the point
15 15
     print_r("\n\n\n");
16 16
     echo "DBF Data = ";
17
-    print_r($record->DBFData);   //All the information related to each point
17
+    print_r($record->DBFData); //All the information related to each point
18 18
     print_r("\n\n\n");
19 19
     echo "</pre>";
20 20
     $i++;
Please login to merge, or discard this patch.