Completed
Push — master ( 73f088...7f17b6 )
by Yannick
07:13
created
require/libs/geoPHP/lib/adapters/GeoHash.class.php 1 patch
Braces   +55 added lines, -15 removed lines patch added patch discarded remove patch
@@ -19,8 +19,7 @@  discard block
 block discarded – undo
19 19
     $ll = $this->decode($hash);
20 20
     if (!$as_grid) {
21 21
       return new Point($ll['medlon'], $ll['medlat']);
22
-    }
23
-    else {
22
+    } else {
24 23
       return new Polygon(array(
25 24
         new LineString(array(
26 25
           new Point($ll['minlon'], $ll['maxlat']),
@@ -40,12 +39,13 @@  discard block
 block discarded – undo
40 39
    * @see GeoAdapter::write()
41 40
    */
42 41
   public function write(Geometry $geometry, $precision = NULL){
43
-    if ($geometry->isEmpty()) return '';
42
+    if ($geometry->isEmpty()) {
43
+    	return '';
44
+    }
44 45
 
45 46
     if($geometry->geometryType() === 'Point'){
46 47
       return $this->encodePoint($geometry, $precision);
47
-    }
48
-    else {
48
+    } else {
49 49
       // The geohash is the hash grid ID that fits the envelope
50 50
       $envelope = $geometry->envelope();
51 51
       $geohashes = array();
@@ -138,19 +138,59 @@  discard block
 block discarded – undo
138 138
     for($i=0,$c=strlen($hash);$i<$c;$i++) {
139 139
       $v = strpos($this->table,$hash[$i]);
140 140
       if(1&$i) {
141
-        if(16&$v)$minlat = ($minlat+$maxlat)/2; else $maxlat = ($minlat+$maxlat)/2;
142
-        if(8&$v) $minlon = ($minlon+$maxlon)/2; else $maxlon = ($minlon+$maxlon)/2;
143
-        if(4&$v) $minlat = ($minlat+$maxlat)/2; else $maxlat = ($minlat+$maxlat)/2;
144
-        if(2&$v) $minlon = ($minlon+$maxlon)/2; else $maxlon = ($minlon+$maxlon)/2;
145
-        if(1&$v) $minlat = ($minlat+$maxlat)/2; else $maxlat = ($minlat+$maxlat)/2;
141
+        if(16&$v) {
142
+        	$minlat = ($minlat+$maxlat)/2;
143
+        } else {
144
+        	$maxlat = ($minlat+$maxlat)/2;
145
+        }
146
+        if(8&$v) {
147
+        	$minlon = ($minlon+$maxlon)/2;
148
+        } else {
149
+        	$maxlon = ($minlon+$maxlon)/2;
150
+        }
151
+        if(4&$v) {
152
+        	$minlat = ($minlat+$maxlat)/2;
153
+        } else {
154
+        	$maxlat = ($minlat+$maxlat)/2;
155
+        }
156
+        if(2&$v) {
157
+        	$minlon = ($minlon+$maxlon)/2;
158
+        } else {
159
+        	$maxlon = ($minlon+$maxlon)/2;
160
+        }
161
+        if(1&$v) {
162
+        	$minlat = ($minlat+$maxlat)/2;
163
+        } else {
164
+        	$maxlat = ($minlat+$maxlat)/2;
165
+        }
146 166
         $latE /= 8;
147 167
         $lonE /= 4;
148 168
       } else {
149
-        if(16&$v)$minlon = ($minlon+$maxlon)/2; else $maxlon = ($minlon+$maxlon)/2;
150
-        if(8&$v) $minlat = ($minlat+$maxlat)/2; else $maxlat = ($minlat+$maxlat)/2;
151
-        if(4&$v) $minlon = ($minlon+$maxlon)/2; else $maxlon = ($minlon+$maxlon)/2;
152
-        if(2&$v) $minlat = ($minlat+$maxlat)/2; else $maxlat = ($minlat+$maxlat)/2;
153
-        if(1&$v) $minlon = ($minlon+$maxlon)/2; else $maxlon = ($minlon+$maxlon)/2;
169
+        if(16&$v) {
170
+        	$minlon = ($minlon+$maxlon)/2;
171
+        } else {
172
+        	$maxlon = ($minlon+$maxlon)/2;
173
+        }
174
+        if(8&$v) {
175
+        	$minlat = ($minlat+$maxlat)/2;
176
+        } else {
177
+        	$maxlat = ($minlat+$maxlat)/2;
178
+        }
179
+        if(4&$v) {
180
+        	$minlon = ($minlon+$maxlon)/2;
181
+        } else {
182
+        	$maxlon = ($minlon+$maxlon)/2;
183
+        }
184
+        if(2&$v) {
185
+        	$minlat = ($minlat+$maxlat)/2;
186
+        } else {
187
+        	$maxlat = ($minlat+$maxlat)/2;
188
+        }
189
+        if(1&$v) {
190
+        	$minlon = ($minlon+$maxlon)/2;
191
+        } else {
192
+        	$maxlon = ($minlon+$maxlon)/2;
193
+        }
154 194
         $latE /= 4;
155 195
         $lonE /= 8;
156 196
       }
Please login to merge, or discard this patch.
require/libs/geoPHP/lib/adapters/GPX.class.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -34,7 +34,9 @@
 block discarded – undo
34 34
    * @return string The GPX string representation of the input geometries
35 35
    */
36 36
   public function write(Geometry $geometry, $namespace = FALSE) {
37
-    if ($geometry->isEmpty()) return NULL;
37
+    if ($geometry->isEmpty()) {
38
+    	return NULL;
39
+    }
38 40
     if ($namespace) {
39 41
       $this->namespace = $namespace;
40 42
       $this->nss = $namespace.':';    
Please login to merge, or discard this patch.
require/libs/geoPHP/lib/adapters/GeoJSON.class.php 1 patch
Braces   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -120,8 +120,7 @@  discard block
 block discarded – undo
120 120
   public function write(Geometry $geometry, $return_array = FALSE) {
121 121
     if ($return_array) {
122 122
       return $this->getArray($geometry);
123
-    }
124
-    else {
123
+    } else {
125 124
       return json_encode($this->getArray($geometry));
126 125
     }
127 126
   }
@@ -139,11 +138,12 @@  discard block
 block discarded – undo
139 138
         'type'=> 'GeometryCollection',
140 139
         'geometries'=> $component_array,
141 140
       );
142
-    }
143
-    else return array(
141
+    } else {
142
+    	return array(
144 143
       'type'=> $geometry->getGeomType(),
145 144
       'coordinates'=> $geometry->asArray(),
146 145
     );
146
+    }
147 147
   }
148 148
 }
149 149
 
Please login to merge, or discard this patch.
require/libs/geoPHP/lib/adapters/WKB.class.php 1 patch
Braces   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -94,7 +94,9 @@  discard block
 block discarded – undo
94 94
     $line_length = unpack('L',fread($mem,4));
95 95
 
96 96
     // Return an empty linestring if there is no line-length
97
-    if (!$line_length[1]) return new LineString();
97
+    if (!$line_length[1]) {
98
+    	return new LineString();
99
+    }
98 100
 
99 101
     // Read the nubmer of points x2 (each point is two coords) into decimal-floats
100 102
     $line_coords = unpack('d*', fread($mem,$line_length[1]*$this->dimension*8));
@@ -190,8 +192,7 @@  discard block
 block discarded – undo
190 192
     if ($write_as_hex) {
191 193
       $unpacked = unpack('H*',$wkb);
192 194
       return $unpacked[1];
193
-    }
194
-    else {
195
+    } else {
195 196
       return $wkb;
196 197
     }
197 198
   }
Please login to merge, or discard this patch.
require/libs/geoPHP/lib/adapters/KML.class.php 1 patch
Braces   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -89,8 +89,7 @@  discard block
 block discarded – undo
89 89
           }
90 90
         }
91 91
       }
92
-    }
93
-    else {
92
+    } else {
94 93
       // The document does not have a placemark, try to create a valid geometry from the root element
95 94
       $node_name = $this->xmlobj->documentElement->nodeName == 'multigeometry' ? 'geometrycollection' : $this->xmlobj->documentElement->nodeName;
96 95
       if (array_key_exists($node_name, $geom_types)) {
@@ -220,7 +219,9 @@  discard block
 block discarded – undo
220 219
       $str .= '<'.$this->nss.'coordinates>';
221 220
       $i=0;
222 221
       foreach ($geom->getComponents() as $comp) {
223
-        if ($i != 0) $str .= ' ';
222
+        if ($i != 0) {
223
+        	$str .= ' ';
224
+        }
224 225
         $str .= $comp->getX() .','. $comp->getY();
225 226
         $i++;
226 227
       }
Please login to merge, or discard this patch.
require/libs/geoPHP/lib/geometry/Polygon.class.php 1 patch
Braces   +27 added lines, -11 removed lines patch added patch discarded remove patch
@@ -9,7 +9,9 @@  discard block
 block discarded – undo
9 9
   protected $geom_type = 'Polygon';
10 10
 
11 11
   public function area($exterior_only = FALSE, $signed = FALSE) {
12
-    if ($this->isEmpty()) return 0;
12
+    if ($this->isEmpty()) {
13
+    	return 0;
14
+    }
13 15
     
14 16
     if ($this->geos() && $exterior_only == FALSE) {
15 17
       return $this->geos()->area();
@@ -19,15 +21,20 @@  discard block
 block discarded – undo
19 21
     $pts = $exterior_ring->getComponents();
20 22
     
21 23
     $c = count($pts);
22
-    if((int)$c == '0') return NULL;
24
+    if((int)$c == '0') {
25
+    	return NULL;
26
+    }
23 27
     $a = '0';
24 28
     foreach($pts as $k => $p){
25 29
       $j = ($k + 1) % $c;
26 30
       $a = $a + ($p->getX() * $pts[$j]->getY()) - ($p->getY() * $pts[$j]->getX());
27 31
     }
28 32
     
29
-    if ($signed) $area = ($a / 2);
30
-    else $area = abs(($a / 2));
33
+    if ($signed) {
34
+    	$area = ($a / 2);
35
+    } else {
36
+    	$area = abs(($a / 2));
37
+    }
31 38
     
32 39
     if ($exterior_only == TRUE) {
33 40
       return $area;
@@ -42,7 +49,9 @@  discard block
 block discarded – undo
42 49
   }
43 50
   
44 51
   public function centroid() {
45
-    if ($this->isEmpty()) return NULL;
52
+    if ($this->isEmpty()) {
53
+    	return NULL;
54
+    }
46 55
     
47 56
     if ($this->geos()) {
48 57
       return geoPHP::geosToGeometry($this->geos()->centroid());
@@ -52,7 +61,9 @@  discard block
 block discarded – undo
52 61
     $pts = $exterior_ring->getComponents();
53 62
     
54 63
     $c = count($pts);
55
-    if((int)$c == '0') return NULL;
64
+    if((int)$c == '0') {
65
+    	return NULL;
66
+    }
56 67
     $cn = array('x' => '0', 'y' => '0');
57 68
     $a = $this->area(TRUE, TRUE);
58 69
     
@@ -98,12 +109,16 @@  discard block
 block discarded – undo
98 109
   }
99 110
 
100 111
   public function exteriorRing() {
101
-    if ($this->isEmpty()) return new LineString();
112
+    if ($this->isEmpty()) {
113
+    	return new LineString();
114
+    }
102 115
     return $this->components[0];
103 116
   }
104 117
   
105 118
   public function numInteriorRings() {
106
-    if ($this->isEmpty()) return 0;
119
+    if ($this->isEmpty()) {
120
+    	return 0;
121
+    }
107 122
     return $this->numGeometries()-1;
108 123
   }
109 124
   
@@ -112,7 +127,9 @@  discard block
 block discarded – undo
112 127
   }
113 128
   
114 129
   public function dimension() {
115
-    if ($this->isEmpty()) return 0;
130
+    if ($this->isEmpty()) {
131
+    	return 0;
132
+    }
116 133
     return 2;
117 134
   }
118 135
 
@@ -187,8 +204,7 @@  discard block
 block discarded – undo
187 204
     // If the number of edges we passed through is even, then it's in the polygon.
188 205
     if ($intersections % 2 != 0) {
189 206
       return TRUE;
190
-    }
191
-    else {
207
+    } else {
192 208
       return FALSE;
193 209
     }
194 210
   }
Please login to merge, or discard this patch.
require/libs/geoPHP/lib/geometry/Point.class.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -71,8 +71,9 @@
 block discarded – undo
71 71
   public function z() {
72 72
     if ($this->dimention == 3) {
73 73
       return $this->coords[2];
74
+    } else {
75
+    	return NULL;
74 76
     }
75
-    else return NULL;
76 77
   }
77 78
 
78 79
   // A point's centroid is itself
Please login to merge, or discard this patch.
require/libs/geoPHP/lib/geometry/Collection.class.php 1 patch
Braces   +18 added lines, -11 removed lines patch added patch discarded remove patch
@@ -24,8 +24,7 @@  discard block
 block discarded – undo
24 24
     foreach ($components as $component) {
25 25
       if ($component instanceof Geometry) {
26 26
         $this->components[] = $component;
27
-      }
28
-      else {
27
+      } else {
29 28
         throw new Exception("Cannot create a collection with non-geometries");
30 29
       }
31 30
     }
@@ -41,7 +40,9 @@  discard block
 block discarded – undo
41 40
   }
42 41
 
43 42
   public function centroid() {
44
-    if ($this->isEmpty()) return NULL;
43
+    if ($this->isEmpty()) {
44
+    	return NULL;
45
+    }
45 46
 
46 47
     if ($this->geos()) {
47 48
       $geos_centroid = $this->geos()->centroid();
@@ -59,7 +60,9 @@  discard block
 block discarded – undo
59 60
   }
60 61
 
61 62
   public function getBBox() {
62
-    if ($this->isEmpty()) return NULL;
63
+    if ($this->isEmpty()) {
64
+    	return NULL;
65
+    }
63 66
 
64 67
     if ($this->geos()) {
65 68
       $envelope = $this->geos()->envelope();
@@ -127,7 +130,9 @@  discard block
 block discarded – undo
127 130
 
128 131
   // By default, the boundary of a collection is the boundary of it's components
129 132
   public function boundary() {
130
-    if ($this->isEmpty()) return new LineString();
133
+    if ($this->isEmpty()) {
134
+    	return new LineString();
135
+    }
131 136
 
132 137
     if ($this->geos()) {
133 138
       return $this->geos()->boundary();
@@ -149,8 +154,7 @@  discard block
 block discarded – undo
149 154
     $n = intval($n);
150 155
     if (array_key_exists($n-1, $this->components)) {
151 156
       return $this->components[$n-1];
152
-    }
153
-    else {
157
+    } else {
154 158
       return NULL;
155 159
     }
156 160
   }
@@ -193,10 +197,11 @@  discard block
 block discarded – undo
193 197
   public function isEmpty() {
194 198
     if (!count($this->components)) {
195 199
       return TRUE;
196
-    }
197
-    else {
200
+    } else {
198 201
       foreach ($this->components as $component) {
199
-        if (!$component->isEmpty()) return FALSE;
202
+        if (!$component->isEmpty()) {
203
+        	return FALSE;
204
+        }
200 205
       }
201 206
       return TRUE;
202 207
     }
@@ -263,7 +268,9 @@  discard block
 block discarded – undo
263 268
 
264 269
     // A collection is simple if all it's components are simple
265 270
     foreach ($this->components as $component) {
266
-      if (!$component->isSimple()) return FALSE;
271
+      if (!$component->isSimple()) {
272
+      	return FALSE;
273
+      }
267 274
     }
268 275
 
269 276
     return TRUE;
Please login to merge, or discard this patch.
require/libs/geoPHP/lib/geometry/LineString.class.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -54,7 +54,9 @@
 block discarded – undo
54 54
   }
55 55
 
56 56
   public function dimension() {
57
-    if ($this->isEmpty()) return 0;
57
+    if ($this->isEmpty()) {
58
+    	return 0;
59
+    }
58 60
     return 1;
59 61
   }
60 62
 
Please login to merge, or discard this patch.