Completed
Push — master ( a99ae2...001830 )
by Michal
03:26
created
src/ShapeFile.lib.php 1 patch
Braces   +108 added lines, -34 removed lines patch added patch discarded remove patch
@@ -29,7 +29,9 @@  discard block
 block discarded – undo
29 29
  *
30 30
  */
31 31
   function loadData($type, $data) {
32
-    if (!$data) return $data;
32
+    if (!$data) {
33
+       return $data;
34
+    }
33 35
     $tmp = unpack($type, $data);
34 36
     return current($tmp);
35 37
   }
@@ -105,7 +107,9 @@  discard block
 block discarded – undo
105 107
     }
106 108
 
107 109
     function saveToFile($FileName = NULL) {
108
-      if ($FileName != NULL) $this->FileName = $FileName;
110
+      if ($FileName != NULL) {
111
+         $this->FileName = $FileName;
112
+      }
109 113
 
110 114
       if (($this->_openSHPFile(TRUE)) && ($this->_openSHXFile(TRUE)) && ($this->_openDBFFile(TRUE))) {
111 115
         $this->_saveHeaders();
@@ -127,20 +131,36 @@  discard block
 block discarded – undo
127 131
       $this->records[] = $record;
128 132
       $this->records[count($this->records) - 1]->recordNumber = count($this->records);
129 133
 
130
-      if ($this->boundingBox["xmin"]==0.0 || ($this->boundingBox["xmin"]>$record->SHPData["xmin"])) $this->boundingBox["xmin"] = $record->SHPData["xmin"];
131
-      if ($this->boundingBox["xmax"]==0.0 || ($this->boundingBox["xmax"]<$record->SHPData["xmax"])) $this->boundingBox["xmax"] = $record->SHPData["xmax"];
134
+      if ($this->boundingBox["xmin"]==0.0 || ($this->boundingBox["xmin"]>$record->SHPData["xmin"])) {
135
+         $this->boundingBox["xmin"] = $record->SHPData["xmin"];
136
+      }
137
+      if ($this->boundingBox["xmax"]==0.0 || ($this->boundingBox["xmax"]<$record->SHPData["xmax"])) {
138
+         $this->boundingBox["xmax"] = $record->SHPData["xmax"];
139
+      }
132 140
 
133
-      if ($this->boundingBox["ymin"]==0.0 || ($this->boundingBox["ymin"]>$record->SHPData["ymin"])) $this->boundingBox["ymin"] = $record->SHPData["ymin"];
134
-      if ($this->boundingBox["ymax"]==0.0 || ($this->boundingBox["ymax"]<$record->SHPData["ymax"])) $this->boundingBox["ymax"] = $record->SHPData["ymax"];
141
+      if ($this->boundingBox["ymin"]==0.0 || ($this->boundingBox["ymin"]>$record->SHPData["ymin"])) {
142
+         $this->boundingBox["ymin"] = $record->SHPData["ymin"];
143
+      }
144
+      if ($this->boundingBox["ymax"]==0.0 || ($this->boundingBox["ymax"]<$record->SHPData["ymax"])) {
145
+         $this->boundingBox["ymax"] = $record->SHPData["ymax"];
146
+      }
135 147
 
136 148
       if (in_array($this->shapeType,array(11,13,15,18,21,23,25,28))) {
137
-        if (!isset($this->boundingBox["mmin"]) || $this->boundingBox["mmin"]==0.0 || ($this->boundingBox["mmin"]>$record->SHPData["mmin"])) $this->boundingBox["mmin"] = $record->SHPData["mmin"];
138
-        if (!isset($this->boundingBox["mmax"]) || $this->boundingBox["mmax"]==0.0 || ($this->boundingBox["mmax"]<$record->SHPData["mmax"])) $this->boundingBox["mmax"] = $record->SHPData["mmax"];
149
+        if (!isset($this->boundingBox["mmin"]) || $this->boundingBox["mmin"]==0.0 || ($this->boundingBox["mmin"]>$record->SHPData["mmin"])) {
150
+           $this->boundingBox["mmin"] = $record->SHPData["mmin"];
151
+        }
152
+        if (!isset($this->boundingBox["mmax"]) || $this->boundingBox["mmax"]==0.0 || ($this->boundingBox["mmax"]<$record->SHPData["mmax"])) {
153
+           $this->boundingBox["mmax"] = $record->SHPData["mmax"];
154
+        }
139 155
       }
140 156
 
141 157
       if (in_array($this->shapeType,array(11,13,15,18))) {
142
-        if (!isset($this->boundingBox["zmin"]) || $this->boundingBox["zmin"]==0.0 || ($this->boundingBox["zmin"]>$record->SHPData["zmin"])) $this->boundingBox["zmin"] = $record->SHPData["zmin"];
143
-        if (!isset($this->boundingBox["zmax"]) || $this->boundingBox["zmax"]==0.0 || ($this->boundingBox["zmax"]<$record->SHPData["zmax"])) $this->boundingBox["zmax"] = $record->SHPData["zmax"];
158
+        if (!isset($this->boundingBox["zmin"]) || $this->boundingBox["zmin"]==0.0 || ($this->boundingBox["zmin"]>$record->SHPData["zmin"])) {
159
+           $this->boundingBox["zmin"] = $record->SHPData["zmin"];
160
+        }
161
+        if (!isset($this->boundingBox["zmax"]) || $this->boundingBox["zmax"]==0.0 || ($this->boundingBox["zmax"]<$record->SHPData["zmax"])) {
162
+           $this->boundingBox["zmax"] = $record->SHPData["zmax"];
163
+        }
144 164
       }
145 165
 
146 166
       return (count($this->records) - 1);
@@ -807,8 +827,14 @@  discard block
 block discarded – undo
807 827
         case 1:
808 828
         case 11:
809 829
         case 21:
810
-          if (in_array($this->shapeType,array(11,21)) && !isset($point["m"])) $point["m"] = 0.0; // no_value
811
-          if (in_array($this->shapeType,array(11)) && !isset($point["z"])) $point["z"] = 0.0; // no_value
830
+          if (in_array($this->shapeType,array(11,21)) && !isset($point["m"])) {
831
+             $point["m"] = 0.0;
832
+          }
833
+          // no_value
834
+          if (in_array($this->shapeType,array(11)) && !isset($point["z"])) {
835
+             $point["z"] = 0.0;
836
+          }
837
+          // no_value
812 838
           //Substitutes the value of the current point
813 839
           $this->SHPData = $point;
814 840
         break;
@@ -818,18 +844,40 @@  discard block
 block discarded – undo
818 844
         case 15:
819 845
         case 23:
820 846
         case 25:
821
-          if (in_array($this->shapeType,array(13,15,23,25)) && !isset($point["m"])) $point["m"] = 0.0; // no_value
822
-          if (in_array($this->shapeType,array(13,15)) && !isset($point["z"])) $point["z"] = 0.0; // no_value
847
+          if (in_array($this->shapeType,array(13,15,23,25)) && !isset($point["m"])) {
848
+             $point["m"] = 0.0;
849
+          }
850
+          // no_value
851
+          if (in_array($this->shapeType,array(13,15)) && !isset($point["z"])) {
852
+             $point["z"] = 0.0;
853
+          }
854
+          // no_value
823 855
 
824 856
           //Adds a new point to the selected part
825
-          if (!isset($this->SHPData["xmin"]) || ($this->SHPData["xmin"] > $point["x"])) $this->SHPData["xmin"] = $point["x"];
826
-          if (!isset($this->SHPData["ymin"]) || ($this->SHPData["ymin"] > $point["y"])) $this->SHPData["ymin"] = $point["y"];
827
-          if (isset($point["m"]) && (!isset($this->SHPData["mmin"]) || ($this->SHPData["mmin"] > $point["m"]))) $this->SHPData["mmin"] = $point["m"];
828
-          if (isset($point["z"]) && (!isset($this->SHPData["zmin"]) || ($this->SHPData["zmin"] > $point["z"]))) $this->SHPData["zmin"] = $point["z"];
829
-          if (!isset($this->SHPData["xmax"]) || ($this->SHPData["xmax"] < $point["x"])) $this->SHPData["xmax"] = $point["x"];
830
-          if (!isset($this->SHPData["ymax"]) || ($this->SHPData["ymax"] < $point["y"])) $this->SHPData["ymax"] = $point["y"];
831
-          if (isset($point["m"]) && (!isset($this->SHPData["mmax"]) || ($this->SHPData["mmax"] < $point["m"]))) $this->SHPData["mmax"] = $point["m"];
832
-          if (isset($point["z"]) && (!isset($this->SHPData["zmax"]) || ($this->SHPData["zmax"] < $point["z"]))) $this->SHPData["zmax"] = $point["z"];
857
+          if (!isset($this->SHPData["xmin"]) || ($this->SHPData["xmin"] > $point["x"])) {
858
+             $this->SHPData["xmin"] = $point["x"];
859
+          }
860
+          if (!isset($this->SHPData["ymin"]) || ($this->SHPData["ymin"] > $point["y"])) {
861
+             $this->SHPData["ymin"] = $point["y"];
862
+          }
863
+          if (isset($point["m"]) && (!isset($this->SHPData["mmin"]) || ($this->SHPData["mmin"] > $point["m"]))) {
864
+             $this->SHPData["mmin"] = $point["m"];
865
+          }
866
+          if (isset($point["z"]) && (!isset($this->SHPData["zmin"]) || ($this->SHPData["zmin"] > $point["z"]))) {
867
+             $this->SHPData["zmin"] = $point["z"];
868
+          }
869
+          if (!isset($this->SHPData["xmax"]) || ($this->SHPData["xmax"] < $point["x"])) {
870
+             $this->SHPData["xmax"] = $point["x"];
871
+          }
872
+          if (!isset($this->SHPData["ymax"]) || ($this->SHPData["ymax"] < $point["y"])) {
873
+             $this->SHPData["ymax"] = $point["y"];
874
+          }
875
+          if (isset($point["m"]) && (!isset($this->SHPData["mmax"]) || ($this->SHPData["mmax"] < $point["m"]))) {
876
+             $this->SHPData["mmax"] = $point["m"];
877
+          }
878
+          if (isset($point["z"]) && (!isset($this->SHPData["zmax"]) || ($this->SHPData["zmax"] < $point["z"]))) {
879
+             $this->SHPData["zmax"] = $point["z"];
880
+          }
833 881
 
834 882
           $this->SHPData["parts"][$partIndex]["points"][] = $point;
835 883
 
@@ -839,18 +887,40 @@  discard block
 block discarded – undo
839 887
         case 8:
840 888
         case 18:
841 889
         case 28:
842
-          if (in_array($this->shapeType,array(18,28)) && !isset($point["m"])) $point["m"] = 0.0; // no_value
843
-          if (in_array($this->shapeType,array(18)) && !isset($point["z"])) $point["z"] = 0.0; // no_value
890
+          if (in_array($this->shapeType,array(18,28)) && !isset($point["m"])) {
891
+             $point["m"] = 0.0;
892
+          }
893
+          // no_value
894
+          if (in_array($this->shapeType,array(18)) && !isset($point["z"])) {
895
+             $point["z"] = 0.0;
896
+          }
897
+          // no_value
844 898
 
845 899
           //Adds a new point
846
-          if (!isset($this->SHPData["xmin"]) || ($this->SHPData["xmin"] > $point["x"])) $this->SHPData["xmin"] = $point["x"];
847
-          if (!isset($this->SHPData["ymin"]) || ($this->SHPData["ymin"] > $point["y"])) $this->SHPData["ymin"] = $point["y"];
848
-          if (isset($point["m"]) && (!isset($this->SHPData["mmin"]) || ($this->SHPData["mmin"] > $point["m"]))) $this->SHPData["mmin"] = $point["m"];
849
-          if (isset($point["z"]) && (!isset($this->SHPData["zmin"]) || ($this->SHPData["zmin"] > $point["z"]))) $this->SHPData["zmin"] = $point["z"];
850
-          if (!isset($this->SHPData["xmax"]) || ($this->SHPData["xmax"] < $point["x"])) $this->SHPData["xmax"] = $point["x"];
851
-          if (!isset($this->SHPData["ymax"]) || ($this->SHPData["ymax"] < $point["y"])) $this->SHPData["ymax"] = $point["y"];
852
-          if (isset($point["m"]) && (!isset($this->SHPData["mmax"]) || ($this->SHPData["mmax"] < $point["m"]))) $this->SHPData["mmax"] = $point["m"];
853
-          if (isset($point["z"]) && (!isset($this->SHPData["zmax"]) || ($this->SHPData["zmax"] < $point["z"]))) $this->SHPData["zmax"] = $point["z"];
900
+          if (!isset($this->SHPData["xmin"]) || ($this->SHPData["xmin"] > $point["x"])) {
901
+             $this->SHPData["xmin"] = $point["x"];
902
+          }
903
+          if (!isset($this->SHPData["ymin"]) || ($this->SHPData["ymin"] > $point["y"])) {
904
+             $this->SHPData["ymin"] = $point["y"];
905
+          }
906
+          if (isset($point["m"]) && (!isset($this->SHPData["mmin"]) || ($this->SHPData["mmin"] > $point["m"]))) {
907
+             $this->SHPData["mmin"] = $point["m"];
908
+          }
909
+          if (isset($point["z"]) && (!isset($this->SHPData["zmin"]) || ($this->SHPData["zmin"] > $point["z"]))) {
910
+             $this->SHPData["zmin"] = $point["z"];
911
+          }
912
+          if (!isset($this->SHPData["xmax"]) || ($this->SHPData["xmax"] < $point["x"])) {
913
+             $this->SHPData["xmax"] = $point["x"];
914
+          }
915
+          if (!isset($this->SHPData["ymax"]) || ($this->SHPData["ymax"] < $point["y"])) {
916
+             $this->SHPData["ymax"] = $point["y"];
917
+          }
918
+          if (isset($point["m"]) && (!isset($this->SHPData["mmax"]) || ($this->SHPData["mmax"] < $point["m"]))) {
919
+             $this->SHPData["mmax"] = $point["m"];
920
+          }
921
+          if (isset($point["z"]) && (!isset($this->SHPData["zmax"]) || ($this->SHPData["zmax"] < $point["z"]))) {
922
+             $this->SHPData["zmax"] = $point["z"];
923
+          }
854 924
 
855 925
           $this->SHPData["points"][] = $point;
856 926
           $this->SHPData["numpoints"] = 1 + (isset($this->SHPData["numpoints"])?$this->SHPData["numpoints"]:0);
@@ -872,8 +942,12 @@  discard block
 block discarded – undo
872 942
           //Sets the value of the point to zero
873 943
           $this->SHPData["x"] = 0.0;
874 944
           $this->SHPData["y"] = 0.0;
875
-          if (in_array($this->shapeType,array(11,21))) $this->SHPData["m"] = 0.0;
876
-          if (in_array($this->shapeType,array(11))) $this->SHPData["z"] = 0.0;
945
+          if (in_array($this->shapeType,array(11,21))) {
946
+             $this->SHPData["m"] = 0.0;
947
+          }
948
+          if (in_array($this->shapeType,array(11))) {
949
+             $this->SHPData["z"] = 0.0;
950
+          }
877 951
         break;
878 952
         case 3:
879 953
         case 5:
Please login to merge, or discard this patch.