Passed
Branch master (58539d)
by Mark
02:25
created
geoPHP/lib/adapters/WKB.class.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -30,11 +30,11 @@  discard block
 block discarded – undo
30 30
    */
31 31
   public function read($wkb, $is_hex_string = FALSE) {
32 32
     if ($is_hex_string) {
33
-      $wkb = pack('H*',$wkb);
33
+      $wkb = pack('H*', $wkb);
34 34
     }
35 35
 
36 36
     if (empty($wkb)) {
37
-      throw new Exception('Cannot read empty WKB geometry. Found ' . gettype($wkb));
37
+      throw new Exception('Cannot read empty WKB geometry. Found '.gettype($wkb));
38 38
     }
39 39
 
40 40
     $mem = fopen('php://memory', 'r+');
@@ -74,20 +74,20 @@  discard block
 block discarded – undo
74 74
       case 3:
75 75
         return $this->getPolygon($mem);
76 76
       case 4:
77
-        return $this->getMulti($mem,'point');
77
+        return $this->getMulti($mem, 'point');
78 78
       case 5:
79
-        return $this->getMulti($mem,'line');
79
+        return $this->getMulti($mem, 'line');
80 80
       case 6:
81
-        return $this->getMulti($mem,'polygon');
81
+        return $this->getMulti($mem, 'polygon');
82 82
       case 7:
83
-        return $this->getMulti($mem,'geometry');
83
+        return $this->getMulti($mem, 'geometry');
84 84
     }
85 85
   }
86 86
 
87 87
   function getPoint(&$mem) {
88
-    $point_coords = unpack("d*", fread($mem,$this->dimension*8));
88
+    $point_coords = unpack("d*", fread($mem, $this->dimension * 8));
89 89
     if (!empty($point_coords)) {
90
-      return new Point($point_coords[1],$point_coords[2]);
90
+      return new Point($point_coords[1], $point_coords[2]);
91 91
     }
92 92
     else {
93 93
       return new Point(); // EMPTY point
@@ -96,20 +96,20 @@  discard block
 block discarded – undo
96 96
 
97 97
   function getLinstring(&$mem) {
98 98
     // Get the number of points expected in this string out of the first 4 bytes
99
-    $line_length = unpack('L',fread($mem,4));
99
+    $line_length = unpack('L', fread($mem, 4));
100 100
 
101 101
     // Return an empty linestring if there is no line-length
102 102
     if (!$line_length[1]) return new LineString();
103 103
 
104 104
     // Read the nubmer of points x2 (each point is two coords) into decimal-floats
105
-    $line_coords = unpack('d*', fread($mem,$line_length[1]*$this->dimension*8));
105
+    $line_coords = unpack('d*', fread($mem, $line_length[1] * $this->dimension * 8));
106 106
 
107 107
     // We have our coords, build up the linestring
108 108
     $components = array();
109 109
     $i = 1;
110 110
     $num_coords = count($line_coords);
111 111
     while ($i <= $num_coords) {
112
-      $components[] = new Point($line_coords[$i],$line_coords[$i+1]);
112
+      $components[] = new Point($line_coords[$i], $line_coords[$i+1]);
113 113
       $i += 2;
114 114
     }
115 115
     return new LineString($components);
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 
118 118
   function getPolygon(&$mem) {
119 119
     // Get the number of linestring expected in this poly out of the first 4 bytes
120
-    $poly_length = unpack('L',fread($mem,4));
120
+    $poly_length = unpack('L', fread($mem, 4));
121 121
 
122 122
     $components = array();
123 123
     $i = 1;
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 
131 131
   function getMulti(&$mem, $type) {
132 132
     // Get the number of items expected in this multi out of the first 4 bytes
133
-    $multi_length = unpack('L',fread($mem,4));
133
+    $multi_length = unpack('L', fread($mem, 4));
134 134
 
135 135
     $components = array();
136 136
     $i = 1;
@@ -159,41 +159,41 @@  discard block
 block discarded – undo
159 159
    */
160 160
   public function write(Geometry $geometry, $write_as_hex = FALSE) {
161 161
     // We always write into NDR (little endian)
162
-    $wkb = pack('c',1);
162
+    $wkb = pack('c', 1);
163 163
 
164 164
     switch ($geometry->getGeomType()) {
165 165
       case 'Point';
166
-        $wkb .= pack('L',1);
166
+        $wkb .= pack('L', 1);
167 167
         $wkb .= $this->writePoint($geometry);
168 168
         break;
169 169
       case 'LineString';
170
-        $wkb .= pack('L',2);
170
+        $wkb .= pack('L', 2);
171 171
         $wkb .= $this->writeLineString($geometry);
172 172
         break;
173 173
       case 'Polygon';
174
-        $wkb .= pack('L',3);
174
+        $wkb .= pack('L', 3);
175 175
         $wkb .= $this->writePolygon($geometry);
176 176
         break;
177 177
       case 'MultiPoint';
178
-        $wkb .= pack('L',4);
178
+        $wkb .= pack('L', 4);
179 179
         $wkb .= $this->writeMulti($geometry);
180 180
         break;
181 181
       case 'MultiLineString';
182
-        $wkb .= pack('L',5);
182
+        $wkb .= pack('L', 5);
183 183
         $wkb .= $this->writeMulti($geometry);
184 184
         break;
185 185
       case 'MultiPolygon';
186
-        $wkb .= pack('L',6);
186
+        $wkb .= pack('L', 6);
187 187
         $wkb .= $this->writeMulti($geometry);
188 188
         break;
189 189
       case 'GeometryCollection';
190
-        $wkb .= pack('L',7);
190
+        $wkb .= pack('L', 7);
191 191
         $wkb .= $this->writeMulti($geometry);
192 192
         break;
193 193
     }
194 194
 
195 195
     if ($write_as_hex) {
196
-      $unpacked = unpack('H*',$wkb);
196
+      $unpacked = unpack('H*', $wkb);
197 197
       return $unpacked[1];
198 198
     }
199 199
     else {
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
   function writePoint($point) {
205 205
     // Set the coords
206 206
     if (!$point->isEmpty()) {
207
-      $wkb = pack('dd',$point->x(), $point->y());
207
+      $wkb = pack('dd', $point->x(), $point->y());
208 208
       return $wkb;
209 209
     } else {
210 210
       return '';
@@ -213,11 +213,11 @@  discard block
 block discarded – undo
213 213
 
214 214
   function writeLineString($line) {
215 215
     // Set the number of points in this line
216
-    $wkb = pack('L',$line->numPoints());
216
+    $wkb = pack('L', $line->numPoints());
217 217
 
218 218
     // Set the coords
219 219
     foreach ($line->getComponents() as $point) {
220
-      $wkb .= pack('dd',$point->x(), $point->y());
220
+      $wkb .= pack('dd', $point->x(), $point->y());
221 221
     }
222 222
 
223 223
     return $wkb;
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 
226 226
   function writePolygon($poly) {
227 227
     // Set the number of lines in this poly
228
-    $wkb = pack('L',$poly->numGeometries());
228
+    $wkb = pack('L', $poly->numGeometries());
229 229
 
230 230
     // Write the lines
231 231
     foreach ($poly->getComponents() as $line) {
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 
238 238
   function writeMulti($geometry) {
239 239
     // Set the number of components
240
-    $wkb = pack('L',$geometry->numGeometries());
240
+    $wkb = pack('L', $geometry->numGeometries());
241 241
 
242 242
     // Write the components
243 243
     foreach ($geometry->getComponents() as $component) {
Please login to merge, or discard this patch.
geoPHP/lib/adapters/GeoHash.class.php 1 patch
Spacing   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @see http://en.wikipedia.org/wiki/Geohash
7 7
  *
8 8
  */
9
-class GeoHash extends GeoAdapter{
9
+class GeoHash extends GeoAdapter {
10 10
 
11 11
   /**
12 12
    * base32 encoding character map.
@@ -16,24 +16,24 @@  discard block
 block discarded – undo
16 16
   /**
17 17
    * array of neighbouring hash character maps.
18 18
    */
19
-  private $neighbours = array (
19
+  private $neighbours = array(
20 20
       // north
21
-      'top' => array (
21
+      'top' => array(
22 22
           'even' => 'p0r21436x8zb9dcf5h7kjnmqesgutwvy',
23 23
           'odd' => 'bc01fg45238967deuvhjyznpkmstqrwx'
24 24
       ),
25 25
       // east
26
-      'right' => array (
26
+      'right' => array(
27 27
           'even' => 'bc01fg45238967deuvhjyznpkmstqrwx',
28 28
           'odd' => 'p0r21436x8zb9dcf5h7kjnmqesgutwvy'
29 29
       ),
30 30
       // west
31
-      'left' => array (
31
+      'left' => array(
32 32
           'even' => '238967debc01fg45kmstqrwxuvhjyznp',
33 33
           'odd' => '14365h7k9dcfesgujnmqp0r2twvyx8zb'
34 34
       ),
35 35
       // south
36
-      'bottom' => array (
36
+      'bottom' => array(
37 37
           'even' => '14365h7k9dcfesgujnmqp0r2twvyx8zb',
38 38
           'odd' => '238967debc01fg45kmstqrwxuvhjyznp'
39 39
       )
@@ -42,24 +42,24 @@  discard block
 block discarded – undo
42 42
   /**
43 43
    * array of bordering hash character maps.
44 44
    */
45
-  private $borders = array (
45
+  private $borders = array(
46 46
       // north
47
-      'top' => array (
47
+      'top' => array(
48 48
           'even' => 'prxz',
49 49
           'odd' => 'bcfguvyz'
50 50
       ),
51 51
       // east
52
-      'right' => array (
52
+      'right' => array(
53 53
           'even' => 'bcfguvyz',
54 54
           'odd' => 'prxz'
55 55
       ),
56 56
       // west
57
-      'left' => array (
57
+      'left' => array(
58 58
           'even' => '0145hjnp',
59 59
           'odd' => '028b'
60 60
       ),
61 61
       // south
62
-      'bottom' => array (
62
+      'bottom' => array(
63 63
           'even' => '028b',
64 64
           'odd' => '0145hjnp'
65 65
       )
@@ -95,10 +95,10 @@  discard block
 block discarded – undo
95 95
    * @param Point $geometry
96 96
    * @see GeoAdapter::write()
97 97
    */
98
-  public function write(Geometry $geometry, $precision = NULL){
98
+  public function write(Geometry $geometry, $precision = NULL) {
99 99
     if ($geometry->isEmpty()) return '';
100 100
 
101
-    if($geometry->geometryType() === 'Point'){
101
+    if ($geometry->geometryType() === 'Point') {
102 102
       return $this->encodePoint($geometry, $precision);
103 103
     }
104 104
     else {
@@ -130,30 +130,30 @@  discard block
 block discarded – undo
130 130
    * @author algorithm based on code by Alexander Songe <[email protected]>
131 131
    * @see https://github.com/asonge/php-geohash/issues/1
132 132
    */
133
-  private function encodePoint($point, $precision = NULL){
133
+  private function encodePoint($point, $precision = NULL) {
134 134
     if ($precision === NULL) {
135
-      $lap = strlen($point->y())-strpos($point->y(),".");
136
-      $lop = strlen($point->x())-strpos($point->x(),".");
137
-      $precision = pow(10,-max($lap-1,$lop-1,0))/2;
135
+      $lap = strlen($point->y())-strpos($point->y(), ".");
136
+      $lop = strlen($point->x())-strpos($point->x(), ".");
137
+      $precision = pow(10, -max($lap-1, $lop-1, 0)) / 2;
138 138
     }
139 139
 
140
-    $minlat =  -90;
141
-    $maxlat =   90;
140
+    $minlat = -90;
141
+    $maxlat = 90;
142 142
     $minlon = -180;
143
-    $maxlon =  180;
144
-    $latE   =   90;
145
-    $lonE   =  180;
143
+    $maxlon = 180;
144
+    $latE   = 90;
145
+    $lonE   = 180;
146 146
     $i = 0;
147 147
     $error = 180;
148
-    $hash='';
149
-    while($error>=$precision) {
148
+    $hash = '';
149
+    while ($error >= $precision) {
150 150
       $chr = 0;
151
-      for($b=4;$b>=0;--$b) {
152
-        if((1&$b) == (1&$i)) {
151
+      for ($b = 4; $b >= 0; --$b) {
152
+        if ((1&$b) == (1&$i)) {
153 153
           // even char, even bit OR odd char, odd bit...a lon
154
-          $next = ($minlon+$maxlon)/2;
155
-          if($point->x()>$next) {
156
-            $chr |= pow(2,$b);
154
+          $next = ($minlon+$maxlon) / 2;
155
+          if ($point->x() > $next) {
156
+            $chr |= pow(2, $b);
157 157
             $minlon = $next;
158 158
           } else {
159 159
             $maxlon = $next;
@@ -161,9 +161,9 @@  discard block
 block discarded – undo
161 161
           $lonE /= 2;
162 162
         } else {
163 163
           // odd char, even bit OR even char, odd bit...a lat
164
-          $next = ($minlat+$maxlat)/2;
165
-          if($point->y()>$next) {
166
-            $chr |= pow(2,$b);
164
+          $next = ($minlat+$maxlat) / 2;
165
+          if ($point->y() > $next) {
166
+            $chr |= pow(2, $b);
167 167
             $minlat = $next;
168 168
           } else {
169 169
             $maxlat = $next;
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
       }
174 174
       $hash .= $this->table[$chr];
175 175
       $i++;
176
-      $error = min($latE,$lonE);
176
+      $error = min($latE, $lonE);
177 177
     }
178 178
     return $hash;
179 179
   }
@@ -183,30 +183,30 @@  discard block
 block discarded – undo
183 183
    * @author algorithm based on code by Alexander Songe <[email protected]>
184 184
    * @see https://github.com/asonge/php-geohash/issues/1
185 185
    */
186
-  private function decode($hash){
186
+  private function decode($hash) {
187 187
     $ll = array();
188
-    $minlat =  -90;
189
-    $maxlat =   90;
188
+    $minlat = -90;
189
+    $maxlat = 90;
190 190
     $minlon = -180;
191
-    $maxlon =  180;
192
-    $latE   =   90;
193
-    $lonE   =  180;
194
-    for($i=0,$c=strlen($hash);$i<$c;$i++) {
195
-      $v = strpos($this->table,$hash[$i]);
196
-      if(1&$i) {
197
-        if(16&$v)$minlat = ($minlat+$maxlat)/2; else $maxlat = ($minlat+$maxlat)/2;
198
-        if(8&$v) $minlon = ($minlon+$maxlon)/2; else $maxlon = ($minlon+$maxlon)/2;
199
-        if(4&$v) $minlat = ($minlat+$maxlat)/2; else $maxlat = ($minlat+$maxlat)/2;
200
-        if(2&$v) $minlon = ($minlon+$maxlon)/2; else $maxlon = ($minlon+$maxlon)/2;
201
-        if(1&$v) $minlat = ($minlat+$maxlat)/2; else $maxlat = ($minlat+$maxlat)/2;
191
+    $maxlon = 180;
192
+    $latE   = 90;
193
+    $lonE   = 180;
194
+    for ($i = 0, $c = strlen($hash); $i < $c; $i++) {
195
+      $v = strpos($this->table, $hash[$i]);
196
+      if (1&$i) {
197
+        if (16&$v)$minlat = ($minlat+$maxlat) / 2; else $maxlat = ($minlat+$maxlat) / 2;
198
+        if (8&$v) $minlon = ($minlon+$maxlon) / 2; else $maxlon = ($minlon+$maxlon) / 2;
199
+        if (4&$v) $minlat = ($minlat+$maxlat) / 2; else $maxlat = ($minlat+$maxlat) / 2;
200
+        if (2&$v) $minlon = ($minlon+$maxlon) / 2; else $maxlon = ($minlon+$maxlon) / 2;
201
+        if (1&$v) $minlat = ($minlat+$maxlat) / 2; else $maxlat = ($minlat+$maxlat) / 2;
202 202
         $latE /= 8;
203 203
         $lonE /= 4;
204 204
       } else {
205
-        if(16&$v)$minlon = ($minlon+$maxlon)/2; else $maxlon = ($minlon+$maxlon)/2;
206
-        if(8&$v) $minlat = ($minlat+$maxlat)/2; else $maxlat = ($minlat+$maxlat)/2;
207
-        if(4&$v) $minlon = ($minlon+$maxlon)/2; else $maxlon = ($minlon+$maxlon)/2;
208
-        if(2&$v) $minlat = ($minlat+$maxlat)/2; else $maxlat = ($minlat+$maxlat)/2;
209
-        if(1&$v) $minlon = ($minlon+$maxlon)/2; else $maxlon = ($minlon+$maxlon)/2;
205
+        if (16&$v)$minlon = ($minlon+$maxlon) / 2; else $maxlon = ($minlon+$maxlon) / 2;
206
+        if (8&$v) $minlat = ($minlat+$maxlat) / 2; else $maxlat = ($minlat+$maxlat) / 2;
207
+        if (4&$v) $minlon = ($minlon+$maxlon) / 2; else $maxlon = ($minlon+$maxlon) / 2;
208
+        if (2&$v) $minlat = ($minlat+$maxlat) / 2; else $maxlat = ($minlat+$maxlat) / 2;
209
+        if (1&$v) $minlon = ($minlon+$maxlon) / 2; else $maxlon = ($minlon+$maxlon) / 2;
210 210
         $latE /= 4;
211 211
         $lonE /= 8;
212 212
       }
@@ -215,8 +215,8 @@  discard block
 block discarded – undo
215 215
     $ll['minlon'] = $minlon;
216 216
     $ll['maxlat'] = $maxlat;
217 217
     $ll['maxlon'] = $maxlon;
218
-    $ll['medlat'] = round(($minlat+$maxlat)/2, max(1, -round(log10($latE)))-1);
219
-    $ll['medlon'] = round(($minlon+$maxlon)/2, max(1, -round(log10($lonE)))-1);
218
+    $ll['medlat'] = round(($minlat+$maxlat) / 2, max(1, -round(log10($latE)))-1);
219
+    $ll['medlon'] = round(($minlon+$maxlon) / 2, max(1, -round(log10($lonE)))-1);
220 220
     return $ll;
221 221
   }
222 222
 
@@ -237,11 +237,11 @@  discard block
 block discarded – undo
237 237
    * @param string $direction the direction of the neighbor (top, bottom, left or right)
238 238
    * @return string the geohash of the adjacent cell
239 239
    */
240
-  public function adjacent($hash, $direction){
240
+  public function adjacent($hash, $direction) {
241 241
     $last = substr($hash, -1);
242
-    $type = (strlen($hash) % 2)? 'odd': 'even';
243
-    $base = substr($hash, 0, strlen($hash) - 1);
244
-    if(strpos(($this->borders[$direction][$type]), $last) !== false){
242
+    $type = (strlen($hash) % 2) ? 'odd' : 'even';
243
+    $base = substr($hash, 0, strlen($hash)-1);
244
+    if (strpos(($this->borders[$direction][$type]), $last) !== false) {
245 245
         $base = $this->adjacent($base, $direction);
246 246
     }
247 247
     return $base.$this->table[strpos($this->neighbours[$direction][$type], $last)];
Please login to merge, or discard this patch.
geoPHP/lib/adapters/WKT.class.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -16,10 +16,10 @@  discard block
 block discarded – undo
16 16
     $wkt = trim($wkt);
17 17
 
18 18
     // If it contains a ';', then it contains additional SRID data
19
-    if (strpos($wkt,';')) {
19
+    if (strpos($wkt, ';')) {
20 20
       $parts = explode(';', $wkt);
21 21
       $wkt = $parts[1];
22
-      $eparts = explode('=',$parts[0]);
22
+      $eparts = explode('=', $parts[0]);
23 23
       $srid = $eparts[1];
24 24
     }
25 25
     else {
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
     // If it's marked as empty, then return an empty point
68 68
     if ($data_string == 'EMPTY') return new Point();
69 69
 
70
-    $parts = explode(' ',$data_string);
70
+    $parts = explode(' ', $data_string);
71 71
     return new Point($parts[0], $parts[1]);
72 72
   }
73 73
 
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
     // If it's marked as empty, then return an empty line
78 78
     if ($data_string == 'EMPTY') return new LineString();
79 79
 
80
-    $parts = explode(',',$data_string);
80
+    $parts = explode(',', $data_string);
81 81
     $points = array();
82 82
     foreach ($parts as $part) {
83 83
       $points[] = $this->parsePoint($part);
@@ -91,11 +91,11 @@  discard block
 block discarded – undo
91 91
     // If it's marked as empty, then return an empty polygon
92 92
     if ($data_string == 'EMPTY') return new Polygon();
93 93
 
94
-    $parts = explode('),(',$data_string);
94
+    $parts = explode('),(', $data_string);
95 95
     $lines = array();
96 96
     foreach ($parts as $part) {
97
-      if (!$this->beginsWith($part,'(')) $part = '(' . $part;
98
-      if (!$this->endsWith($part,')'))   $part = $part . ')';
97
+      if (!$this->beginsWith($part, '(')) $part = '('.$part;
98
+      if (!$this->endsWith($part, ')'))   $part = $part.')';
99 99
       $lines[] = $this->parseLineString($part);
100 100
     }
101 101
     return new Polygon($lines);
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
     // If it's marked as empty, then return an empty MutiPoint
108 108
     if ($data_string == 'EMPTY') return new MultiPoint();
109 109
 
110
-    $parts = explode(',',$data_string);
110
+    $parts = explode(',', $data_string);
111 111
     $points = array();
112 112
     foreach ($parts as $part) {
113 113
       $points[] = $this->parsePoint($part);
@@ -121,12 +121,12 @@  discard block
 block discarded – undo
121 121
     // If it's marked as empty, then return an empty multi-linestring
122 122
     if ($data_string == 'EMPTY') return new MultiLineString();
123 123
 
124
-    $parts = explode('),(',$data_string);
124
+    $parts = explode('),(', $data_string);
125 125
     $lines = array();
126 126
     foreach ($parts as $part) {
127 127
       // Repair the string if the explode broke it
128
-      if (!$this->beginsWith($part,'(')) $part = '(' . $part;
129
-      if (!$this->endsWith($part,')'))   $part = $part . ')';
128
+      if (!$this->beginsWith($part, '(')) $part = '('.$part;
129
+      if (!$this->endsWith($part, ')'))   $part = $part.')';
130 130
       $lines[] = $this->parseLineString($part);
131 131
     }
132 132
     return new MultiLineString($lines);
@@ -138,12 +138,12 @@  discard block
 block discarded – undo
138 138
     // If it's marked as empty, then return an empty multi-polygon
139 139
     if ($data_string == 'EMPTY') return new MultiPolygon();
140 140
 
141
-    $parts = explode(')),((',$data_string);
141
+    $parts = explode(')),((', $data_string);
142 142
     $polys = array();
143 143
     foreach ($parts as $part) {
144 144
       // Repair the string if the explode broke it
145
-      if (!$this->beginsWith($part,'((')) $part = '((' . $part;
146
-      if (!$this->endsWith($part,'))'))   $part = $part . '))';
145
+      if (!$this->beginsWith($part, '((')) $part = '(('.$part;
146
+      if (!$this->endsWith($part, '))'))   $part = $part.'))';
147 147
       $polys[] = $this->parsePolygon($part);
148 148
     }
149 149
     return new MultiPolygon($polys);
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 
172 172
     if ($first_paren !== FALSE) {
173 173
       return substr($wkt, $first_paren);
174
-    } elseif (strstr($wkt,'EMPTY')) {
174
+    } elseif (strstr($wkt, 'EMPTY')) {
175 175
       return 'EMPTY';
176 176
     } else
177 177
       return FALSE;
@@ -185,18 +185,18 @@  discard block
 block discarded – undo
185 185
 
186 186
     // We want to only strip off one set of parenthesis
187 187
     if ($this->beginsWith($str, '(')) {
188
-      return substr($str,1,-1);
188
+      return substr($str, 1, -1);
189 189
     }
190 190
     else return $str;
191 191
   }
192 192
 
193 193
   protected function beginsWith($str, $char) {
194
-    if (substr($str,0,strlen($char)) == $char) return TRUE;
194
+    if (substr($str, 0, strlen($char)) == $char) return TRUE;
195 195
     else return FALSE;
196 196
   }
197 197
 
198 198
   protected function endsWith($str, $char) {
199
-    if (substr($str,(0 - strlen($char))) == $char) return TRUE;
199
+    if (substr($str, (0-strlen($char))) == $char) return TRUE;
200 200
     else return FALSE;
201 201
   }
202 202
 
Please login to merge, or discard this patch.
geoPHP/lib/adapters/EWKB.class.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
    */
15 15
   public function read($wkb, $is_hex_string = FALSE) {
16 16
     if ($is_hex_string) {
17
-      $wkb = pack('H*',$wkb);
17
+      $wkb = pack('H*', $wkb);
18 18
     }
19 19
     
20 20
     // Open the wkb up in memory so we can examine the SRID
@@ -51,41 +51,41 @@  discard block
 block discarded – undo
51 51
    */
52 52
   public function write(Geometry $geometry, $write_as_hex = FALSE) {
53 53
     // We always write into NDR (little endian)
54
-    $wkb = pack('c',1);
54
+    $wkb = pack('c', 1);
55 55
     
56 56
     switch ($geometry->getGeomType()) {
57 57
       case 'Point';
58
-        $wkb .= pack('L',1);
58
+        $wkb .= pack('L', 1);
59 59
         $wkb .= $this->writePoint($geometry);
60 60
         break;
61 61
       case 'LineString';
62
-        $wkb .= pack('L',2);
62
+        $wkb .= pack('L', 2);
63 63
         $wkb .= $this->writeLineString($geometry);
64 64
         break;
65 65
       case 'Polygon';
66
-        $wkb .= pack('L',3);
66
+        $wkb .= pack('L', 3);
67 67
         $wkb .= $this->writePolygon($geometry);
68 68
         break;
69 69
       case 'MultiPoint';
70
-        $wkb .= pack('L',4);
70
+        $wkb .= pack('L', 4);
71 71
         $wkb .= $this->writeMulti($geometry);
72 72
         break;
73 73
       case 'MultiLineString';
74
-        $wkb .= pack('L',5);
74
+        $wkb .= pack('L', 5);
75 75
         $wkb .= $this->writeMulti($geometry);
76 76
         break;
77 77
       case 'MultiPolygon';
78
-        $wkb .= pack('L',6);
78
+        $wkb .= pack('L', 6);
79 79
         $wkb .= $this->writeMulti($geometry);
80 80
         break;
81 81
       case 'GeometryCollection';
82
-        $wkb .= pack('L',7);
82
+        $wkb .= pack('L', 7);
83 83
         $wkb .= $this->writeMulti($geometry);
84 84
         break;
85 85
     }
86 86
     
87 87
     if ($write_as_hex) {
88
-      $unpacked = unpack('H*',$wkb);
88
+      $unpacked = unpack('H*', $wkb);
89 89
       return $unpacked[1];
90 90
     }
91 91
     else {
Please login to merge, or discard this patch.
geoPHP/lib/adapters/KML.class.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -52,21 +52,21 @@  discard block
 block discarded – undo
52 52
   public function geomFromText($text) {
53 53
     // Change to lower-case and strip all CDATA
54 54
     $text = mb_strtolower($text, mb_detect_encoding($text));
55
-    $text = preg_replace('/<!\[cdata\[(.*?)\]\]>/s','',$text);
55
+    $text = preg_replace('/<!\[cdata\[(.*?)\]\]>/s', '', $text);
56 56
 
57 57
     // Load into DOMDocument
58 58
     $xmlobj = new DOMDocument();
59 59
     @$xmlobj->loadXML($text);
60 60
     if ($xmlobj === false) {
61
-      throw new Exception("Invalid KML: ". $text);
61
+      throw new Exception("Invalid KML: ".$text);
62 62
     }
63 63
 
64 64
     $this->xmlobj = $xmlobj;
65 65
     try {
66 66
       $geom = $this->geomFromXML();
67
-    } catch(InvalidText $e) {
68
-        throw new Exception("Cannot Read Geometry From KML: ". $text);
69
-    } catch(Exception $e) {
67
+    } catch (InvalidText $e) {
68
+        throw new Exception("Cannot Read Geometry From KML: ".$text);
69
+    } catch (Exception $e) {
70 70
         throw $e;
71 71
     }
72 72
 
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
   protected function parsePoint($xml) {
116 116
     $coordinates = $this->_extractCoordinates($xml);
117 117
     if (!empty($coordinates)) {
118
-      return new Point($coordinates[0][0],$coordinates[0][1]);
118
+      return new Point($coordinates[0][0], $coordinates[0][1]);
119 119
     }
120 120
     else {
121 121
       return new Point();
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
     $coordinates = $this->_extractCoordinates($xml);
127 127
     $point_array = array();
128 128
     foreach ($coordinates as $set) {
129
-      $point_array[] = new Point($set[0],$set[1]);
129
+      $point_array[] = new Point($set[0], $set[1]);
130 130
     }
131 131
     return new LineString($point_array);
132 132
   }
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
       foreach ($coord_sets as $set_string) {
181 181
         $set_string = trim($set_string);
182 182
         if ($set_string) {
183
-          $set_array = explode(',',$set_string);
183
+          $set_array = explode(',', $set_string);
184 184
           if (count($set_array) >= 2) {
185 185
             $coordinates[] = $set_array;
186 186
           }
@@ -226,21 +226,21 @@  discard block
 block discarded – undo
226 226
       $type = $geom->getGeomType();
227 227
     }
228 228
 
229
-    $str = '<'.$this->nss . $type .'>';
229
+    $str = '<'.$this->nss.$type.'>';
230 230
 
231 231
     if (!$geom->isEmpty()) {
232 232
       $str .= '<'.$this->nss.'coordinates>';
233
-      $i=0;
233
+      $i = 0;
234 234
       foreach ($geom->getComponents() as $comp) {
235 235
         if ($i != 0) $str .= ' ';
236
-        $str .= $comp->getX() .','. $comp->getY();
236
+        $str .= $comp->getX().','.$comp->getY();
237 237
         $i++;
238 238
       }
239 239
 
240 240
       $str .= '</'.$this->nss.'coordinates>';
241 241
     }
242 242
 
243
-    $str .= '</'. $this->nss . $type .'>';
243
+    $str .= '</'.$this->nss.$type.'>';
244 244
 
245 245
     return $str;
246 246
   }
@@ -249,13 +249,13 @@  discard block
 block discarded – undo
249 249
     $components = $geom->getComponents();
250 250
     $str = '';
251 251
     if (!empty($components)) {
252
-      $str = '<'.$this->nss.'outerBoundaryIs>' . $this->linestringToKML($components[0], 'LinearRing') . '</'.$this->nss.'outerBoundaryIs>';
252
+      $str = '<'.$this->nss.'outerBoundaryIs>'.$this->linestringToKML($components[0], 'LinearRing').'</'.$this->nss.'outerBoundaryIs>';
253 253
       foreach (array_slice($components, 1) as $comp) {
254
-        $str .= '<'.$this->nss.'innerBoundaryIs>' . $this->linestringToKML($comp) . '</'.$this->nss.'innerBoundaryIs>';
254
+        $str .= '<'.$this->nss.'innerBoundaryIs>'.$this->linestringToKML($comp).'</'.$this->nss.'innerBoundaryIs>';
255 255
       }
256 256
     }
257 257
 
258
-    return '<'.$this->nss.'Polygon>'. $str .'</'.$this->nss.'Polygon>';
258
+    return '<'.$this->nss.'Polygon>'.$str.'</'.$this->nss.'Polygon>';
259 259
   }
260 260
 
261 261
   public function collectionToKML($geom) {
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
       $str .= $sub_adapter->write($comp);
267 267
     }
268 268
 
269
-    return $str .'</'.$this->nss.'MultiGeometry>';
269
+    return $str.'</'.$this->nss.'MultiGeometry>';
270 270
   }
271 271
 
272 272
 }
Please login to merge, or discard this patch.
geoPHP/geoPHP.inc 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
   }
91 91
 
92 92
   static function getAdapterMap() {
93
-    return array (
93
+    return array(
94 94
       'wkt' =>  'WKT',
95 95
       'ewkt' => 'EWKT',
96 96
       'wkb' =>  'WKB',
@@ -153,8 +153,8 @@  discard block
 block discarded – undo
153 153
 
154 154
     // If the geometry cannot even theoretically be reduced more, then pass it back
155 155
     if (gettype($geometry) == 'object') {
156
-      $passbacks = array('Point','LineString','Polygon');
157
-      if (in_array($geometry->geometryType(),$passbacks)) {
156
+      $passbacks = array('Point', 'LineString', 'Polygon');
157
+      if (in_array($geometry->geometryType(), $passbacks)) {
158 158
         return $geometry;
159 159
       }
160 160
     }
@@ -162,8 +162,8 @@  discard block
 block discarded – undo
162 162
     // If it is a mutlti-geometry, check to see if it just has one member
163 163
     // If it does, then pass the member, if not, then just pass back the geometry
164 164
     if (gettype($geometry) == 'object') {
165
-      $simple_collections = array('MultiPoint','MultiLineString','MultiPolygon');
166
-      if (in_array(get_class($geometry),$passbacks)) {
165
+      $simple_collections = array('MultiPoint', 'MultiLineString', 'MultiPolygon');
166
+      if (in_array(get_class($geometry), $passbacks)) {
167 167
         $components = $geometry->getComponents();
168 168
         if (count($components) == 1) {
169 169
           return $components[0];
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
     $geometries = array();
183 183
     $geom_types = array();
184 184
 
185
-    $collections = array('MultiPoint','MultiLineString','MultiPolygon','GeometryCollection');
185
+    $collections = array('MultiPoint', 'MultiLineString', 'MultiPolygon', 'GeometryCollection');
186 186
 
187 187
     foreach ($geometry as $item) {
188 188
       if ($item) {
Please login to merge, or discard this patch.
_test/general.test.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@
 block discarded – undo
30 30
      * Simple test to make sure the plugin.info.txt is in correct format
31 31
      */
32 32
     public function test_plugininfo() {
33
-        $file = __DIR__ . '/../plugin.info.txt';
33
+        $file = __DIR__.'/../plugin.info.txt';
34 34
         $this->assertFileExists($file);
35 35
 
36 36
         $info = confToHash($file);
Please login to merge, or discard this patch.